PARP Research Group University of Murcia, Spain


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

Class to read from many video formats and devices, based on the MPlayer application. More...

#include <qvio/qvmplayerproxy.h>

List of all members.

Public Types

enum  OpenOption {
  Default = 0x0, RealTime = 0x1, Deinterlaced = 0x2, NoLoop = 0x4,
  RGBMEncoder = 0x8
}

Public Slots

void pauseCam ()
void unpauseCam ()
void nextFrameCam ()
void setSpeedCam (double d)
 Set the camera speed.
void seekCam (QVCamera::TSeekType type, double pos)
 Moves the camera file to a given position.
void closeCam ()
void pauseCamSlot ()
void unpauseCamSlot ()
void nextFrameCamSlot ()
void setSpeedCamSlot (double d)
void seekCamSlot (QVCamera::TSeekType type, double pos)

Public Member Functions

 QVMPlayerProxy (QString name=QString())
 ~QVMPlayerProxy ()
bool openCam (const QString &urlstring, OpenOptions opts=Default, unsigned int r=0, unsigned int c=0)
 Opens a mplayer source given by its URL, and scales output to a requested size.
bool grab (QVImage< uChar, 3 > &image)
 Grabs a frame in RGB format.
bool grab (QVImage< uChar, 1 > &image)
 Grabs a gray scale frame.
bool grab (QVImage< uChar > &imgY, QVImage< uChar > &imgU, QVImage< uChar > &imgV)
 Grabs a frame in YUV format.
const QString getUrlBase () const
 Returns the current camera name (without path).
OpenOptions getOptions () const
 Returns current camera options.
unsigned int getFramesUpdated () const
 Returns the total number of updated frames.
unsigned int getRows () const
 Returns the number of rows of the buffer.
unsigned int getCols () const
 Returns the number of cols of the buffer.
double getFPS () const
 Returns the camera speed in frames per second.
double getTimeLength () const
 Returns the video file length in seconds.
double getTimePos () const
 Returns the current video position in seconds.
double getSpeed () const
 Returns the current video speed.
unsigned int getFramesGrabbed () const
 Returns number of frames grabbed.
unsigned int getFramesRead () const
 Returns number of frames read.
bool isLiveCamera () const
 Tells if the camera is a live camera.
QVCamera::TCameraStatus getCameraStatus () const
bool isClosed () const
bool isRunning () const
bool isRunningOneStep () const
bool isPaused () const


Detailed Description

Class to read from many video formats and devices, based on the MPlayer application.

This class is based on the MPlayer application. It can read videos from a wide variety of media formats, webcams and digital cameras.

Internally, when used to read from a video source compatible with MPlayer, the QVMPlayerProxy object will launch the MPlayer application to open and read from a video source. The MPlayer will be configured to redirect its output to a pipeline, from which the QVMPlayerProxy class will read the input frames. deo source.

Video source identifier URL formats

Each video source is identified by a URL string, even for video files, webcams, remote videos, etc... this class opens a video source, and reads frames from it, until a stop condition arises or the video finishes.

Simplified camera URL format.

Format: just the path to a file or files. Type of formats
  • For video files:
    path-to-file/file-name.{avi, mpg, dv, ...} 
  • For devices (webcams, digital cams, tv inputs):
    /dev/devicename 
  • For image lists:
    path-to-directory/filemask.{jpg, png, ...} 

Extended camera URL formats.

With previous format there can be incompleteness, ambiguous video input, and other problems. More specific URL formats follows: The format of this string depends of the type of the video source. Notation: [] means optional, {} means alternative:
  • Local video file compatible with mplayer:
    file://[path-to-file/]file-name.{avi, mpg, dv, ...} 
    Path can be relative, or absolute. Absolute paths begin with an extra slash. Examples:
    file:///home/vision/penguin.dv 
    file://../../home/vision/penguin.dv 
  • Remote video file (via http, rtsp, ftp):
    {http,rtsp,ftp}://domain-name/path-to-file/file.{avi, mpg, dv, ...} 
    Examples:
    rtsp://ficheros.7rm.es/7RM/7rm06-01-071430.rm 
    http://perception.inf.um.es/public_data/videos/misc/penguin.dv 
    ftp://user:passwd@server.dom/data/video.avi 

  • DVD | VCD video track (see mplayer man page for correct URL formation for a specific title, track, device, etc.).
    {dvd,vcd}://{video track}
    Examples:
    dvd://2 
    vcd://1 

  • Sequence of multiple JPEG or PNG files:
    mf://path-to/filemask.{jpg, png, ...} 
    Examples:
    mf:///home/user/images/img*.jpg 
    mf:///./images/img*.png 

  • Video 4 linux, video 4 linux 2 camera, and analog inputs:
    {v4l,v4l2,analog}://{device file}?[options] 
    Examples:
    v4l:///dev/video0 
    analog:///dev/video0 
    Note: Optional specifiers H and W are used by mplayer to open the camera in a given source size. Note that this is not the same as opening the camera in a default size and then scaling the output image to a given size using the r and c parameters (see overloaded function). Check manual page for mplayer, for a complete list of options, at parameter '-tv' option specifications.

