Main MRPT website
>
C++ reference
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
mrpt
vision
CVideoFileWriter.h
Go to the documentation of this file.
1
/* +---------------------------------------------------------------------------+
2
| The Mobile Robot Programming Toolkit (MRPT) C++ library |
3
| |
4
| http://www.mrpt.org/ |
5
| |
6
| Copyright (C) 2005-2012 University of Malaga |
7
| |
8
| This software was written by the Machine Perception and Intelligent |
9
| Robotics Lab, University of Malaga (Spain). |
10
| Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11
| |
12
| This file is part of the MRPT project. |
13
| |
14
| MRPT is free software: you can redistribute it and/or modify |
15
| it under the terms of the GNU General Public License as published by |
16
| the Free Software Foundation, either version 3 of the License, or |
17
| (at your option) any later version. |
18
| |
19
| MRPT is distributed in the hope that it will be useful, |
20
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
21
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22
| GNU General Public License for more details. |
23
| |
24
| You should have received a copy of the GNU General Public License |
25
| along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26
| |
27
+---------------------------------------------------------------------------+ */
28
#ifndef CVideoFileWritter_H
29
#define CVideoFileWritter_H
30
31
#include <
mrpt/vision/utils.h
>
32
#include <
mrpt/utils/CImage.h
>
33
#include <
mrpt/utils/safe_pointers.h
>
34
35
namespace
mrpt
36
{
37
namespace
vision
38
{
39
/** An output stream which takes a sequence of images and writes a video file in any of a given of compatible formats.
40
*
41
* The output file is open when calling "open", and it's closed at destructor or after calling "close".
42
*
43
* Example of usage:
44
*
45
* \code
46
* CVideoFileWriter vid;
47
* vid.open("test.avi","MJPG",15,TPixelCoord(320,200));
48
* CImage img(320,200);
49
* vid << img;
50
* vid.close;
51
* \endcode
52
*
53
* There are two methods for adding frames to the video:
54
* - The operator <<: Which will raise an exception on any error.
55
* - The method writeImage, which does not raise any exception on errors.
56
*
57
* \note This class is a wrapper for OpenCV's CvVideoWriter.
58
* \ingroup mrpt_vision_grp
59
*/
60
class
VISION_IMPEXP
CVideoFileWriter
61
{
62
private
:
63
mrpt::utils::void_ptr_noncopy
m_video
;
//!< A pointer to CvVideoWriter
64
mrpt::vision::TImageSize
m_img_size
;
//!< A copy of the video size
65
66
public
:
67
CVideoFileWriter
();
//!< Default constructor, which does not open any file
68
virtual
~
CVideoFileWriter
();
//!< Destructor
69
70
/** Open a file for writing the video.
71
* \param out_file The video file to create for output.
72
* \param fourcc The video codec, as a string. See notes below.
73
* \paam fps The video FPS (frames per seconds).
74
* \param frameSize The size of the video frames. All subsequent images must be of this size.
75
* \param isColor Set to false to create a grayscale video.
76
*
77
* \note If fourcc is left as an empty string a default codec will be seleceted (e.g. "IYUV").
78
* \note Other valid values for "fourcc" are: "PIM1" -> MPEG1, "MJPG" -> Motion JPEG, "XVID", etc...
79
*
80
* \return false on any error, true on success.
81
*/
82
bool
open(
83
const
std::string &out_file,
84
double
fps,
85
const
mrpt::vision::TImageSize
& frameSize,
86
const
std::string &fourcc = std::string(
""
),
87
bool
isColor =
true
);
88
89
/** Finish the file writing and close the file output
90
*/
91
void
close();
92
93
/** Return true if already successfully open with open() and not closed yet. */
94
bool
isOpen()
const
;
95
96
/** Write image to the video file.
97
* \exception std::exception On any error
98
*/
99
const
CVideoFileWriter
&
operator <<
(
const
mrpt::utils::CImage
& img)
const
;
100
101
/** Write image to the video file (method function, alternative to the operator <<).
102
* \return false on any error
103
*/
104
bool
writeImage(
const
mrpt::utils::CImage
& img)
const
;
105
106
107
};
// end of class
108
109
}
// end of namespace
110
}
// end of namespace
111
112
#endif
Page generated by
Doxygen 1.8.3
for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013