PARP Research Group University of Murcia, Spain


Video and image input/storage group

Classes and functions to perform image an video input, and storage in image and video files. More...

Classes

class  QVCameraWorker
 Virtual base class to create video reader "input worker blocks" for the QVision application architecture. More...
class  QVMPlayerCamera
 Class to create versatile video input blocks for the QVision application architecture. More...
class  QVMPlayerCameraWorker
 Class to create MPlayer video file reader "input blocks" for the QVision application architecture. More...
class  QVMPlayerProxy
 Class to read from many video formats and devices, based on the MPlayer application. More...
class  QVMPlayerReader
 Class to read from many video formats and devices, based on the MPlayer application. More...
class  QVYUV4MPEG2CameraWorker
 Class to create yuv4mpeg2 video file reader "input blocks" for the QVision application architecture. More...
class  QVYUV4MPEG2Recorder
 Video source class for reading many video file formats, webcams and digital cameras. More...

Functions

bool writeYUV4MPEG2Header (QFile &file, const int cols, const int rows, const int fps)
 Create a yuv4mpeg2 video file.
bool writeYUV4MPEG2Frame (QFile &file, const QVImage< uChar, 1 > imageY, const QVImage< uChar, 1 > imageU, const QVImage< uChar, 1 > imageV)
 Write YUV image frames to a yuv4mpeg2 video file.
bool writeYUV4MPEG2Frame (QFile &file, const QVImage< uChar, 3 > imageRGB)
 Write RGB image frames to a yuv4mpeg2 video file.
bool writeQVImageToFile (const QString fileName, const QVImage< uChar, 3 > &image)
 Write the content of a QVImage (RGB) object in an image file.
bool readQVImageFromFile (const QString fileName, QVImage< uChar, 3 > &image)
 Reads the content of a QVImage (RGB) object from an image file.
bool readYUV4MPEG2Frame (QFile &file, QVImage< uChar > &imageY, QVImage< uChar > &imageU, QVImage< uChar > &imageV)
 Read YUV image frames from a yuv4mpeg2 video file.
bool readYUV4MPEG2Header (QFile &file, int &cols, int &rows, int &fps)
 Read yuv4mpeg2 header from a video file.

Detailed Description

Classes and functions to perform image an video input, and storage in image and video files.


Function Documentation

bool readQVImageFromFile ( const QString  fileName,
QVImage< uChar, 3 > &  image 
)

Reads the content of a QVImage (RGB) object from an image file.

Parameters:
fileName The name of the image file to read from. File format is inferred from fileName suffix. Supported formats: BMP,JPG,PNG,PPM,TIFF,XBM,XPM,GIF,PBM,PGM.
image The image to store in the file.
Returns:
TRUE if success, FALSE otherwise.

Definition at line 73 of file qvio.cpp.

bool readYUV4MPEG2Frame ( QFile &  file,
QVImage< uChar > &  imageY,
QVImage< uChar > &  imageU,
QVImage< uChar > &  imageV 
)

Read YUV image frames from a yuv4mpeg2 video file.

This function retrieves a frame from a video file coded in YUV format. The parameters of this function must be three images to store the three chanels for the YUV image.

For further information about its usage, see documentation for function readYUV4MPEG2Header.

Parameters:
file The input file object. It must be already opened when received as argument by this function.
imageY Image object to contain the Y channel for the YUV image, to store in the video file.
imageU Image object to contain the U channel for the YUV image, to store in the video file.
imageV Image object to contain the V channel for the YUV image, to store in the video file.
See also:
readYUV4MPEG2Header

Definition at line 152 of file qvio.cpp.

bool readYUV4MPEG2Header ( QFile &  file,
int &  cols,
int &  rows,
int &  fps 
)

Read yuv4mpeg2 header from a video file.

This function reads the header of a video file encoded in yuv4mpeg2 format. This header contains information about the size of the frames in the video file, as well as the number of frames per second of the video sequence.

This function can be used with readYUV4MPEG2Frame to retrieve the contents of the video file. An example code usage follows:

// Headers for the QFile and the YUV4MPEG functions.
#include <QFile>
#include <qvio.h>

[...]
// Code for video file reading.
QFile videoFile("test.mpeg");
int cols, rows, fps;

if (!videoFile.open(QIODevice::ReadOnly))
    std::err << "Can't open file 'test.mpeg'." << std::endl;
else if (!readYUV4MPEG2Header(videoFile, cols, rows, fps))
    std::err << "File 'test.mpeg' doesn't seem to contain a valid YUV4MPEG2 header." << std::endl;
