PARP Research Group University of Murcia, Spain


QVCameraWorker Class Reference
[Video and image input/storage group]

Virtual base class to create video reader "input worker blocks" for the QVision application architecture. More...

#include <qvio/qvcameraworker.h>

Inherits QVWorker.

Inherited by QVMPlayerCameraWorker, and QVYUV4MPEG2CameraWorker.

List of all members.

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


Detailed Description

Virtual base class to create video reader "input worker blocks" for the QVision application architecture.

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:

  • NoLoop (bool): If the camera should be opened in no loop mode.
  • RealTime (bool): If the camera should be opened in real time mode.
  • URL (QString): URL of the video file to read.
  • Cols (int): Number of suggested columns for the video source.
  • Rows (int): Number of suggested rows for the video source.

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:

  • Opened (bool): Tells if the camera is correctly opened and working.
  • FPS (int): FPS of the video.
  • Frames (int): Number of read frames up to now -not necessarily equal to the number of processed frames, if in real time mode-.
  • ColsR (int): Actual number of columns of the video -not necessarily equal to the number of requested columns, which will in any case be transparently rounded to the nearest upper even integer-.
  • RowsR (int): Actual number of rows of the video -not necessarily equal to the number of requested rows, which will in any case be transparently rounded to the nearest upper even integer-..

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:

  • RGB image (QVImage<uChar,3>): Last grabbed RGB image.
  • Y channel image (QVImage<uChar,1>): Last grabbed Y channel image.
  • U channel image (QVImage<uChar,1>): Last grabbed U channel image.
  • V channel image (QVImage<uChar,1>): Last grabbed V channel image.

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.


Constructor & Destructor Documentation

QVCameraWorker::QVCameraWorker ( QString  name = QString("")  ) 

Constructor for (virtual) QVCameraWorker class.

Parameters:
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.


Member Function Documentation

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>).

Parameters:
dstCont Pointer to the destination worker.
dstProp Name of the destination property.
Returns:
TRUE if success, false otherwise.

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.

Parameters:
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.
Returns:
TRUE if success, false otherwise.

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.

Parameters:
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).
Returns:
TRUE if success, FALSE if fail.

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).

Parameters:
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.


The documentation for this class was generated from the following files:



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