MRPT  2.0.4
List of all members | Classes | Public Member Functions | Private Attributes
mrpt::vision::CVideoFileWriter Class Reference

Detailed Description

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:

vid.open("test.avi",15,TPixelCoord(320,200), "MJPG");
CImage img(320,200);
vid << img;
vid.close;

There are two methods for adding frames to the video:

Note
This class is a wrapper for OpenCV's CvVideoWriter.

Definition at line 41 of file CVideoFileWriter.h.

#include <mrpt/vision/CVideoFileWriter.h>

Classes

struct  Impl
 

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::img::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 CVideoFileWriteroperator<< (const mrpt::img::CImage &img)
 Write image to the video file. More...
 
bool writeImage (const mrpt::img::CImage &img)
 Write image to the video file (method function, alternative to the operator <<). More...
 

Private Attributes

mrpt::pimpl< Implm_video
 
mrpt::img::TImageSize m_img_size {0, 0}
 A copy of the video size. More...
 

Constructor & Destructor Documentation

◆ CVideoFileWriter()

CVideoFileWriter::CVideoFileWriter ( )

Default constructor, which does not open any file.

Definition at line 33 of file CVideoFileWriter.cpp.

◆ ~CVideoFileWriter()

CVideoFileWriter::~CVideoFileWriter ( )
virtual

Destructor.

Definition at line 38 of file CVideoFileWriter.cpp.

References close().

Here is the call graph for this function:

Member Function Documentation

◆ close()

void CVideoFileWriter::close ( )

Finish the file writing and close the file output.

Definition at line 79 of file CVideoFileWriter.cpp.

References m_video.

Referenced by open(), and ~CVideoFileWriter().

Here is the caller graph for this function:

◆ isOpen()

bool CVideoFileWriter::isOpen ( ) const

Return true if already successfully open with open() and not closed yet.

Definition at line 89 of file CVideoFileWriter.cpp.

References m_video.

◆ open()

bool CVideoFileWriter::open ( const std::string &  out_file,
double  fps,
const mrpt::img::TImageSize frameSize,
const std::string &  fourcc = std::string(""),
bool  isColor = true 
)

Open a file for writing the video.

Parameters
out_fileThe video file to create for output.
fourccThe video codec, as a string. See notes below. fps The video FPS (frames per seconds).
frameSizeThe size of the video frames. All subsequent images must be of this size.
isColorSet to false to create a grayscale video.
Note
If fourcc is left as an empty string a default codec will be seleceted (e.g. "IYUV").
Other valid values for "fourcc" are: "PIM1" -> MPEG1, "MJPG" -> Motion JPEG, "XVID", etc...
Returns
false on any error, true on success.

Definition at line 40 of file CVideoFileWriter.cpp.

References close(), m_img_size, m_video, mrpt::img::TPixelCoord::x, and mrpt::img::TPixelCoord::y.

Here is the call graph for this function:

◆ operator<<()

const CVideoFileWriter & CVideoFileWriter::operator<< ( const mrpt::img::CImage img)

Write image to the video file.

Exceptions
std::exceptionOn any error

Definition at line 98 of file CVideoFileWriter.cpp.

References writeImage().

Here is the call graph for this function:

◆ writeImage()

bool CVideoFileWriter::writeImage ( const mrpt::img::CImage img)

Write image to the video file (method function, alternative to the operator <<).

Returns
false on any error

Definition at line 105 of file CVideoFileWriter.cpp.

References mrpt::img::CImage::asCvMatRef(), mrpt::format(), mrpt::img::CImage::getHeight(), mrpt::img::CImage::getWidth(), m_img_size, m_video, mrpt::img::TPixelCoord::x, and mrpt::img::TPixelCoord::y.

Referenced by operator<<().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_img_size

mrpt::img::TImageSize mrpt::vision::CVideoFileWriter::m_img_size {0, 0}
private

A copy of the video size.

Definition at line 49 of file CVideoFileWriter.h.

Referenced by open(), and writeImage().

◆ m_video

mrpt::pimpl<Impl> mrpt::vision::CVideoFileWriter::m_video
private

Definition at line 45 of file CVideoFileWriter.h.

Referenced by close(), isOpen(), open(), and writeImage().




Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020