Visual Servoing Platform version 3.5.0
vpVideoWriter.h
1/****************************************************************************
2 *
3 * ViSP, open source Visual Servoing Platform software.
4 * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5 *
6 * This software is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 * See the file LICENSE.txt at the root directory of this source
11 * distribution for additional information about the GNU GPL.
12 *
13 * For using ViSP with software that can not be combined with the GNU
14 * GPL, please contact Inria about acquiring a ViSP Professional
15 * Edition License.
16 *
17 * See http://visp.inria.fr for more information.
18 *
19 * This software was developed at:
20 * Inria Rennes - Bretagne Atlantique
21 * Campus Universitaire de Beaulieu
22 * 35042 Rennes Cedex
23 * France
24 *
25 * If you have questions regarding the use of this file, please contact
26 * Inria at visp@inria.fr
27 *
28 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30 *
31 * Description:
32 * Write videos and sequences of images.
33 *
34 * Authors:
35 * Nicolas Melchior
36 *
37 *****************************************************************************/
38
44#ifndef vpVideoWriter_H
45#define vpVideoWriter_H
46
47#include <string>
48
49#include <visp3/io/vpImageIo.h>
50
51#if VISP_HAVE_OPENCV_VERSION >= 0x020200
52#include <opencv2/highgui/highgui.hpp>
53#elif VISP_HAVE_OPENCV_VERSION >= 0x020000
54#include <opencv/highgui.h>
55#endif
56
159class VISP_EXPORT vpVideoWriter
160{
161private:
162#if VISP_HAVE_OPENCV_VERSION >= 0x020100
163 cv::VideoWriter m_writer;
164 int m_fourcc;
165 double m_framerate;
166#endif
168 typedef enum {
169 FORMAT_PGM,
170 FORMAT_PPM,
171 FORMAT_JPEG,
172 FORMAT_PNG,
173 FORMAT_AVI,
174 FORMAT_MPEG,
175 FORMAT_MPEG4,
176 FORMAT_MOV,
177 FORMAT_UNKNOWN
178 } vpVideoFormatType;
179
181 vpVideoFormatType m_formatType;
182
184 std::string m_videoName;
185 std::string m_frameName;
186
188 bool m_initFileName;
189
191 bool m_isOpen;
192
194 int m_frameCount;
195
197 int m_firstFrame;
198
200 unsigned int m_width;
201 unsigned int m_height;
202
203 int m_frameStep;
204
205public:
207 virtual ~vpVideoWriter();
208
209 void close();
210
216 inline unsigned int getCurrentFrameIndex() const { return m_frameCount; }
220 inline std::string getFrameName() const { return m_frameName; }
221
222 void open(vpImage<vpRGBa> &I);
223 void open(vpImage<unsigned char> &I);
229 inline void resetFrameCounter() { m_frameCount = m_firstFrame; }
230
231 void saveFrame(vpImage<vpRGBa> &I);
232 void saveFrame(vpImage<unsigned char> &I);
233
234#if VISP_HAVE_OPENCV_VERSION >= 0x020100
235 inline void setCodec(const int fourcc_codec) { m_fourcc = fourcc_codec; }
236#endif
237
238 void setFileName(const std::string &filename);
239 void setFirstFrameIndex(int first_frame);
240
250#if VISP_HAVE_OPENCV_VERSION >= 0x020100
251 inline void setFramerate(const double framerate) { m_framerate = framerate; }
252#else
253 inline void setFramerate(const double dummy) { (void)dummy; }
254#endif
259 inline void setFrameStep(const int frame_step) { m_frameStep = frame_step; }
260
261private:
262 vpVideoFormatType getFormat(const std::string &filename);
263 static std::string getExtension(const std::string &filename);
264};
265
266#endif
Class that enables to write easily a video file or a sequence of images.
void setFrameStep(const int frame_step)
void setFramerate(const double framerate)
void setCodec(const int fourcc_codec)
std::string getFrameName() const
unsigned int getCurrentFrameIndex() const
void resetFrameCounter()