![]() |
University of Murcia, Spain ![]() |
QVCameraWorker Class ReferenceVirtual base class to create input video reader worker components for the QVision application architecture.
More...
|
Signals | |
void | opened () |
void | closed () |
void | grabbed () |
Public Member Functions | |
QVCameraWorker (QString name=QString("")) | |
Constructor for (virtual) QVCameraWorker class. | |
~QVCameraWorker () | |
bool | linkProperty (QVPropertyContainer *dstCont, QString dstProp) |
Links a QVImage<uChar,3> or QVImage<uChar,1> from the camera to another worker. | |
bool | linkProperty (QVPropertyContainer *dstCont, QString dstProp1, QString dstProp2, QString dstProp3) |
Links 3 QVImage<uChar,1> from the camera (YUV channels) to the corresponding ones of another worker. | |
Protected Member Functions | |
virtual bool | openCam (QString urlName, int &cols, int &rows, int &fps)=0 |
Pure virtual openCam method. | |
virtual void | closeCam ()=0 |
Pure virtual closeCam method. | |
virtual bool | grab (QVImage< uChar, 1 > &imgY, QVImage< uChar, 1 > &imgU, QVImage< uChar, 1 > &imgV)=0 |
Pure virtual grab method. | |
virtual double | lengthOfVideo ()=0 |
Pure virtual method to get the length of the video. | |
virtual double | currentPos ()=0 |
Pure virtual method to get the current time position in the video. | |
Protected Attributes | |
bool | realTime |
bool | noLoop |
This class is pure virtual, and should not be used by normal QVision users (except when implementing their own video sources workers, such as, say, direct driver-based IEEE 1394 or V4L2 cameras; remember, though, that QVMPlayerCameraWorker can read almost any kind of video input source, including live cameras, such as webcams, DV cameras, and so on). Any of its two derived classes QVYUV4MPEG2CameraWorker and QVMPlayerCameraWorker are the classes that normal users will use. See documentation on those classes for more details.
Implementors of new kind of QVCameraWorkers should only have to redefine this five pure virtual methods:
Whose desired behaviour should be self-explanatory: the first one should open the video source specified by the string urlName, trying to open it with the suggested cols, rows and fps. The method must indicates a successful opening by returning true (and updating the corresponding cols, rows and fps output values to the really obtained ones, which could coincide or not with the suggested input values), or false, if there was any problem opening the source. The second must close the video source. The third must grab Y, U and V channel images in the corresponding variable parameters, with respective sizes cols x rows, cols/2 x rows/2 and cols/2 x rows/2 (with cols and rows as returned by the openCam method), returning true if grabbing was succesful, or false otherwise (for example, if the camera was closed). The fourth method must return the length of the video in seconds (or 0.0 if not available; for example, for live video cameras). Finally, the fifth method must return, when called, the current position in the video, again in seconds.
All camera workers inheriting from this class will always have the following properties:
Input properties:
Note.- RealTime property is also input (and as such can be initialized using the command line), but invisible to the GUI (because once the camera has been linked, it cannot be relinked changing its synchronism).
Note.- Note that you can open the camera in a different size of that specified in the real video source file, by setting the desired values of properties Cols and Rows (this class will automatically rescale output images if needed).
Output properties are the following:
Note.- Remember that you can open the camera in a different size of that specified in the real video source file (this class will automatically rescale output images if needed); thus, ColsR and RowsR will always contain the real size of the output images served by this worker.
Output image properties:
Output image properties can (and should!) be linked automatically, without the need of naming them explicitly, using any of the QVCameraWorker::linkProperty() available methods.
Definition at line 86 of file qvcameraworker.h.
QVCameraWorker::QVCameraWorker | ( | QString | name = QString("") |
) |
Constructor for (virtual) QVCameraWorker class.
name | the (optional) name given to the camera worker. |
Definition at line 33 of file qvcameraworker.cpp.
QVCameraWorker::~QVCameraWorker | ( | ) |
Destructor for (virtual) QVCameraWorker class.
Definition at line 78 of file qvcameraworker.cpp.
bool QVCameraWorker::linkProperty | ( | QVPropertyContainer * | dstCont, | |
QString | dstProp | |||
) |
Links a QVImage<uChar,3> or QVImage<uChar,1> from the camera to another worker.
This method will automatically link, using the adequate synchronism (Asynchronous for real time cameras and Synchronous for non real time cameras), a gray or an RGB image in the worker to the corresponding output image property of the camera. An error (return value=false) will occur if dstProp is not of the adequate type (QVImage<uChar,3> or QVImage<uChar,1>).
dstCont | Pointer to the destination worker. | |
dstProp | Name of the destination property. |
Definition at line 182 of file qvcameraworker.cpp.
Referenced by main().
bool QVCameraWorker::linkProperty | ( | QVPropertyContainer * | dstCont, | |
QString | dstProp1, | |||
QString | dstProp2, | |||
QString | dstProp3 | |||
) |
Links 3 QVImage<uChar,1> from the camera (YUV channels) to the corresponding ones of another worker.
This method will automatically link, using the adequate synchronism (Asynchronous for real time cameras and Synchronous for non real time cameras), a set of three one channel images in the worker to the corresponding output image properties of the camera. An error (return value=false) will occur if any of the dstProp are not of the adequate QVImage<uChar,1> type.
dstCont | Pointer to the destination worker. | |
dstProp1 | Name of the destination property for image Y. | |
dstProp2 | Name of the destination property for image U. | |
dstProp3 | Name of the destination property for image V. |
Definition at line 199 of file qvcameraworker.cpp.
virtual bool QVCameraWorker::openCam | ( | QString | urlName, | |
int & | cols, | |||
int & | rows, | |||
int & | fps | |||
) | [protected, pure virtual] |
Pure virtual openCam method.
Reimplementations of this method should open the video source specified by the string urlName, trying to open it with the suggested cols, rows and fps. The method must indicate a successful opening by returning true (and updating the corresponding cols, rows and fps output values to the really obtained ones, which could coincide or not with the suggested input values), or false, if there was any problem opening the source.
urlName | QString determining the video source. | |
cols | Suggested number of columns (as input). On return contains real number of columns (as output). | |
rows | Suggested number of rows (as input). On return contains real number of rows (as output). | |
fps | Suggested fps (as input). On return contains real fps (as output). |
Implemented in QVMPlayerCameraWorker, and QVYUV4MPEG2CameraWorker.
virtual void QVCameraWorker::closeCam | ( | ) | [protected, pure virtual] |
Pure virtual closeCam method.
Reimplementations of this method should close the video source.
Implemented in QVMPlayerCameraWorker, and QVYUV4MPEG2CameraWorker.
virtual bool QVCameraWorker::grab | ( | QVImage< uChar, 1 > & | imgY, | |
QVImage< uChar, 1 > & | imgU, | |||
QVImage< uChar, 1 > & | imgV | |||
) | [protected, pure virtual] |
Pure virtual grab method.
Reimplementations of this method should grab Y, U and V channel images in the corresponding variable parameters, with respective sizes cols x rows, cols/2 x rows/2 and cols/2 x rows/2 (with cols and rows as returned by the openCam() method), returning true if grabbing was succesful, or false otherwise (for example, if the camera was closed).
imgY | On return, contains the grabbed Y image. | |
imgU | On return, contains the grabbed U image. | |
imgV | On return, contains the grabbed V image. |
Implemented in QVMPlayerCameraWorker, and QVYUV4MPEG2CameraWorker.
virtual double QVCameraWorker::lengthOfVideo | ( | ) | [protected, pure virtual] |
Pure virtual method to get the length of the video.
Reimplementations of this method should inform of the length of the video in seconds. A length equal to 0.0 should be returned if not available (for example, for live cameras, remote streaming video, and the like)
Implemented in QVMPlayerCameraWorker, and QVYUV4MPEG2CameraWorker.
virtual double QVCameraWorker::currentPos | ( | ) | [protected, pure virtual] |
Pure virtual method to get the current time position in the video.
Reimplementations of this method should inform of the current position in the video in seconds.
Implemented in QVMPlayerCameraWorker, and QVYUV4MPEG2CameraWorker.
void QVCameraWorker::opened | ( | ) | [signal] |
Emitted each time a new video source is opened.
void QVCameraWorker::closed | ( | ) | [signal] |
Emitted each time the video source is closed.
void QVCameraWorker::grabbed | ( | ) | [signal] |
Emitted each time a new frame is grabbed.