Visual Servoing Platform
version 3.6.1 under development (2024-11-21)
|
#include <visp3/io/vpVideoWriter.h>
Public Member Functions | |
vpVideoWriter () | |
virtual | ~vpVideoWriter () |
void | close () |
unsigned int | getCurrentFrameIndex () const |
std::string | getFrameName () const |
void | open (vpImage< vpRGBa > &I) |
void | open (vpImage< unsigned char > &I) |
void | resetFrameCounter () |
void | saveFrame (vpImage< vpRGBa > &I) |
void | saveFrame (vpImage< unsigned char > &I) |
void | setCodec (const int fourcc_codec) |
void | setFileName (const std::string &filename) |
void | setFirstFrameIndex (int first_frame) |
void | setFramerate (const double framerate) |
void | setFrameStep (const int frame_step) |
Class that enables to write easily a video file or a sequence of images.
This class has its own implementation to write a sequence of PGM and PPM images.
This class may benefit from optional 3rd parties:
The following example available in tutorial-video-recorder.cpp shows how this class can be used to record a video from a camera by default in an mpeg file.
The following example shows also how this class can be used to write an image sequence. The images are stored in the folder "./image" and are named "image0000.jpeg", "image0001.jpeg", "image0002.jpeg", ...
The other following example explains how to use the class to write directly an mpeg file.
Definition at line 163 of file vpVideoWriter.h.
BEGIN_VISP_NAMESPACE vpVideoWriter::vpVideoWriter | ( | ) |
Basic constructor.
Definition at line 51 of file vpVideoWriter.cpp.
|
virtual |
Basic destructor.
Definition at line 71 of file vpVideoWriter.cpp.
void vpVideoWriter::close | ( | ) |
Deallocates parameters use to write the video or the image sequence.
Definition at line 262 of file vpVideoWriter.cpp.
References vpException::notInitialized.
|
inline |
Gets the current frame index.
Definition at line 221 of file vpVideoWriter.h.
|
inline |
Return the name of the file in which the last frame was saved.
Definition at line 225 of file vpVideoWriter.h.
void vpVideoWriter::open | ( | vpImage< unsigned char > & | I | ) |
Sets all the parameters needed to write the video or the image sequence.
This function will also create recursively the folders to host the video or the sequence of images.
I | : One image with the right dimensions. |
Definition at line 153 of file vpVideoWriter.cpp.
References vpException::fatalError, vpImage< Type >::getHeight(), vpIoTools::getParent(), vpImage< Type >::getWidth(), vpIoTools::makeDirectory(), and vpImageException::noFileNameError.
Sets all the parameters needed to write the video or the image sequence.
This function will also create recursively the folders to host the video or the sequence of images.
I | : One image with the right dimensions. |
Definition at line 113 of file vpVideoWriter.cpp.
References vpException::fatalError, vpImage< Type >::getHeight(), vpIoTools::getParent(), vpImage< Type >::getWidth(), vpIoTools::makeDirectory(), and vpImageException::noFileNameError.
|
inline |
Reset the frame counter and sets it to the first image index.
By default the first frame index is set to 0.
Definition at line 234 of file vpVideoWriter.h.
void vpVideoWriter::saveFrame | ( | vpImage< unsigned char > & | I | ) |
Saves the image as a frame of the video or as an image belonging to the image sequence.
Each time this method is used, the frame counter is incremented and thus the file name change for the case of an image sequence.
I | : The image which has to be saved. |
Definition at line 227 of file vpVideoWriter.cpp.
References vpImageConvert::convert(), vpException::notInitialized, and vpImageIo::write().
Saves the image as a frame of the video or as an image belonging to the image sequence.
Each time this method is used, the frame counter is incremented and thus the file name change for the case of an image sequence.
I | : The image which has to be saved. |
Definition at line 194 of file vpVideoWriter.cpp.
References vpImageConvert::convert(), vpException::notInitialized, and vpImageIo::write().
|
inline |
Definition at line 240 of file vpVideoWriter.h.
void vpVideoWriter::setFileName | ( | const std::string & | filename | ) |
It enables to set the path and the name of the video or sequence of images which will be saved.
If you want to write a sequence of images, filename
corresponds to the path followed by the image name template. For example, if you want to write different images named image0001.jpeg
, image0002.jpg
, ... and located in the folder /local/image
, filename
will be /local/image/image%04d.jpg
.
filename | : filename template of an image sequence. |
Definition at line 87 of file vpVideoWriter.cpp.
References vpException::badValue, and vpImageException::noFileNameError.
void vpVideoWriter::setFirstFrameIndex | ( | int | first_frame | ) |
Enables to set the first frame index.
first_frame | : The first frame index. Value should be positive. |
Definition at line 340 of file vpVideoWriter.cpp.
References vpException::fatalError.
|
inline |
Sets the framerate in Hz of the video when encoding.
framerate | : The expected framerate. |
By default the framerate is set to 25Hz.
Definition at line 256 of file vpVideoWriter.h.
|
inline |
Set frame step between 2 successive images when a sequence of images is considered.
frame_step | : Step between 2 successive images. The default value is 1. |
Definition at line 264 of file vpVideoWriter.h.