PARP Research Group University of Murcia


QVVideoReaderBlock Class Reference
[Video and image input/output group]

Virtual base class to create input video reader block components for the QVision application architecture. More...

#include <QVVideoReaderBlock>

Inherits QVProcessingBlock.

Inherited by QVMPlayerReaderBlock, and QVYUV4MPEG2ReaderBlock.

List of all members.

Public Types

enum  TCameraStatus { , Running, RunningOneStep, Paused }
 Camera status.
enum  TSeekType
 Options for a seek through the file.

Signals

void opened ()
 Emitted each time a new video source is opened.
void closed ()
 Emitted each time the video source is closed.
void grabbed ()
 Emitted each time a new frame is grabbed.

Public Member Functions

 QVVideoReaderBlock (QString name=QString(""))
 Constructor for (virtual) QVVideoReaderBlock class.
 ~QVVideoReaderBlock ()
 Destructor for (virtual) QVVideoReaderBlock class.
bool linkProperty (QVPropertyContainer *dstCont, QString dstProp)
 Links a QVImage<uChar,3> or QVImage<uChar,1> from the camera to another block.
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 block.

Protected Member Functions

virtual bool open (QString urlName, int &cols, int &rows, int &fps)=0
 Pure virtual open method.
virtual void close ()=0
 Pure virtual close 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.


Detailed Description

Virtual base class to create input video reader block components 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 blocks, such as, say, direct driver-based IEEE 1394 or V4L2 cameras; remember, though, that QVMPlayerReaderBlock 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 QVYUV4MPEG2ReaderBlock and QVMPlayerReaderBlock are the classes that normal users will use. See documentation on those classes for more details.

Implementors of new kind of QVVideoReaderBlocks 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 open 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 blocks 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, by setting the desired values of properties Cols and Rows (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.
  • 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-.
  • Pos (double): Current position in the video, if available (in seconds).
  • Length (double): Length of the video, if available (in seconds).

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

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 (and should!) be linked automatically, without the need of naming them explicitly, using any of the QVVideoReaderBlock::linkProperty() available methods.

Definition at line 86 of file qvvideoreaderblock.h.


Constructor & Destructor Documentation

QVVideoReaderBlock::QVVideoReaderBlock ( QString  name = QString("")  ) 

Constructor for (virtual) QVVideoReaderBlock class.

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

Definition at line 34 of file qvvideoreaderblock.cpp.


Member Function Documentation

bool QVVideoReaderBlock::linkProperty ( QVPropertyContainer dstCont,
QString  dstProp 
)

Links a QVImage<uChar,3> or QVImage<uChar,1> from the camera to another block.

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 block 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 block.
dstProp Name of the destination property.
Returns:
true if success, false otherwise.

Definition at line 183 of file qvvideoreaderblock.cpp.

bool QVVideoReaderBlock::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 block.

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 block 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 block.
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 200 of file qvvideoreaderblock.cpp.

virtual bool QVVideoReaderBlock::open ( QString  urlName,
int &  cols,
int &  rows,
int &  fps 
) [protected, pure virtual]

Pure virtual open 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.

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

Implemented in QVMPlayerReaderBlock, and QVYUV4MPEG2ReaderBlock.

virtual void QVVideoReaderBlock::close (  )  [protected, pure virtual]

Pure virtual close method.

Reimplementations of this method should close the video source.

Implemented in QVMPlayerReaderBlock, and QVYUV4MPEG2ReaderBlock.

virtual bool QVVideoReaderBlock::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 open() 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 QVMPlayerReaderBlock, and QVYUV4MPEG2ReaderBlock.

virtual double QVVideoReaderBlock::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 QVMPlayerReaderBlock, and QVYUV4MPEG2ReaderBlock.

virtual double QVVideoReaderBlock::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 QVMPlayerReaderBlock, and QVYUV4MPEG2ReaderBlock.


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



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