Main MRPT website > C++ reference for MRPT 1.9.9
CVideoFileWriter.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef CVideoFileWriter_H
10 #define CVideoFileWriter_H
11 
12 #include <mrpt/vision/utils.h>
13 #include <mrpt/img/CImage.h>
15 
16 namespace mrpt
17 {
18 namespace vision
19 {
20 /** An output stream which takes a sequence of images and writes a video file
21  * in any of a given of compatible formats.
22  *
23  * The output file is open when calling "open", and it's closed at destructor
24  * or after calling "close".
25  *
26  * Example of usage:
27  *
28  * \code
29  * CVideoFileWriter vid;
30  * vid.open("test.avi",15,TPixelCoord(320,200), "MJPG");
31  * CImage img(320,200);
32  * vid << img;
33  * vid.close;
34  * \endcode
35  *
36  * There are two methods for adding frames to the video:
37  * - The operator <<: Which will raise an exception on any error.
38  * - The method writeImage, which does not raise any exception on errors.
39  *
40  * \note This class is a wrapper for OpenCV's CvVideoWriter.
41  * \ingroup mrpt_vision_grp
42  */
44 {
45  private:
46  /** A pointer to CvVideoWriter */
48  /** A copy of the video size */
50 
51  public:
52  /** Default constructor, which does not open any file */
54  /** Destructor */
55  virtual ~CVideoFileWriter();
56 
57  /** Open a file for writing the video.
58  * \param out_file The video file to create for output.
59  * \param fourcc The video codec, as a string. See notes below.
60  * \paam fps The video FPS (frames per seconds).
61  * \param frameSize The size of the video frames. All subsequent images
62  * must be of this size.
63  * \param isColor Set to false to create a grayscale video.
64  *
65  * \note If fourcc is left as an empty string a default codec will be
66  * seleceted (e.g. "IYUV").
67  * \note Other valid values for "fourcc" are: "PIM1" -> MPEG1, "MJPG" ->
68  * Motion JPEG, "XVID", etc...
69  *
70  * \return false on any error, true on success.
71  */
72  bool open(
73  const std::string& out_file, double fps,
74  const mrpt::img::TImageSize& frameSize,
75  const std::string& fourcc = std::string(""), bool isColor = true);
76 
77  /** Finish the file writing and close the file output
78  */
79  void close();
80 
81  /** Return true if already successfully open with open() and not closed yet.
82  */
83  bool isOpen() const;
84 
85  /** Write image to the video file.
86  * \exception std::exception On any error
87  */
88  const CVideoFileWriter& operator<<(const mrpt::img::CImage& img) const;
89 
90  /** Write image to the video file (method function, alternative to the
91  * operator <<).
92  * \return false on any error
93  */
94  bool writeImage(const mrpt::img::CImage& img) const;
95 
96 }; // end of class
97 
98 } // end of namespace
99 } // end of namespace
100 
101 #endif
mrpt::vision::CVideoFileWriter::~CVideoFileWriter
virtual ~CVideoFileWriter()
Destructor.
Definition: CVideoFileWriter.cpp:34
mrpt::vision::CVideoFileWriter::writeImage
bool writeImage(const mrpt::img::CImage &img) const
Write image to the video file (method function, alternative to the operator <<).
Definition: CVideoFileWriter.cpp:137
mrpt::vision::CVideoFileWriter::isOpen
bool isOpen() const
Return true if already successfully open with open() and not closed yet.
Definition: CVideoFileWriter.cpp:102
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::vision::CVideoFileWriter::CVideoFileWriter
CVideoFileWriter()
Default constructor, which does not open any file.
Definition: CVideoFileWriter.cpp:30
mrpt::vision::CVideoFileWriter::m_video
mrpt::void_ptr_noncopy m_video
A pointer to CvVideoWriter.
Definition: CVideoFileWriter.h:47
mrpt::vision::CVideoFileWriter
An output stream which takes a sequence of images and writes a video file in any of a given of compat...
Definition: CVideoFileWriter.h:43
mrpt::vision::CVideoFileWriter::close
void close()
Finish the file writing and close the file output.
Definition: CVideoFileWriter.cpp:90
mrpt::vision::CVideoFileWriter::operator<<
const CVideoFileWriter & operator<<(const mrpt::img::CImage &img) const
Write image to the video file.
Definition: CVideoFileWriter.cpp:114
mrpt::vision::CVideoFileWriter::m_img_size
mrpt::img::TImageSize m_img_size
A copy of the video size.
Definition: CVideoFileWriter.h:49
mrpt::img::CImage
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130
safe_pointers.h
img
GLint GLvoid * img
Definition: glext.h:3763
string
GLsizei const GLchar ** string
Definition: glext.h:4101
CImage.h
mrpt::img::TImageSize
TPixelCoord TImageSize
A type for image sizes.
Definition: TPixelCoord.h:53
mrpt::vision::CVideoFileWriter::open
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.
Definition: CVideoFileWriter.cpp:38
mrpt::non_copiable_ptr_basic< void >
utils.h



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST