15 #include <mrpt/otherlibs/do_opencv_includes.h>
18 (const_cast<CvVideoWriter*>( \
19 static_cast<const CvVideoWriter*>(m_video.get())))
20 #define M_WRITER_PTR (reinterpret_cast<CvVideoWriter**>(m_video.getPtrToPtr()))
50 #if MRPT_OPENCV_VERSION_NUM <= 0x100
54 cc = CV_FOURCC_DEFAULT;
56 cc = CV_FOURCC_DEFAULT;
60 else if (fourcc.size() == 4)
62 cc = CV_FOURCC(fourcc[0], fourcc[1], fourcc[2], fourcc[3]);
66 std::cerr <<
"[CVideoFileWriter::open] fourcc string must be four "
67 "character length or empty for default."
73 out_file.c_str(), cc, fps, cvSize(frameSize.x, frameSize.y),
80 std::cerr <<
"[CVideoFileWriter::open] ERROR: MRPT was compiled without "
123 "Video frame size is %ix%i but image is %ux%u",
m_img_size.x,
125 (
unsigned)
img.getHeight()));
128 if (!cvWriteFrame(
M_WRITER,
img.getAs<IplImage>()))
145 "[CVideoFileWriter::writeImage] Error: video frame "
146 "size is %ix%i but image is %ux%u",
148 (
unsigned)
img.getHeight())
154 return 0 != cvWriteFrame(
M_WRITER,
img.getAs<IplImage>());
A class for storing images as grayscale or RGB bitmaps.
An output stream which takes a sequence of images and writes a video file in any of a given of compat...
bool writeImage(const mrpt::img::CImage &img) const
Write image to the video file (method function, alternative to the operator <<).
void close()
Finish the file writing and close the file output.
mrpt::void_ptr_noncopy m_video
A pointer to CvVideoWriter.
virtual ~CVideoFileWriter()
Destructor.
const CVideoFileWriter & operator<<(const mrpt::img::CImage &img) const
Write image to the video file.
CVideoFileWriter()
Default constructor, which does not open any file.
bool isOpen() const
Return true if already successfully open with open() and not closed yet.
mrpt::img::TImageSize m_img_size
A copy of the video size.
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.
#define THROW_EXCEPTION(msg)
GLsizei const GLchar ** string
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
TPixelCoord TImageSize
A type for image sizes.
Classes for computer vision, detectors, features, etc.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.