![]() |
University of Murcia ![]() |
QVYUV4MPEG2ReaderBlock Class ReferenceClass to create YUV4MPEG2 input video reader block components for the QVision application architecture.
More...
|
Public Member Functions | |
QVYUV4MPEG2ReaderBlock (QString name=QString("")) | |
Constructor for QVYUV4MPEG2ReaderBlock class. | |
~QVYUV4MPEG2ReaderBlock () | |
Destructor for QVYUV4MPEG2ReaderBlock class. | |
Protected Member Functions | |
bool | open (QString urlName, int &cols, int &rows, int &fps) |
Pure virtual open method. | |
void | close () |
Pure virtual close method. | |
bool | grab (QVImage< uChar, 1 > &imgY, QVImage< uChar, 1 > &imgU, QVImage< uChar, 1 > &imgV) |
Pure virtual grab method. | |
double | lengthOfVideo () |
Pure virtual method to get the length of the video. | |
double | currentPos () |
Pure virtual method to get the current time position in the video. |
This is an implementation of the class QVVideoReaderBlock, which can be used to create video input blocks for a QVision application architecture (see QVVideoReaderBlock documentation for more details on generic camera blocks). These blocks can read image frames from video files stored in the yuv4mpeg2 format.
To use it, create a QVYUV4MPEG2ReaderBlock object in the main function, and link a gray image, a RGB image, or three (Y,U,V) one channel images from a block. For example:
int main(int argc, char *argv[]) { [...] // The following block should have a property named 'Output image' containing a gray (QVImage<uChar>) or // (QVImage<uChar,3>) RGB image: MyBlock myBlock("My block"); [...] QVYUV4MPEG2ReaderBlock camera("Input camera"); camera.linkProperty(&myBlock, "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 block should have three QVImage<uChar,1> properties named 'Input image Y', 'Input image U', // and 'Input image V': MyBlock myBlock("My block"); [...] QVYUV4MPEG2ReaderBlock camera("Input camera"); camera.linkProperty(&myBlock, "Input image Y", "Input image U", "Input image V"); [...] }
Input properties are the following:
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 block.
Output image properties:
Output image properties can (and should!) be linked automatically, without the need of naming them explicitly, using any of the QVVideoReaderBlock::linkProperty() available methods.
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.yuv". 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).
Definition at line 111 of file qvyuv4mpeg2readerblock.h.
QVYUV4MPEG2ReaderBlock::QVYUV4MPEG2ReaderBlock | ( | QString | name = QString("") |
) | [inline] |
Constructor for QVYUV4MPEG2ReaderBlock class.
name | the (optional) name given to the camera block. |
Definition at line 117 of file qvyuv4mpeg2readerblock.h.
bool QVYUV4MPEG2ReaderBlock::open | ( | QString | urlName, | |
int & | cols, | |||
int & | rows, | |||
int & | fps | |||
) | [protected, 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.
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). |
Implements QVVideoReaderBlock.
Definition at line 32 of file qvyuv4mpeg2readerblock.cpp.
void QVYUV4MPEG2ReaderBlock::close | ( | ) | [protected, virtual] |
Pure virtual close method.
Reimplementations of this method should close the video source.
Implements QVVideoReaderBlock.
Definition at line 110 of file qvyuv4mpeg2readerblock.cpp.
Referenced by ~QVYUV4MPEG2ReaderBlock().
bool QVYUV4MPEG2ReaderBlock::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 open() 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. |
Implements QVVideoReaderBlock.
Definition at line 115 of file qvyuv4mpeg2readerblock.cpp.
double QVYUV4MPEG2ReaderBlock::lengthOfVideo | ( | ) | [protected, 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)
Implements QVVideoReaderBlock.
Definition at line 171 of file qvyuv4mpeg2readerblock.cpp.
double QVYUV4MPEG2ReaderBlock::currentPos | ( | ) | [protected, 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.
Implements QVVideoReaderBlock.
Definition at line 176 of file qvyuv4mpeg2readerblock.cpp.