An output stream which takes a sequence of images and writes a video file in any of a given of compatible formats.
The output file is open when calling "open", and it's closed at destructor or after calling "close".
Example of usage:
There are two methods for adding frames to the video:
Definition at line 43 of file CVideoFileWriter.h.
#include <mrpt/vision/CVideoFileWriter.h>
Public Member Functions | |
CVideoFileWriter () | |
Default constructor, which does not open any file. More... | |
virtual | ~CVideoFileWriter () |
Destructor. More... | |
bool | open (const std::string &out_file, double fps, const mrpt::utils::TImageSize &frameSize, const std::string &fourcc=std::string(""), bool isColor=true) |
Open a file for writing the video. More... | |
void | close () |
Finish the file writing and close the file output. More... | |
bool | isOpen () const |
Return true if already successfully open with open() and not closed yet. More... | |
const CVideoFileWriter & | operator<< (const mrpt::utils::CImage &img) const |
Write image to the video file. More... | |
bool | writeImage (const mrpt::utils::CImage &img) const |
Write image to the video file (method function, alternative to the operator <<). More... | |
Private Attributes | |
mrpt::utils::void_ptr_noncopy | m_video |
A pointer to CvVideoWriter. More... | |
mrpt::utils::TImageSize | m_img_size |
A copy of the video size. More... | |
CVideoFileWriter::CVideoFileWriter | ( | ) |
Default constructor, which does not open any file.
Definition at line 30 of file CVideoFileWriter.cpp.
|
virtual |
Destructor.
Definition at line 34 of file CVideoFileWriter.cpp.
References close().
void CVideoFileWriter::close | ( | ) |
Finish the file writing and close the file output.
Definition at line 90 of file CVideoFileWriter.cpp.
References M_WRITER, and M_WRITER_PTR.
Referenced by open(), and ~CVideoFileWriter().
bool CVideoFileWriter::isOpen | ( | ) | const |
Return true if already successfully open with open() and not closed yet.
Definition at line 102 of file CVideoFileWriter.cpp.
References M_WRITER.
bool CVideoFileWriter::open | ( | const std::string & | out_file, |
double | fps, | ||
const mrpt::utils::TImageSize & | frameSize, | ||
const std::string & | fourcc = std::string("") , |
||
bool | isColor = true |
||
) |
Open a file for writing the video.
out_file | The video file to create for output. |
fourcc | The video codec, as a string. See notes below. fps The video FPS (frames per seconds). |
frameSize | The size of the video frames. All subsequent images must be of this size. |
isColor | Set to false to create a grayscale video. |
Definition at line 38 of file CVideoFileWriter.cpp.
References close(), mrpt::utils::non_copiable_ptr_basic< T >::get(), m_img_size, m_video, mrpt::utils::TPixelCoord::x, and mrpt::utils::TPixelCoord::y.
const CVideoFileWriter & CVideoFileWriter::operator<< | ( | const mrpt::utils::CImage & | img | ) | const |
Write image to the video file.
std::exception | On any error |
Definition at line 114 of file CVideoFileWriter.cpp.
References mrpt::format(), mrpt::utils::non_copiable_ptr_basic< T >::get(), m_img_size, m_video, M_WRITER, THROW_EXCEPTION, mrpt::utils::TPixelCoord::x, and mrpt::utils::TPixelCoord::y.
bool CVideoFileWriter::writeImage | ( | const mrpt::utils::CImage & | img | ) | const |
Write image to the video file (method function, alternative to the operator <<).
Definition at line 137 of file CVideoFileWriter.cpp.
References mrpt::format(), mrpt::utils::non_copiable_ptr_basic< T >::get(), m_img_size, m_video, M_WRITER, mrpt::utils::TPixelCoord::x, and mrpt::utils::TPixelCoord::y.
|
private |
A copy of the video size.
Definition at line 49 of file CVideoFileWriter.h.
Referenced by open(), operator<<(), and writeImage().
|
private |
A pointer to CvVideoWriter.
Definition at line 47 of file CVideoFileWriter.h.
Referenced by open(), operator<<(), and writeImage().
Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019 |