15 #include <mrpt/otherlibs/do_opencv_includes.h> 17 #define M_WRITER (const_cast<CvVideoWriter*>( static_cast<const CvVideoWriter*>(m_video.get())) ) 18 #define M_WRITER_PTR (reinterpret_cast<CvVideoWriter**>(m_video.getPtrToPtr())) 58 #if MRPT_OPENCV_VERSION_NUM<=0x100 61 #ifdef MRPT_OS_WINDOWS 62 cc = CV_FOURCC_DEFAULT;
64 cc = CV_FOURCC_DEFAULT;
71 cc = CV_FOURCC( fourcc[0],fourcc[1],fourcc[2],fourcc[3] );
75 std::cerr <<
"[CVideoFileWriter::open] fourcc string must be four character length or empty for default." << std::endl;
79 m_video = cvCreateVideoWriter(out_file.c_str(),cc,fps,cvSize(frameSize.
x,frameSize.
y),isColor ? 1:0);
85 std::cerr <<
"[CVideoFileWriter::open] ERROR: MRPT was compiled without OpenCV support " << std::endl;
128 if (! cvWriteFrame(
M_WRITER,
img.getAs<IplImage>() ) )
144 std::cout <<
format(
"[CVideoFileWriter::writeImage] Error: video frame size is %ix%i but image is %ux%u",
m_img_size.
x,
m_img_size.
y,(
unsigned)
img.getWidth(),(unsigned)
img.getHeight() ) << std::endl;
149 return 0!= cvWriteFrame(
M_WRITER,
img.getAs<IplImage>() );
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
mrpt::utils::TImageSize m_img_size
A copy of the video size.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
A class for storing images as grayscale or RGB bitmaps.
void close()
Finish the file writing and close the file output.
#define THROW_EXCEPTION(msg)
A pair (x,y) of pixel coordinates (integer resolution).
mrpt::utils::void_ptr_noncopy m_video
A pointer to CvVideoWriter.
bool isOpen() const
Return true if already successfully open with open() and not closed yet.
bool writeImage(const mrpt::utils::CImage &img) const
Write image to the video file (method function, alternative to the operator <<).
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Classes for computer vision, detectors, features, etc.
GLsizei const GLchar ** string
CVideoFileWriter()
Default constructor, which does not open any file.
virtual ~CVideoFileWriter()
Destructor.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
An output stream which takes a sequence of images and writes a video file in any of a given of compat...
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.
const CVideoFileWriter & operator<<(const mrpt::utils::CImage &img) const
Write image to the video file.