PARP Research Group University of Murcia, Spain


src/qvio/qvcameraworker.h

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2007, 2008, 2009. 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 #ifndef QVCAMERAWORKER_H
00026 #define QVCAMERAWORKER_H
00027 
00028 #include <QVWorker>
00029 #include <QVImage>
00030 
00086 class QVCameraWorker: public QVWorker
00087         {
00088         Q_OBJECT
00089         public:
00093                 QVCameraWorker(QString name = QString(""));
00094 
00096                 ~QVCameraWorker();
00097 
00108                 bool linkProperty(QVPropertyContainer *dstCont, QString dstProp);
00109 
00122                 bool linkProperty(QVPropertyContainer *dstCont, QString dstProp1, QString dstProp2, QString dstProp3);
00123 
00124         protected:
00125                 bool realTime, noLoop;
00126 
00139                 virtual bool openCam(QString urlName, int &cols, int &rows, int &fps) = 0;
00140 
00144                 virtual void closeCam() = 0;
00145 
00155                 virtual bool grab(QVImage<uChar,1> &imgY, QVImage<uChar,1> &imgU, QVImage<uChar,1> &imgV) = 0;
00156 
00162                 virtual double lengthOfVideo() = 0;
00163 
00167                 virtual double currentPos() = 0;
00168 
00169         private slots:
00173                 virtual void setCurrentPos(double time_pos) = 0;
00174 
00179                 void reopen();
00180 
00184                 void resetCameraWorker();
00185 
00186                 void grabFrame();
00187 
00188                 void nothing() { /* Just to block connected workers if in real time (using Qt::BlockingQueuedConnection) */ };
00189 
00190         private:
00191                 bool flush_pending_images;
00192                 QString urlName;
00193                 QVImage<uChar,1> imageY, imageU, imageV;
00194 
00195                 void tryOpeningCam();
00196                 void iterate();
00197                 void connectOrDisconnectLinkedWorkers(bool connect_disconnect);
00198 
00199         signals:
00201                 void opened();
00202 
00204                 void closed();
00205 
00207                 void grabbed();
00208 
00209         };
00210 
00211 #endif



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