PARP Research Group University of Murcia, Spain


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

Class to create MPlayer video file reader "input blocks" for the QVision application architecture. More...

#include <qvio/qvmplayercameraworker.h>

Inherits QVCameraWorker.

List of all members.

Public Member Functions

 QVMPlayerCameraWorker (QString name)
 Constructor for QVMPlayerCameraWorker class.
 ~QVMPlayerCameraWorker ()

Protected Member Functions

bool openCam (QString urlName, int &cols, int &rows, int &fps)
 Pure virtual openCam method.
void closeCam ()
 Pure virtual closeCam method.
bool grab (QVImage< uChar, 1 > &imgY, QVImage< uChar, 1 > &imgU, QVImage< uChar, 1 > &imgV)
 Pure virtual grab method.


Detailed Description

Class to create MPlayer video file reader "input blocks" for the QVision application architecture.

This is an implementation of the class QVCameraWorker, based on the QVMPlayerReader interface class for the MPlayer application.

This class can create input blocks to read frames from a video source, in a QVision application. The video sources can be any video file or device connected physically to the computer, or remotely through a network video stream. The class can read from a wide variety of media formats.

For a detailed usage of this class in a QVision application, see section ProgrammingModel. To learn how to specify a given video source for the class, read QVMPlayerReader class documentation. Specifically, the Video source identifier URL formats section.

To use it, create a QVMPlayerCameraWorker object in the main function, and link a gray image, a RGB image, or three (Y,U,V) one channel images from a worker. For example:

int main(int argc, char *argv[])
        {
        [...]
        // The following worker should have a property named 'Output image' containing a gray (QVImage<uChar>) or 
        // (QVImage<uChar,3>) RGB image:
        MyWorker myWorker("My worker");
        [...]
        QVMPlayerCameraWorker camera("Input camera");
        camera.linkUnspecifiedOutputProperty(&myWorker, "Input image");
        [...]
        }

Alternatively you can link simultaneously three properties containing the Y, U and V channels of a YUV image respectively to store images in the video file directly in that format:

int main(int argc, char *argv[])
        {
        [...]
        // The following worker should have three QVImage<uChar,1> properties named 'Input image Y', 'Input image U',
        // and 'Input image V':
        MyWorker myWorker("My worker");
        [...]
        QVMPlayerCameraWorker camera("Input camera");
        camera.linkUnspecifiedOutputProperty(&myWorker, "Input image Y", "Input image U", "Input image V");
        [...]
        }

Input properties are the following:

  • NoLoop (bool): If the MPlayer camera should be opened in no loop mode.
  • RealTime (bool): If the MPlayer camera should be opened in real time mode.
  • Deinterlaced (bool): If the MPlayer camera should deinterlace (using median filter) the video.
  • URL (QString): URL (see QVMPlayerReader ) 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.

You can specify any of the input properties at the start of the program, using the command line parameters; for example, the file to read the video from can be specified by calling the program this way: ./program --File="/home/me/myfile.avi". But modification of these properties can also be done directly in the corresponding graphical widgets when reopening the camera during execution (though, of course, these new values will have no effect until the camera is reopened).

Two important properties are RealTime and NoLoop, both boolean. The first one specifies if the camera will be read in real time mode -possibly leaving frames unprocessed, if processing is slower than reading- (RealTime=true), or at maximum speed -but without leaving any frame unprocessed in any case- (RealTime=false). The second one specifies if the camera will be closed when the end of the file is reached (NoLoop=true), or will loop, starting from the first frame again and again (NoLoop=false).

Output image properties can be linked automatically without the need of naming them explicitly, using the QVCameraWorker::linkUnspecifiedOutputProperty() method.

See also:
QVMPlayerReader

Definition at line 120 of file qvmplayercameraworker.h.


Constructor & Destructor Documentation

QVMPlayerCameraWorker::QVMPlayerCameraWorker ( QString  name  ) 

Constructor for QVMPlayerCameraWorker class.

Parameters:
name the (optional) name given to the camera worker.

Definition at line 31 of file qvmplayercameraworker.cpp.

QVMPlayerCameraWorker::~QVMPlayerCameraWorker (  )  [inline]

Destructor for QVMPlayerCameraWorker class.

Definition at line 129 of file qvmplayercameraworker.h.


Member Function Documentation

bool QVMPlayerCameraWorker::openCam ( QString  urlName,
int &  cols,
int &  rows,
int &  fps 
) [protected, 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.

Implements QVCameraWorker.

Definition at line 37 of file qvmplayercameraworker.cpp.

void QVMPlayerCameraWorker::closeCam (  )  [protected, virtual]

Pure virtual closeCam method.

Reimplementations of this method should close the video source.

Implements QVCameraWorker.

Definition at line 68 of file qvmplayercameraworker.cpp.

bool QVMPlayerCameraWorker::grab ( QVImage< uChar, 1 > &  imgY,
QVImage< uChar, 1 > &  imgU,
QVImage< uChar, 1 > &  imgV 
) [protected, 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.

Implements QVCameraWorker.

Definition at line 73 of file qvmplayercameraworker.cpp.


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



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