Camera parameters

Both extended and simplified formats can include special parameters for tuning device input options. Some of these parameters are:
  • width=<value>
    sets the width of the image frames to be read from the video device.
  • height=<value>
    sets the height of the image frames to be read from the video device.
  • fps=<value>
    sets the number of frames per second to be read from the video device.
  • [brightness|contrast|hue|saturation]=[-100, 100]
    sets the brightness, contrast, hue or saturation for the device.
  • channel=<value>
    specifies the tv channel to read images from. You can get a complete list of these options at the MPlayer documentation, about the user line input parameter -tv.

Setting the with and height for the images read from the input device using parameters width and height differs from doing so with options --Cols and --Rows of the input command line. The former can configure the device to capture images using a higher or lesser resolution, while the latter scale the image as MPlayer reads them from the input device.

These options work for video 4 Linux, video 4 Linux 2 camera, and analog inputs. They can be included appending a ? sign after the URL for the device, and separated with & signs. Some example usages of these URL options follow:

  • URL to open a V4L2 device specifying 25 frames per second, image size of 640x480, and minimum brightness:
    v4l2:///dev/video0?height=480&width=640&brightness=-100&fps=25 
  • The same device and configuration using a simplified URL:
    /dev/video0?height=480&width=640&brightness=-100&fps=25 
  • URL to open an tv device at a 320x240 resolution, on channel 42
    analog:///dev/tv?height=240&width=320&channel=42 

See also:
QVMPlayerCamera

Definition at line 234 of file qvmplayerproxy.h.


Member Enumeration Documentation

Open options for a mplayer camera. Combine them using OR (|).

Enumerator:
Default  Default options: don't include any of the other options.
RealTime  Camera runs in an independent, real time thread.
Deinterlaced  Make mplayer deinterlace the image (odd lines).
NoLoop  Continue from the beginning of the video when it ends.
RGBMEncoder  Camera will produce interleave RGB images (instead of YUV).

Definition at line 246 of file qvmplayerproxy.h.


Constructor & Destructor Documentation

QVMPlayerProxy::QVMPlayerProxy ( QString  name = QString()  ) 

Constructs a QVMPlayerProxy, which is initially in "Closed" status.

Definition at line 378 of file qvmplayerproxy.cpp.

QVMPlayerProxy::~QVMPlayerProxy (  ) 

Destroys a QVMPlayerProxy.

Definition at line 388 of file qvmplayerproxy.cpp.


Member Function Documentation

bool QVMPlayerProxy::openCam ( const QString &  urlstring,
OpenOptions  opts = Default,
unsigned int  r = 0,
unsigned int  c = 0 
)

Opens a mplayer source given by its URL, and scales output to a requested size.

(Overloaded function, provided by convenience).

Parameters:
url Camera identifying URL string. See Video source identifier URL formats for URL formats.
r Number of requested output rows.
c Number of requested output cols.
opts Camera opening options (see QVMPlayerProxy::openCam(const QString&,OpenOptions))
Returns:
True if the camera was opened successfully, false otherwise.

Definition at line 509 of file qvmplayerproxy.cpp.

bool QVMPlayerProxy::grab ( QVImage< uChar, 3 > &  image  ) 

Grabs a frame in RGB format.

If the camera is not opened with RGBMencoderMode option, this function will set parameter QVImage to null image.

Parameters:
image QVImage that will store grabbed frame.
Returns:
TRUE if success, FALSE if fail.

Definition at line 640 of file qvmplayerproxy.cpp.

Referenced by QVMPlayerCamera::grab().

bool QVMPlayerProxy::grab ( QVImage< uChar, 1 > &  image  ) 

Grabs a gray scale frame.

If the camera is opened with RGBMencoderMode option, this function will set param QVImage to null image.

Parameters:
image QVImage that will store grabbed frame.
Returns:
True if success, false otherwise.

Definition at line 659 of file qvmplayerproxy.cpp.

bool QVMPlayerProxy::grab ( QVImage< uChar > &  imgY,
QVImage< uChar > &  imgU,
QVImage< uChar > &  imgV 
)

Grabs a frame in YUV format.

This function grabs the image in YUV format, storing each channel Y, U and V, in a separate QVImage of one channel. YUV format would be 422, thus QVImage corresponding to plane Y will be four times bigger than those corresponding to planes U and V.

If the camera is opened with RGBMencoderMode option, this function will set param QVImage's to null images.

Parameters:
imgY QVImage that will store grabbed frame Y channel.
imgU QVImage that will store grabbed frame U channel.
imgV QVImage that will store grabbed frame V channel.
Returns:
True if success, false otherwise.

Definition at line 626 of file qvmplayerproxy.cpp.