else    // Proceed to frame reading
        {
        QVImage<uChar, 1>       imageY(cols, rows, cols),
                                imageU(cols/2, rows/2, cols/2),
                                imageV(cols/2, rows/2, cols/2);

        while (!videoFile.atEnd() && readYUV4MPEG2Frame(videoFile, imageY, imageU, imageV))
                {

                }


        if (videoFile.atEnd())

        }

Parameters:
file The input file object. It must be already opened when received as argument by this function.
cols (output parameter) Number of cols readed in the header
rows (output parameter) Number of rows readed in the header
fps (output parameter) Video fps readed in the header
See also:
readYUV4MPEG2Frame

Definition at line 111 of file qvio.cpp.

bool writeQVImageToFile ( const QString  fileName,
const QVImage< uChar, 3 > &  image 
)

Write the content of a QVImage (RGB) object in an image file.

Parameters:
fileName The name of the image file to create. It is overwritten if already exists. File format is inferred from fileName suffix. Supported formats: BMP,JPG,PNG,PPM,TIFF,XBM,XPM.
image The image to store in the file.
Returns:
TRUE if success, FALSE otherwise.

Definition at line 70 of file qvio.cpp.

bool writeYUV4MPEG2Frame ( QFile &  file,
const QVImage< uChar, 3 >  imageRGB 
)

Write RGB image frames to a yuv4mpeg2 video file.

This function stores a frame in a video file from the RGB format. The parameter of this function is an image containing the RGB image. For further information about its usage, see documentation for function writeYUV4MPEG2Header.

Parameters:
file The input file object. It must be already opened when received as argument by this function.
imageRGB RGB image object, to store in the video file.
See also:
writeYUV4MPEG2Header

Definition at line 56 of file qvio.cpp.

bool writeYUV4MPEG2Frame ( QFile &  file,
const QVImage< uChar, 1 >  imageY,
const QVImage< uChar, 1 >  imageU,
const QVImage< uChar, 1 >  imageV 
)

Write YUV image frames to a yuv4mpeg2 video file.

This is an overloaded version of the function writeYUV4MPEG2Frame(QFile &, const QVImage<uChar,3>) provided for convenience.

This version stores a frame in a video file from the YUV format. The parameters of this function must be three images containing the three chanels for the YUV image. For further information about its usage, see documentation for function writeYUV4MPEG2Header.

Parameters:
file The input file object. It must be already opened when received as argument by this function.
imageY Image object containing the Y channel for the YUV image, to store in the video file.
imageU Image object containing the Y channel for the YUV image, to store in the video file.
imageV Image object containing the Y channel for the YUV image, to store in the video file.
See also:
writeYUV4MPEG2Header

Definition at line 41 of file qvio.cpp.

bool writeYUV4MPEG2Header ( QFile &  file,
const int  cols,
const int  rows,
const int  fps 
)

Create a yuv4mpeg2 video file.

This function stores the header for a video sequence in YUV4MPEG2 format in a newly created file. It can be used in conjunction with any of the versions of the writeYUV4MPEG2Frame functions to store a flow of images in a video file.

The following code illustrates its usage. First the video file must be created and initializated with a header:

#include <QFile>

[...]
QFile videoFile("test.mpeg");
videoFile.open(QIODevice::WriteOnly|QIODevice::Truncate);
writeYUV4MPEG2Header(videoFile, cols, rows, 24);
[...]

Then, each image frame must be stored in the video file, until a stop condition:

while(newImages)
        {
        // Read a new image in RGB format
        QVImage<uChar,3> rgbImage = getNewRGBImage();
        
        // Write the RGB image to the file
        writeYUV4MPEG2Frame(videoFile, rgbImage);
        [...]
        }

Alternatively, an overloaded version of the writeYUV4MPEG2Frame function can be used, to store an image in YUV format:

while(newImages)
        {
        // Read a new YUV image in 4:2:0 format
        QVImage<uChar,1> yImage = getNewYUVImageYChannel();
        QVImage<uChar,1> UImage = getNewYUVImageUChannel();
        QVImage<uChar,1> VImage = getNewYUVImageVChannel();

        // Write the YUV image to the file
        writeYUV4MPEG2Frame(videoFile, yImage, uImage, vImage);
        [...]
        }

when finished storing frames in the video file, it can be closed:

videoFile.close();

Parameters:
file The input file object. It must be already opened when received as argument by this function.
cols The number of columns that the video in the file should have.
rows The number of rows that the video in the file should have.
fps The number of frames per second that the video sequence will have.
See also:
writeYUV4MPEG2Frame(QFile &, const QVImage<uChar,1>, const QVImage<uChar,1>, const QVImage<uChar,1>);

writeYUV4MPEG2Frame(QFile &, const QVImage<uChar,3>);

Definition at line 34 of file qvio.cpp.




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