Main MRPT website > C++ reference for MRPT 1.5.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-2017, 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/utils/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 in any of a given of compatible formats.
21  *
22  * The output file is open when calling "open", and it's closed at destructor or after calling "close".
23  *
24  * Example of usage:
25  *
26  * \code
27  * CVideoFileWriter vid;
28  * vid.open("test.avi",15,TPixelCoord(320,200), "MJPG");
29  * CImage img(320,200);
30  * vid << img;
31  * vid.close;
32  * \endcode
33  *
34  * There are two methods for adding frames to the video:
35  * - The operator <<: Which will raise an exception on any error.
36  * - The method writeImage, which does not raise any exception on errors.
37  *
38  * \note This class is a wrapper for OpenCV's CvVideoWriter.
39  * \ingroup mrpt_vision_grp
40  */
42  {
43  private:
44  mrpt::utils::void_ptr_noncopy m_video; //!< A pointer to CvVideoWriter
45  mrpt::utils::TImageSize m_img_size; //!< A copy of the video size
46 
47  public:
48  CVideoFileWriter(); //!< Default constructor, which does not open any file
49  virtual ~CVideoFileWriter(); //!< Destructor
50 
51  /** Open a file for writing the video.
52  * \param out_file The video file to create for output.
53  * \param fourcc The video codec, as a string. See notes below.
54  * \paam fps The video FPS (frames per seconds).
55  * \param frameSize The size of the video frames. All subsequent images must be of this size.
56  * \param isColor Set to false to create a grayscale video.
57  *
58  * \note If fourcc is left as an empty string a default codec will be seleceted (e.g. "IYUV").
59  * \note Other valid values for "fourcc" are: "PIM1" -> MPEG1, "MJPG" -> Motion JPEG, "XVID", etc...
60  *
61  * \return false on any error, true on success.
62  */
63  bool open(
64  const std::string &out_file,
65  double fps,
66  const mrpt::utils::TImageSize & frameSize,
67  const std::string &fourcc = std::string(""),
68  bool isColor = true );
69 
70  /** Finish the file writing and close the file output
71  */
72  void close();
73 
74  /** Return true if already successfully open with open() and not closed yet. */
75  bool isOpen() const;
76 
77  /** Write image to the video file.
78  * \exception std::exception On any error
79  */
81 
82  /** Write image to the video file (method function, alternative to the operator <<).
83  * \return false on any error
84  */
85  bool writeImage(const mrpt::utils::CImage& img) const;
86 
87 
88  }; // end of class
89 
90  } // end of namespace
91 } // end of namespace
92 
93 #endif
mrpt::utils::TImageSize m_img_size
A copy of the video size.
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:101
A pair (x,y) of pixel coordinates (integer resolution).
Definition: TPixelCoord.h:37
mrpt::utils::void_ptr_noncopy m_video
A pointer to CvVideoWriter.
GLint GLvoid * img
Definition: glext.h:3645
GLsizei const GLchar ** string
Definition: glext.h:3919
std::ostream & operator<<(std::ostream &out, MD5 md5)
Definition: md5.cpp:419
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...



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020