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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019