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::vision
17 {
18 /** An output stream which takes a sequence of images and writes a video file
19  * in any of a given of compatible formats.
20  *
21  * The output file is open when calling "open", and it's closed at destructor
22  * 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  /** A pointer to CvVideoWriter */
46  /** A copy of the video size */
48 
49  public:
50  /** Default constructor, which does not open any file */
52  /** Destructor */
53  virtual ~CVideoFileWriter();
54 
55  /** Open a file for writing the video.
56  * \param out_file The video file to create for output.
57  * \param fourcc The video codec, as a string. See notes below.
58  * \paam fps The video FPS (frames per seconds).
59  * \param frameSize The size of the video frames. All subsequent images
60  * must be of this size.
61  * \param isColor Set to false to create a grayscale video.
62  *
63  * \note If fourcc is left as an empty string a default codec will be
64  * seleceted (e.g. "IYUV").
65  * \note Other valid values for "fourcc" are: "PIM1" -> MPEG1, "MJPG" ->
66  * Motion JPEG, "XVID", etc...
67  *
68  * \return false on any error, true on success.
69  */
70  bool open(
71  const std::string& out_file, double fps,
72  const mrpt::img::TImageSize& frameSize,
73  const std::string& fourcc = std::string(""), bool isColor = true);
74 
75  /** Finish the file writing and close the file output
76  */
77  void close();
78 
79  /** Return true if already successfully open with open() and not closed yet.
80  */
81  bool isOpen() const;
82 
83  /** Write image to the video file.
84  * \exception std::exception On any error
85  */
86  const CVideoFileWriter& operator<<(const mrpt::img::CImage& img) const;
87 
88  /** Write image to the video file (method function, alternative to the
89  * operator <<).
90  * \return false on any error
91  */
92  bool writeImage(const mrpt::img::CImage& img) const;
93 
94 }; // end of class
95 
96 }
97 #endif
98 
99 
const CVideoFileWriter & operator<<(const mrpt::img::CImage &img) const
Write image to the video file.
void close()
Finish the file writing and close the file output.
mrpt::void_ptr_noncopy m_video
A pointer to CvVideoWriter.
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.
mrpt::img::TImageSize m_img_size
A copy of the video size.
bool isOpen() const
Return true if already successfully open with open() and not closed yet.
GLint GLvoid * img
Definition: glext.h:3763
Classes for computer vision, detectors, features, etc.
Definition: CCamModel.h:18
GLsizei const GLchar ** string
Definition: glext.h:4101
CVideoFileWriter()
Default constructor, which does not open any file.
virtual ~CVideoFileWriter()
Destructor.
An output stream which takes a sequence of images and writes a video file in any of a given of compat...
TPixelCoord TImageSize
A type for image sizes.
Definition: TPixelCoord.h:51
bool writeImage(const mrpt::img::CImage &img) const
Write image to the video file (method function, alternative to the operator <<).
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020