ViSP
2.8.0
|
#include <vpVideoReader.h>
Public Member Functions | |
vpVideoReader () | |
~vpVideoReader () | |
void | acquire (vpImage< vpRGBa > &I) |
void | acquire (vpImage< unsigned char > &I) |
void | close () |
bool | end () |
bool | getFrame (vpImage< vpRGBa > &I, long frame) |
bool | getFrame (vpImage< unsigned char > &I, long frame) |
double | getFramerate () const |
long | getFrameIndex () const |
long | getLastFrameIndex () const |
void | open (vpImage< vpRGBa > &I) |
void | open (vpImage< unsigned char > &I) |
void | resetFrameCounter () |
void | setFileName (const char *filename) |
void | setFileName (const std::string &filename) |
void | setFirstFrameIndex (const long firstFrame) |
void | setLastFrameIndex (const long lastFrame) |
unsigned int | getHeight () const |
unsigned int | getWidth () const |
Public Attributes | |
bool | init |
Protected Attributes | |
unsigned int | height |
unsigned int | width |
Class that enables to manipulate easily a video file or a sequence of images. As it inherits from the vpFrameGrabber Class, it can be used like an other frame grabber class.
The following example available in tutorial-grabber-video.cpp shows how this class is really easy to use. It enables to read a video file named video.mpeg.
As shown in the next example, this class allows also to access to a specific frame. But be careful, for video files, the getFrame() method is not precise and returns the nearest intra key frame from the expected frame. You can use the getFrame() method to position the reader in the video and then use the acquire() method to get the following frames one by one.
The other following example explains how to use the class to read a sequence of images. The images are stored in the folder "./image" and are named "image0000.jpeg", "image0001.jpeg", "image0002.jpeg", ... As explained in setFirstFrameIndex() it is also possible to set the first and last image numbers.
Note that it is also possible to access to a specific frame using getFrame().
Definition at line 152 of file vpVideoReader.h.
vpVideoReader::vpVideoReader | ( | ) |
Basic constructor.
Definition at line 57 of file vpVideoReader.cpp.
vpVideoReader::~vpVideoReader | ( | ) |
Basic destructor.
Definition at line 76 of file vpVideoReader.cpp.
Grabs the current (k) image in the stack of frames and increments the frame counter in order to grab the next image (k+1) during the next use of the method. If open() was not called priviously, this method opens the video reader.
This method enables to use the class as frame grabber.
I | : The image where the frame is stored. |
Implements vpFrameGrabber.
Definition at line 287 of file vpVideoReader.cpp.
References vpDiskGrabber::acquire(), vpFFMPEG::acquire(), and open().
|
virtual |
Grabs the kth image in the stack of frames and increments the frame counter in order to grab the next image (k+1) during the next use of the method.
This method enables to use the class as frame grabber.
I | : The image where the frame is stored. |
Implements vpFrameGrabber.
Definition at line 312 of file vpVideoReader.cpp.
References vpDiskGrabber::acquire(), vpFFMPEG::acquire(), and open().
|
inlinevirtual |
This virtual function is used to de-allocate the memory used by a specific frame grabber
Implements vpFrameGrabber.
Definition at line 207 of file vpVideoReader.h.
|
inline |
Definition at line 212 of file vpVideoReader.h.
Gets the th frame and stores it in the image .
I | : The vpImage used to stored the frame. |
frame | : The index of the frame which has to be read. |
Definition at line 341 of file vpVideoReader.cpp.
References vpDiskGrabber::acquire(), vpFFMPEG::getFrame(), and vpERROR_TRACE.
Referenced by open().
bool vpVideoReader::getFrame | ( | vpImage< unsigned char > & | I, |
long | frame | ||
) |
Gets the th frame and stores it in the image .
I | : The vpImage used to stored the frame. |
frame | : The index of the frame which has to be read. |
Definition at line 382 of file vpVideoReader.cpp.
References vpDiskGrabber::acquire(), vpFFMPEG::getFrame(), and vpERROR_TRACE.
|
inline |
Get the current frame index. This index is updated at each call of the acquire method. It can be used to detect the end of a file (comparison with getLastFrameIndex()).
Definition at line 228 of file vpVideoReader.h.
double vpVideoReader::getFramerate | ( | ) | const |
Return the framerate in Hz used to encode the video stream.
If the video is a sequence of images, return -1.
Definition at line 551 of file vpVideoReader.cpp.
References vpFFMPEG::getFramerate().
|
inlineinherited |
Return the number of rows in the image.
Definition at line 119 of file vpFrameGrabber.h.
Referenced by vp1394Grabber::acquire(), and vp1394Grabber::open().
|
inline |
Gets the last frame index.
Definition at line 235 of file vpVideoReader.h.
|
inlineinherited |
Return the number of columns in the image.
Definition at line 121 of file vpFrameGrabber.h.
Referenced by vp1394Grabber::acquire(), and vp1394Grabber::open().
Sets all the parameters needed to read the video or the image sequence.
Grab the first frame and stores it in the image .
I | : The image where the frame is stored. |
Implements vpFrameGrabber.
Definition at line 136 of file vpVideoReader.cpp.
References vpFFMPEG::COLORED, vpException::fatalError, getFrame(), vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpFrameGrabber::height, vpFFMPEG::initStream(), vpException::ioError, vpImageException::noFileNameError, vpFFMPEG::openStream(), vpDiskGrabber::setGenericName(), vpDiskGrabber::setImageNumber(), vpERROR_TRACE, and vpFrameGrabber::width.
Referenced by acquire().
|
virtual |
Sets all the parameters needed to read the video or the image sequence.
Grab the first frame and stores it in the image .
I | : The image where the frame is stored. |
Implements vpFrameGrabber.
Definition at line 211 of file vpVideoReader.cpp.
References vpException::fatalError, getFrame(), vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpFFMPEG::GRAY_SCALED, vpFrameGrabber::height, vpFFMPEG::initStream(), vpException::ioError, vpImageException::noFileNameError, vpFFMPEG::openStream(), vpDiskGrabber::setGenericName(), vpDiskGrabber::setImageNumber(), vpERROR_TRACE, and vpFrameGrabber::width.
|
inline |
Reset the frame counter and sets it to the first image index.
By default the first frame index is set to 0.
This method is useful if you use the class like a frame grabber (ie with theacquire method).
Definition at line 246 of file vpVideoReader.h.
void vpVideoReader::setFileName | ( | const char * | filename | ) |
It enables to set the path and the name of the file(s) which as/have to be read.
If you want to read a video file, corresponds to the path to the file (example : /local/video.mpeg).
If you want to read a sequence of images, corresponds to the path followed by the image name template. For exemple, if you want to read different images named image0001.jpeg, image0002.jpg, ... and located in the folder /local/image, will be "/local/image/image%04d.jpg".
filename | : Path to a video file or file name template of a image sequence. |
Definition at line 100 of file vpVideoReader.cpp.
References vpImageException::noFileNameError, and vpERROR_TRACE.
Referenced by setFileName().
void vpVideoReader::setFileName | ( | const std::string & | filename | ) |
It enables to set the path and the name of the file(s) which as/have to be read.
If you want to read a video file, corresponds to the path to the file (example : /local/video.mpeg).
If you want to read a sequence of images, corresponds to the path followed by the image name template. For exemple, if you want to read different images named image0001.jpeg, image0002.jpg, ... and located in the folder /local/image, will be "/local/image/image%04d.jpg".
filename | : Path to a video file or file name template of a image sequence. |
Definition at line 124 of file vpVideoReader.cpp.
References setFileName().
|
inline |
Enables to set the first frame index if you want to use the class like a grabber (ie with the acquire method).
firstFrame | : The first frame index. |
Definition at line 257 of file vpVideoReader.h.
|
inline |
Enables to set the last frame index.
lastFrame | : The last frame index. |
Definition at line 268 of file vpVideoReader.h.
|
protectedinherited |
Number of rows in the image.
Definition at line 113 of file vpFrameGrabber.h.
Referenced by vpDiskGrabber::acquire(), vpV4l2Grabber::acquire(), vp1394TwoGrabber::acquire(), vp1394TwoGrabber::dequeue(), vp1394Grabber::getHeight(), vp1394TwoGrabber::getHeight(), vpDiskGrabber::open(), vpV4l2Grabber::open(), open(), vp1394CMUGrabber::open(), vpOpenCVGrabber::setHeight(), vpV4l2Grabber::setHeight(), vp1394CMUGrabber::setVideoMode(), vp1394TwoGrabber::setVideoMode(), vp1394CMUGrabber::vp1394CMUGrabber(), vp1394TwoGrabber::vp1394TwoGrabber(), vpOpenCVGrabber::vpOpenCVGrabber(), and vpV4l2Grabber::vpV4l2Grabber().
|
inherited |
Set to true if the frame grabber has been initialized.
Definition at line 111 of file vpFrameGrabber.h.
Referenced by vpOpenCVGrabber::acquire(), vp1394Grabber::acquire(), vpV4l2Grabber::acquire(), vpOpenCVGrabber::close(), vp1394CMUGrabber::close(), vp1394TwoGrabber::close(), vpOpenCVGrabber::open(), vpDiskGrabber::open(), vp1394Grabber::open(), vpV4l2Grabber::open(), vp1394TwoGrabber::resetBus(), vp1394CMUGrabber::vp1394CMUGrabber(), vp1394Grabber::vp1394Grabber(), vp1394TwoGrabber::vp1394TwoGrabber(), vpDiskGrabber::vpDiskGrabber(), vpOpenCVGrabber::vpOpenCVGrabber(), and vpV4l2Grabber::vpV4l2Grabber().
|
protectedinherited |
Number of columns in the image.
Definition at line 114 of file vpFrameGrabber.h.
Referenced by vpDiskGrabber::acquire(), vpV4l2Grabber::acquire(), vp1394TwoGrabber::acquire(), vp1394TwoGrabber::dequeue(), vp1394Grabber::getWidth(), vp1394TwoGrabber::getWidth(), vpDiskGrabber::open(), vpV4l2Grabber::open(), open(), vp1394CMUGrabber::open(), vp1394CMUGrabber::setVideoMode(), vp1394TwoGrabber::setVideoMode(), vpOpenCVGrabber::setWidth(), vpV4l2Grabber::setWidth(), vp1394CMUGrabber::vp1394CMUGrabber(), vp1394TwoGrabber::vp1394TwoGrabber(), vpOpenCVGrabber::vpOpenCVGrabber(), and vpV4l2Grabber::vpV4l2Grabber().