PARP Research Group University of Murcia, Spain


src/qvio/qvmplayercameraworker.cpp

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2007, 2008. PARP Research Group.
00003  *      <http://perception.inf.um.es>
00004  *      University of Murcia, Spain.
00005  *
00006  *      This file is part of the QVision library.
00007  *
00008  *      QVision is free software: you can redistribute it and/or modify
00009  *      it under the terms of the GNU Lesser General Public License as
00010  *      published by the Free Software Foundation, version 3 of the License.
00011  *
00012  *      QVision is distributed in the hope that it will be useful,
00013  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *      GNU Lesser General Public License for more details.
00016  *
00017  *      You should have received a copy of the GNU Lesser General Public
00018  *      License along with QVision. If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00024 
00025 #include <QVMPlayerCameraWorker>
00026 #include <qvipp.h>
00027 
00028 #include <iostream>
00029 #include <qvdefines.h>
00030 
00031 QVMPlayerCameraWorker::QVMPlayerCameraWorker(QString name) : QVCameraWorker(name)
00032 {
00033         addProperty<bool>("Deinterlaced", inputFlag, FALSE,"If the camera should be opened in deinterlaced mode");
00034 }
00035 
00036 
00037 bool QVMPlayerCameraWorker::openCam(QString fileName, int &cols, int &rows, int &fps)
00038         {
00039         // Try to open mplayerreader, and read correct rows, cols and fps.
00040 
00041         QVMPlayerReader::OpenOptions options = QVMPlayerReader::Default;
00042         if(getPropertyValue<bool>("RealTime")) options |= QVMPlayerReader::RealTime;
00043         if(getPropertyValue<bool>("Deinterlaced")) options |= QVMPlayerReader::Deinterlaced;
00044         if(getPropertyValue<bool>("NoLoop")) options |= QVMPlayerReader::NoLoop;
00045 
00046         if(not mplayerreader.openCam(fileName,options,cols,rows))
00047                 {
00048                 QString msg = QString("MPlayer can not open ") + fileName ;
00049                 qWarning() << msg;
00050                 setLastError(msg);
00051                 return FALSE;
00052                 }
00053         else    // Everything correct.
00054                 {
00055                 cols = mplayerreader.getCols();
00056                 rows = mplayerreader.getRows();
00057                 fps = mplayerreader.getFPS();
00058 
00059                 if(mplayerreader.isLiveCamera() and not getPropertyValue<bool>("RealTime"))
00060                         qWarning() <<   "QVMPlayerCameraWorker::openCam: Warning, live cameras should always be opened in\n"
00061                                         "RealTime mode; otherwise, strange delayed (buffered) frames behaviour could be\n"
00062                                         "observed when connected to slow workers, or when pausing the camera.\n";
00063 
00064                 return TRUE;
00065                 }
00066         }
00067 
00068 void QVMPlayerCameraWorker::closeCam()
00069         {
00070         mplayerreader.closeCam();
00071         }
00072 
00073 bool QVMPlayerCameraWorker::grab(QVImage<uChar,1> &imgY, QVImage<uChar,1> &imgU, QVImage<uChar,1> &imgV)
00074         {
00075         return mplayerreader.grab(imgY, imgU, imgV);
00076         }
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 



QVision framework. PARP research group, copyright 2007, 2008.