const QString QVMPlayerProxy::getUrlBase (  )  const [inline]

Returns the current camera name (without path).

Returns:
Current camera name.
Deprecated:
Use getName() instead

Definition at line 301 of file qvmplayerproxy.h.

Referenced by QVMPlayerCamera::getUrlBase().

OpenOptions QVMPlayerProxy::getOptions (  )  const [inline]

Returns current camera options.

Returns:
Current camera options.

Definition at line 305 of file qvmplayerproxy.h.

Referenced by QVMPlayerCamera::getOptions().

unsigned int QVMPlayerProxy::getFramesUpdated (  )  const [inline]

Returns the total number of updated frames.

Returns:
Current total number of updated frames.

Definition at line 309 of file qvmplayerproxy.h.

Referenced by QVMPlayerCamera::getFramesUpdated().

unsigned int QVMPlayerProxy::getRows (  )  const [inline]

Returns the number of rows of the buffer.

Returns:
Number of rows.

Definition at line 313 of file qvmplayerproxy.h.

Referenced by QVMPlayerCamera::getRows().

unsigned int QVMPlayerProxy::getCols (  )  const [inline]

Returns the number of cols of the buffer.

Returns:
Number of cols.

Definition at line 317 of file qvmplayerproxy.h.

Referenced by QVMPlayerCamera::getCols().

double QVMPlayerProxy::getFPS (  )  const [inline]

Returns the camera speed in frames per second.

Returns:
Camera speed in frames per second.

Definition at line 321 of file qvmplayerproxy.h.

Referenced by QVMPlayerCamera::getFPS().

double QVMPlayerProxy::getTimeLength (  )  const [inline]

Returns the video file length in seconds.

Returns:
Video length in seconds.

Definition at line 325 of file qvmplayerproxy.h.

Referenced by QVMPlayerCamera::getTimeLength().

double QVMPlayerProxy::getTimePos (  )  const [inline]

Returns the current video position in seconds.

Returns:
Current video position in seconds.

Definition at line 329 of file qvmplayerproxy.h.

Referenced by QVMPlayerCamera::getTimePos().

double QVMPlayerProxy::getSpeed (  )  const [inline]

Returns the current video speed.

Returns:
Current video speed (as a multiplier of the FPS).

Definition at line 333 of file qvmplayerproxy.h.

Referenced by QVMPlayerCamera::getSpeed().

unsigned int QVMPlayerProxy::getFramesGrabbed (  )  const [inline]

Returns number of frames grabbed.

Returns:
Number of successful frames returned by grab's

Definition at line 337 of file qvmplayerproxy.h.

Referenced by QVMPlayerCamera::getFramesGrabbed().

unsigned int QVMPlayerProxy::getFramesRead (  )  const [inline]

Returns number of frames read.

Returns:
Number of frames actually read by a camera.

Definition at line 341 of file qvmplayerproxy.h.

Referenced by QVMPlayerCamera::getFramesRead().

bool QVMPlayerProxy::isLiveCamera (  )  const [inline]

Tells if the camera is a live camera.

Returns:
True if camera is a live camera.

Definition at line 345 of file qvmplayerproxy.h.

Referenced by QVMPlayerCamera::isLiveCamera().

void QVMPlayerProxy::pauseCam (  )  [inline, slot]

Pauses the camera.

Definition at line 356 of file qvmplayerproxy.h.

Referenced by QVMPlayerCamera::pauseCam().

void QVMPlayerProxy::unpauseCam (  )  [inline, slot]

Unpauses the camera.

Definition at line 359 of file qvmplayerproxy.h.

Referenced by QVMPlayerCamera::unpauseCam().

void QVMPlayerProxy::nextFrameCam (  )  [inline, slot]

Go to the next frame.

Definition at line 362 of file qvmplayerproxy.h.

Referenced by QVMPlayerCamera::nextFrameCam().

void QVMPlayerProxy::setSpeedCam ( double  d  )  [inline, slot]

Set the camera speed.

Parameters:
d Camera speed (as a multiplier of the FPS)

Definition at line 366 of file qvmplayerproxy.h.

Referenced by QVMPlayerCamera::setSpeedCam().

void QVMPlayerProxy::seekCam ( QVCamera::TSeekType  type,
double  pos 
) [inline, slot]

Moves the camera file to a given position.

Parameters:
type Type of seek: Current=0,Percentage=1,Absolute=2.
pos 
  • If in Current mode: Relative displacement with respect to the current position in seconds.
  • If in Percentage mode: Percentage of total video length.
  • If in Absolute mode: Absolute position in seconds.

Definition at line 374 of file qvmplayerproxy.h.

Referenced by QVMPlayerCamera::seekCam().

void QVMPlayerProxy::closeCam (  )  [slot]

Closes the camera.

Definition at line 591 of file qvmplayerproxy.cpp.

Referenced by QVMPlayerCamera::closeCam(), and ~QVMPlayerProxy().


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



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