![]() |
University of Murcia, Spain ![]() |
QVMPlayerCamera Class ReferenceVideo source class for reading many video file formats, webcams and digital cameras.
More...
|
Public Types | |
enum | OpenOption { Default = 0x0, RealTime = 0x1, Deinterlaced = 0x2, NoLoop = 0x4, RGBMEncoder = 0x8 } |
Open options for a mplayer camera. Combine them using OR (|). More... | |
Public Slots | |
bool | grab () |
Grabs a frame from camera input. | |
void | pauseCam () |
Pauses the camera. | |
void | unpauseCam () |
Unpauses the camera. | |
void | nextFrameCam () |
Go to the next frame. | |
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 () |
Closes the camera. | |
Public Member Functions | |
QVMPlayerCamera (QString name=QString()) | |
Constructs a QVMPlayerCamera, which is initially in "Closed" status. | |
~QVMPlayerCamera () | |
Destroys a QVMPlayerCamera. | |
bool | openCam (const QString &url, OpenOptions opts=Default) |
Opens a video source for image frames reading. | |
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 video source for image reading. This is an overloaded version for openCam(const QString &, unsigned int, unsigned int, OpenOptions) function that will get the url and the configuration options from dynamic properties defined in the camera object. | |
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. |
This is an implementation of the class QVCamera, based on the program MPlayer. This program can read videos from a wide variety of media formats, webcams and digital cameras, and the class QVMPlayerCamera takes advantage of that feature. Thus the QVMPlayerCamera is a good, robust and versatile video input reader class.
Internally, when used to read from a video source compatible with MPlayer, the QVMPlayerCamera object will launch a copy of the MPlayer program, and redirect its output to a named pipe, from which will read the frames from the video source.
For a detailed usage of this class in a QVision application, see section ProgrammingModel.
path-to-file/file-name.{avi, mpg, dv, ...}
/dev/devicename
path-to-directory/filemask.{jpg, png, ...}
file://[path-to-file/]file-name.{avi, mpg, dv, ...}
file:///home/vision/penguin.dv
file://../../home/vision/penguin.dv
{http,rtsp,ftp}://domain-name/path-to-file/file.{avi, mpg, dv, ...}
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}
dvd://2
vcd://1
mf://path-to/filemask.{jpg, png, ...}
mf:///home/user/images/img*.jpg
mf:///./images/img*.png
{v4l,v4l2,analog}://{device file}?[options]
v4l:///dev/video0
analog:///dev/video0
r
and c
parameters (see overloaded function). Check manual page for mplayer, for a complete list of options, at parameter '-tv' option specifications.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:
v4l2:///dev/video0?height=480&width=640&brightness=-100&fps=25
/dev/video0?height=480&width=640&brightness=-100&fps=25
analog:///dev/tv?height=240&width=320&channel=42
Definition at line 237 of file qvmplayercamera.h.
Open options for a mplayer camera. Combine them using OR (|).
Definition at line 250 of file qvmplayercamera.h.
bool QVMPlayerCamera::openCam | ( | const QString & | url, | |
OpenOptions | opts = Default | |||
) |
Opens a video source for image frames reading.
url | URL identifying the device and opening options to open. See Video source identifier URL formats for URL formats. | |
opts | Or'ed set of opening options (see QVMPlayerCamera::OpenOption). |
Definition at line 591 of file qvmplayercamera.cpp.
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).
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 QVMPlayerCamera::openCam(const QString&,OpenOptions)) |
Definition at line 595 of file qvmplayercamera.cpp.
bool QVMPlayerCamera::openCam | ( | ) |
Opens a video source for image reading. This is an overloaded version for openCam(const QString &, unsigned int, unsigned int, OpenOptions) function that will get the url and the configuration options from dynamic properties defined in the camera object.
Used properties:
For further info about the usage of these parameters see QVMPlayerCamera::OpenOption flags.
Definition at line 576 of file qvmplayercamera.cpp.
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 parameter QVImage to null image.
image | QVImage that will store grabbed frame. |
Definition at line 792 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.
image | QVImage that will store grabbed frame. |
Definition at line 813 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.
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. |
Definition at line 774 of file qvmplayercamera.cpp.
const QString QVMPlayerCamera::getUrlBase | ( | ) | const [inline] |
Returns the current camera name (without path).
Definition at line 333 of file qvmplayercamera.h.
OpenOptions QVMPlayerCamera::getOptions | ( | ) | const [inline] |
Returns current camera options.
Definition at line 337 of file qvmplayercamera.h.
int QVMPlayerCamera::getBufferSize | ( | ) | const [inline] |
Returns the current frame buffer size.
Definition at line 341 of file qvmplayercamera.h.
unsigned int QVMPlayerCamera::getFramesUpdated | ( | ) | const [inline] |
Returns the total number of updated frames.
Definition at line 345 of file qvmplayercamera.h.
unsigned int QVMPlayerCamera::getRows | ( | ) | const [inline] |
Returns the number of rows of the buffer.
Definition at line 349 of file qvmplayercamera.h.
Referenced by openCam().
unsigned int QVMPlayerCamera::getCols | ( | ) | const [inline] |
Returns the number of cols of the buffer.
Definition at line 353 of file qvmplayercamera.h.
Referenced by openCam().
double QVMPlayerCamera::getFPS | ( | ) | const [inline] |
Returns the camera speed in frames per second.
Definition at line 357 of file qvmplayercamera.h.
Referenced by openCam().
double QVMPlayerCamera::getTimeLength | ( | ) | const [inline] |
Returns the video file length in seconds.
Definition at line 361 of file qvmplayercamera.h.
double QVMPlayerCamera::getTimePos | ( | ) | const [inline] |
Returns the current video position in seconds.
Definition at line 365 of file qvmplayercamera.h.
double QVMPlayerCamera::getSpeed | ( | ) | const [inline] |
Returns the current video speed.
Definition at line 369 of file qvmplayercamera.h.
unsigned int QVMPlayerCamera::getFramesGrabbed | ( | ) | const [inline] |
Returns number of frames grabbed.
Definition at line 373 of file qvmplayercamera.h.
unsigned int QVMPlayerCamera::getFramesRead | ( | ) | const [inline] |
Returns number of frames read.
Definition at line 377 of file qvmplayercamera.h.
bool QVMPlayerCamera::isLiveCamera | ( | ) | const [inline] |
Tells if the camera is a live camera.
Definition at line 381 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.
uri | Camera URL (see QVMPlayerCamera::openCam(const QString&,OpenOptions)). | |
image | QVImage that will store grabbed frame. | |
frame | frame number, 0 for first frame. |
Definition at line 391 of file qvmplayercamera.h.
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.
uri | Camera URL (see QVMPlayerCamera::openCam(const QString&,OpenOptions)). | |
image | QVImage that will store grabbed frame. | |
frame | frame number, 0 for first frame. |
Definition at line 411 of file qvmplayercamera.h.
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.
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. |
Definition at line 436 of file qvmplayercamera.h.
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".
image | QVImage that will store grabbed frame. |
Definition at line 739 of file qvmplayercamera.cpp.
void QVMPlayerCamera::setSpeedCam | ( | double | d | ) | [slot] |
Set the camera speed.
d | Camera speed (as a multiplier of the FPS) |
Definition at line 909 of file qvmplayercamera.cpp.
void QVMPlayerCamera::seekCam | ( | QVCamera::TSeekType | type, | |
double | pos | |||
) | [slot] |
Moves the camera file to a given position.
type | Type of seek: Current=0,Percentage=1,Absolute=2. | |
pos |
|