Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpVideoWriter.h
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2024 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
38
39
#ifndef VP_VIDEO_WRITER_H
40
#define VP_VIDEO_WRITER_H
41
42
#include <string>
43
44
#include <visp3/io/vpImageIo.h>
45
46
#if defined(VISP_HAVE_OPENCV) && \
47
(((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)) || \
48
((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO)))
49
50
#if (VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)
51
#include <opencv2/highgui/highgui.hpp>
// for cv::VideoCapture
52
#elif (VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO)
53
#include <opencv2/videoio/videoio.hpp>
54
#endif
55
56
#endif
57
58
BEGIN_VISP_NAMESPACE
59
169
170
class
VISP_EXPORT
vpVideoWriter
171
{
172
private
:
173
#if defined(VISP_HAVE_OPENCV) && \
174
(((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)) || \
175
((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO)))
176
cv::VideoWriter m_writer;
177
int
m_fourcc;
178
double
m_framerate;
179
#endif
181
typedef
enum
182
{
183
FORMAT_PGM,
184
FORMAT_PPM,
185
FORMAT_JPEG,
186
FORMAT_PNG,
187
FORMAT_AVI,
188
FORMAT_MPEG,
189
FORMAT_MPEG4,
190
FORMAT_MOV,
191
FORMAT_UNKNOWN
192
} vpVideoFormatType;
193
195
vpVideoFormatType m_formatType;
196
198
std::string m_videoName;
199
std::string m_frameName;
200
202
bool
m_initFileName;
203
205
bool
m_isOpen;
206
208
int
m_frameCount;
209
211
int
m_firstFrame;
212
214
unsigned
int
m_width;
215
unsigned
int
m_height;
216
217
int
m_frameStep;
218
219
public
:
220
vpVideoWriter
();
221
virtual
~vpVideoWriter
();
222
223
void
close
();
224
230
inline
unsigned
int
getCurrentFrameIndex
()
const
{
return
static_cast<
unsigned
int
>
(m_frameCount); }
234
inline
std::string
getFrameName
()
const
{
return
m_frameName; }
235
236
void
open(
vpImage<vpRGBa>
&I);
237
void
open(
vpImage<unsigned char>
&I);
243
inline
void
resetFrameCounter
() { m_frameCount = m_firstFrame; }
244
245
void
saveFrame(
vpImage<vpRGBa>
&I);
246
void
saveFrame(
vpImage<unsigned char>
&I);
247
248
#if defined(VISP_HAVE_OPENCV) && \
249
(((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)) || \
250
((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO)))
251
inline
void
setCodec
(
const
int
fourcc_codec) { m_fourcc = fourcc_codec; }
252
#endif
253
254
void
setFileName(
const
std::string &filename);
255
void
setFirstFrameIndex(
int
first_frame);
256
266
#if defined(VISP_HAVE_OPENCV) && \
267
(((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)) || \
268
((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO)))
269
inline
void
setFramerate
(
const
double
framerate) { m_framerate = framerate; }
270
#else
271
inline
void
setFramerate(
const
double
dummy) { (void)dummy; }
272
#endif
277
inline
void
setFrameStep
(
const
int
frame_step) { m_frameStep = frame_step; }
278
279
private
:
280
vpVideoFormatType getFormat(
const
std::string &filename);
281
static
std::string getExtension(
const
std::string &filename);
282
};
283
284
END_VISP_NAMESPACE
285
286
#endif
vpImage
Definition of the vpImage class member functions.
Definition
vpImage.h:131
vpVideoWriter::close
void close()
Definition
vpVideoWriter.cpp:270
vpVideoWriter::setFrameStep
void setFrameStep(const int frame_step)
Definition
vpVideoWriter.h:277
vpVideoWriter::setFramerate
void setFramerate(const double framerate)
Definition
vpVideoWriter.h:269
vpVideoWriter::vpVideoWriter
vpVideoWriter()
Definition
vpVideoWriter.cpp:51
vpVideoWriter::setCodec
void setCodec(const int fourcc_codec)
Definition
vpVideoWriter.h:251
vpVideoWriter::getFrameName
std::string getFrameName() const
Definition
vpVideoWriter.h:234
vpVideoWriter::getCurrentFrameIndex
unsigned int getCurrentFrameIndex() const
Definition
vpVideoWriter.h:230
vpVideoWriter::resetFrameCounter
void resetFrameCounter()
Definition
vpVideoWriter.h:243
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
io
include
visp3
io
vpVideoWriter.h
Generated by
1.17.0