QVMPlayerCamera Class Reference

#include <qvmplayercamera/qvmplayercamera.h>

Inheritance diagram for QVMPlayerCamera:
[legend]
Collaboration diagram for QVMPlayerCamera:
[legend]

List of all members.

Public Types

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

Public Slots

bool grab ()
 Grabs a frame from camera input.
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 ()
bool link (QVWorker *, QString imageName)
bool link (QVWorker *, const QString imageY, const QString imageU, const QString imageV)

Public Member Functions

 QVMPlayerCamera (QString name=QString())
 ~QVMPlayerCamera ()
bool openCam (const QString &url, OpenOptions opts=Default)
 Opens a mplayer source given by its URL.
bool openCam (const QString &urlstring, unsigned int r, unsigned int c, OpenOptions opts=Default)
 Opens a mplayer source given by its URL, and scales output to a requested size.
bool openCam ()
 Opens a mplayer source using the internal properties assigned to it. (Overloaded function, provided by convenience; see QVPropertyHolder for details on properties). Used properties:
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.
int getBufferSize () const
 Returns the current frame buffer size.
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.

Static Public Member Functions

static bool getFrame (const QString uri, QVImage< uChar, 3 > &img, int frame=0)
 Grabs a RGB image, from a camera specified with an URI.
static bool getFrame (const QString uri, QVImage< uChar, 1 > &img, int frame=0)
 Grabs a gray image, from a camera specified with an URI.
static bool getFrame (const QString uri, QVImage< uChar > &imgY, QVImage< uChar > &imgU, QVImage< uChar > &imgV, int frame=0)
 Grabs a YUV image, from a camera specified with an URI.


Detailed Description

Mplayer camera class. Universal camera class that reads an image sequence from any source (camera, video file, image files, TV, TDT, ...) using the external program mplayer through a memory (operating system) FIFO.

Definition at line 159 of file qvmplayercamera.h.


Member Enumeration Documentation

enum QVMPlayerCamera::OpenOption

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

Enumerator:
Default  Default camera (no realtime, do not discard frames, do not deinterlace, loop mode, produce YUV images).
RealTime  Camera runs in an independent, real time thread.
Deinterlaced  Make mplayer deinterlace the image (odd lines).
NoLoop  If video reaches end, do not loop. Instead, automatically close the camera.
RGBMEncoder  Camera will produce interleave RGB images (instead of YUV).

Definition at line 172 of file qvmplayercamera.h.


Constructor & Destructor Documentation

QVMPlayerCamera::QVMPlayerCamera ( QString  name = QString()  ) 

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

Definition at line 447 of file qvmplayercamera.cpp.

References QVPropertyHolder::inputFlag, and QVPropertyHolder::outputFlag.

QVMPlayerCamera::~QVMPlayerCamera (  ) 

Destroys a QVMPlayerCamera.

Definition at line 474 of file qvmplayercamera.cpp.

References closeCam().


Member Function Documentation

bool QVMPlayerCamera::openCam ( const QString &  url,
OpenOptions  opts = Default 
)

Opens a mplayer source given by its URL.

Parameters:
url URL of the mplayer source. Possible URLs are ([] means optional, {} means alternative):

Parameters:
opts Or'ed set of opening options (see QVMPlayerCamera::OpenOption).
Returns:
True if the camera was opened successfully, false otherwise.

Definition at line 658 of file qvmplayercamera.cpp.

References openCam().

Referenced by getFrame().

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

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

(Overloaded function, provided by convenience).

Parameters:
url Camera URL (see QVMPlayerCamera::openCam(const QString&,OpenOptions))
r Number of requested output rows.
c Number of requested output cols.
opts Camera opening options (see QVMPlayerCamera::openCam(const QString&,OpenOptions))
Returns:
True if the camera was opened successfully, false otherwise.

bool QVMPlayerCamera::openCam (  ) 

Opens a mplayer source using the internal properties assigned to it. (Overloaded function, provided by convenience; see QVPropertyHolder for details on properties). Used properties:

Returns:
True if the camera was opened successfully, false otherwise.

Definition at line 637 of file qvmplayercamera.cpp.

References Default, and RGBMEncoder.

Referenced by openCam().

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

Grabs a frame in RGB format.

If the camera is not 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 if fail.

Definition at line 906 of file qvmplayercamera.cpp.

Referenced by getFrame().

bool QVMPlayerCamera::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 923 of file qvmplayercamera.cpp.

bool QVMPlayerCamera::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 882 of file qvmplayercamera.cpp.

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

Returns the current camera name (without path).

Returns:
Current camera name.

Definition at line 277 of file qvmplayercamera.h.

OpenOptions QVMPlayerCamera::getOptions (  )  const [inline]

Returns current camera options.

Returns:
Current camera options.

Definition at line 281 of file qvmplayercamera.h.

int QVMPlayerCamera::getBufferSize (  )  const [inline]

Returns the current frame buffer size.

Returns:
Current frame buffer size.

Definition at line 285 of file qvmplayercamera.h.

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

Returns the total number of updated frames.

Returns:
Current total number of updated frames.

