Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
vpVideoWriter.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * See the file LICENSE.txt at the root directory of this source
10 * distribution for additional information about the GNU GPL.
11 *
12 * For using ViSP with software that can not be combined with the GNU
13 * GPL, please contact Inria about acquiring a ViSP Professional
14 * Edition License.
15 *
16 * See https://visp.inria.fr for more information.
17 *
18 * This software was developed at:
19 * Inria Rennes - Bretagne Atlantique
20 * Campus Universitaire de Beaulieu
21 * 35042 Rennes Cedex
22 * France
23 *
24 * If you have questions regarding the use of this file, please contact
25 * Inria at visp@inria.fr
26 *
27 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29 *
30 * Description:
31 * Write videos and sequences of images.
32 */
33
39#ifndef _vpVideoWriter_h_
40#define _vpVideoWriter_h_
41
42#include <string>
43
44#include <visp3/io/vpImageIo.h>
45
46#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_VIDEOIO) && defined(HAVE_OPENCV_HIGHGUI)
47#include <opencv2/videoio/videoio.hpp>
48#include <opencv2/highgui/highgui.hpp>
49#endif
50
153class VISP_EXPORT vpVideoWriter
154{
155private:
156#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_VIDEOIO)
157 cv::VideoWriter m_writer;
158 int m_fourcc;
159 double m_framerate;
160#endif
162 typedef enum
163 {
164 FORMAT_PGM,
165 FORMAT_PPM,
166 FORMAT_JPEG,
167 FORMAT_PNG,
168 FORMAT_AVI,
169 FORMAT_MPEG,
170 FORMAT_MPEG4,
171 FORMAT_MOV,
172 FORMAT_UNKNOWN
173 } vpVideoFormatType;
174
176 vpVideoFormatType m_formatType;
177
179 std::string m_videoName;
180 std::string m_frameName;
181
183 bool m_initFileName;
184
186 bool m_isOpen;
187
189 int m_frameCount;
190
192 int m_firstFrame;
193
195 unsigned int m_width;
196 unsigned int m_height;
197
198 int m_frameStep;
199
200public:
202 virtual ~vpVideoWriter();
203
204 void close();
205
211 inline unsigned int getCurrentFrameIndex() const { return m_frameCount; }
215 inline std::string getFrameName() const { return m_frameName; }
216
217 void open(vpImage<vpRGBa> &I);
218 void open(vpImage<unsigned char> &I);
224 inline void resetFrameCounter() { m_frameCount = m_firstFrame; }
225
226 void saveFrame(vpImage<vpRGBa> &I);
227 void saveFrame(vpImage<unsigned char> &I);
228
229#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_VIDEOIO)
230 inline void setCodec(const int fourcc_codec) { m_fourcc = fourcc_codec; }
231#endif
232
233 void setFileName(const std::string &filename);
234 void setFirstFrameIndex(int first_frame);
235
245#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_VIDEOIO)
246 inline void setFramerate(const double framerate) { m_framerate = framerate; }
247#else
248 inline void setFramerate(const double dummy) { (void)dummy; }
249#endif
254 inline void setFrameStep(const int frame_step) { m_frameStep = frame_step; }
255
256private:
257 vpVideoFormatType getFormat(const std::string &filename);
258 static std::string getExtension(const std::string &filename);
259};
260
261#endif
Definition of the vpImage class member functions.
Definition vpImage.h:135
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()