![]() |
University of Murcia, Spain ![]() |
QVCameraWorker Class ReferenceVirtual base class to create video reader "input worker blocks" for the QVision application architecture.
More...
|
Public Member Functions | |
QVCameraWorker (QString name=QString("")) | |
Constructor for (virtual) QVCameraWorker class. | |
~QVCameraWorker () | |
bool | linkUnspecifiedOutputProperty (QVPropertyContainer *dstCont, QString dstProp) |
Links a QVImage<uChar,3> or QVImage<uChar,1> from the camera to another worker. | |
bool | linkUnspecifiedOutputProperty (QVPropertyContainer *dstCont, QString dstProp1, QString dstProp2, QString dstProp3) |
Links three QVImage<uChar,1> from the camera to the corresponding properties 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. | |
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 three 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. Finally, 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).
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 (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 be linked automatically without the need of naming them explicitly, using the QVCameraWorker::linkUnspecifiedOutputProperty() method.
Definition at line 81 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 76 of file qvcameraworker.cpp.
bool QVCameraWorker::linkUnspecifiedOutputProperty | ( | 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 149 of file qvcameraworker.cpp.
bool QVCameraWorker::linkUnspecifiedOutputProperty | ( | QVPropertyContainer * | dstCont, | |
QString | dstProp1, | |||
QString | dstProp2, | |||
QString | dstProp3 | |||
) |
Links three QVImage<uChar,1> from the camera to the corresponding properties 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 166 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 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.
urlName | QString denoting 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.