Definition at line 289 of file qvmplayercamera.h.

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

Returns the number of rows of the buffer.

Returns:
Number of rows.

Definition at line 293 of file qvmplayercamera.h.

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

Returns the number of cols of the buffer.

Returns:
Number of cols.

Definition at line 297 of file qvmplayercamera.h.

double QVMPlayerCamera::getFPS (  )  const [inline]

Returns the camera speed in frames per second.

Returns:
Camera speed in frames per second.

Definition at line 301 of file qvmplayercamera.h.

double QVMPlayerCamera::getTimeLength (  )  const [inline]

Returns the video file length in seconds.

Returns:
Video length in seconds.

Definition at line 305 of file qvmplayercamera.h.

double QVMPlayerCamera::getTimePos (  )  const [inline]

Returns the current video position in seconds.

Returns:
Current video position in seconds.

Definition at line 309 of file qvmplayercamera.h.

double QVMPlayerCamera::getSpeed (  )  const [inline]

Returns the current video speed.

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

Definition at line 313 of file qvmplayercamera.h.

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

Returns number of frames grabbed.

Returns:
Number of successful frames returned by grab's

Definition at line 317 of file qvmplayercamera.h.

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

Returns number of frames read.

Returns:
Number of frames actually read by a camera.

Definition at line 321 of file qvmplayercamera.h.

bool QVMPlayerCamera::isLiveCamera (  )  const [inline]

Tells if the camera is a live camera.

Returns:
True if camera is a live camera.

Definition at line 325 of file qvmplayercamera.h.

static bool QVMPlayerCamera::getFrame ( const QString  uri,
QVImage< uChar, 3 > &  img,
int  frame = 0 
) [inline, static]

Grabs a RGB image, from a camera specified with an URI.

This function grabs a frame from a video file or url, in RGB format, without having to create explicitly a mplayer camera object, open it, skip frames to the desired, and close the camera.

Parameters:
uri Camera URL (see QVMPlayerCamera::openCam(const QString&,OpenOptions)).
image QVImage that will store grabbed frame.
frame frame number, 0 for first frame.
Returns:
TRUE if success, FALSE if fail.

Definition at line 335 of file qvmplayercamera.h.

References closeCam(), grab(), openCam(), and RGBMEncoder.

static bool QVMPlayerCamera::getFrame ( const QString  uri,
QVImage< uChar, 1 > &  img,
int  frame = 0 
) [inline, static]

Grabs a gray image, from a camera specified with an URI.

This function grabs a gray scale frame from a video file or url, without having to create explicitly a mplayer camera object, open it, skip frames to the desired, and close the camera.

Parameters:
uri Camera URL (see QVMPlayerCamera::openCam(const QString&,OpenOptions)).
image QVImage that will store grabbed frame.
frame frame number, 0 for first frame.
Returns:
TRUE if success, FALSE if fail.

Definition at line 355 of file qvmplayercamera.h.

References closeCam(), Default, grab(), and openCam().

static bool QVMPlayerCamera::getFrame ( const QString  uri,
QVImage< uChar > &  imgY,
QVImage< uChar > &  imgU,
QVImage< uChar > &  imgV,
int  frame = 0 
) [inline, static]

Grabs a YUV image, from a camera specified with an URI.

This function grabs a frame from a video file or url, in YUV format, without having to create explicitly a mplayer camera object, open it, skip frames to the desired, and close the camera.

Parameters:
uri Camera URL (see QVMPlayerCamera::openCam(const QString&,OpenOptions)).
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.
frame frame number, 0 for first frame.
Returns:
TRUE if success, FALSE if fail.

Definition at line 380 of file qvmplayercamera.h.

References closeCam(), Default, grab(), and openCam().

bool QVMPlayerCamera::grab (  )  [slot]

Grabs a frame from camera input.

Grabs an image, and stores it in the corresponding properties of the camera: "RGB image", "Y channel image", "U channel image", and "V channel image".

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

Definition at line 853 of file qvmplayercamera.cpp.

References QVPropertyHolder::writeOutputProperties().

Referenced by link().

void QVMPlayerCamera::pauseCam (  )  [slot]

Pauses the camera.

Definition at line 1003 of file qvmplayercamera.cpp.

void QVMPlayerCamera::unpauseCam (  )  [slot]

Unpauses the camera.

Definition at line 1011 of file qvmplayercamera.cpp.

void QVMPlayerCamera::nextFrameCam (  )  [slot]

Go to the next frame.

Definition at line 1019 of file qvmplayercamera.cpp.

void QVMPlayerCamera::setSpeedCam ( double  d  )  [slot]

Set the camera speed.

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

Definition at line 1027 of file qvmplayercamera.cpp.

void QVMPlayerCamera::seekCam ( QVCamera::TSeekType  type,
double  pos 
) [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.

void QVMPlayerCamera::closeCam (  )  [slot]

Closes the camera.

Definition at line 799 of file qvmplayercamera.cpp.

Referenced by getFrame(), and ~QVMPlayerCamera().


The documentation for this class was generated from the following files:
Generated on Thu Dec 13 13:06:27 2007 for QVision by  doxygen 1.5.3