MRPT
2.0.4
mrpt
hwdrivers
CFFMPEG_InputStream.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-2020, 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
10
#pragma once
11
12
#include <
mrpt/core/pimpl.h
>
13
#include <
mrpt/img/CImage.h
>
14
15
/*---------------------------------------------------------------
16
Class
17
---------------------------------------------------------------*/
18
namespace
mrpt::hwdrivers
19
{
20
/** A generic class which process a video file or other kind of input stream
21
* (http, rtsp) and allows the extraction of images frame by frame.
22
* Video sources can be open with "openURL", which can manage both video files
23
* and "rtsp://" sources (IP cameras).
24
*
25
* Frames are retrieved by calling CFFMPEG_InputStream::retrieveFrame
26
*
27
* For an example of usage, see the file "samples/grab_camera_ffmpeg"
28
*
29
* \note This class is an easy to use C++ wrapper for ffmpeg libraries
30
* (libavcodec). In Unix systems these libraries must be installed in the system
31
* as explained in <a
32
* href="http://www.mrpt.org/Building_and_Installing_Instructions" > MRPT's
33
* wiki</a>. In Win32, a precompiled version for Visual Studio must be also
34
* downloaded as explained in <a
35
* href="http://www.mrpt.org/Building_and_Installing_Instructions" >the
36
* wiki</a>.
37
* \ingroup mrpt_hwdrivers_grp
38
*/
39
class
CFFMPEG_InputStream
40
{
41
private
:
42
/** The internal ffmpeg state */
43
struct
Impl
;
44
mrpt::pimpl<Impl>
m_impl
;
45
/** The open URL */
46
std::string
m_url
;
47
bool
m_grab_as_grayscale
;
48
49
public
:
50
/** Default constructor, does not open any video source at startup */
51
CFFMPEG_InputStream
();
52
/** Destructor */
53
virtual
~CFFMPEG_InputStream
();
54
55
/** Open a video file or a video stream (rtsp://)
56
* This can be used to open local video files (eg. "myVideo.avi",
57
* "c:\a.mpeg") and also IP cameras (e. "rtsp://a.b.c.d/live.sdp").
58
* However, note that there is currently no support for user/password in
59
* IP access.
60
* If verbose is set to true, more information about the video will be
61
* dumped to cout.
62
*
63
* \sa close, retrieveFrame
64
* \return false on any error (and error info dumped to cerr), true on
65
* success.
66
*/
67
bool
openURL
(
68
const
std::string&
url
,
bool
grab_as_grayscale =
false
,
69
bool
verbose
=
false
);
70
71
/** Return whether the video source was open correctly */
72
bool
isOpen
()
const
;
73
74
/** Close the video stream (this is called automatically at destruction).
75
* \sa openURL
76
*/
77
void
close
();
78
79
/** Get the frame-per-second (FPS) of the video source, or "-1" if the video
80
* is not open. */
81
double
getVideoFPS
()
const
;
82
83
/** Get the next frame from the video stream.
84
* Note that for remote streams (IP cameras) this method may block until
85
* enough information is read to generate a new frame.
86
* Images are returned as 8-bit depth grayscale if "grab_as_grayscale" is
87
* true.
88
* \return false on any error, true on success.
89
* \sa openURL, close, isOpen
90
*/
91
bool
retrieveFrame
(
mrpt::img::CImage
& out_img);
92
};
93
}
// namespace mrpt::hwdrivers
mrpt::hwdrivers::CFFMPEG_InputStream::retrieveFrame
bool retrieveFrame(mrpt::img::CImage &out_img)
Get the next frame from the video stream.
Definition:
CFFMPEG_InputStream.cpp:321
mrpt::pimpl
spimpl::impl_ptr< T > pimpl
Definition:
pimpl.h:15
verbose
params verbose
Definition:
chessboard_stereo_camera_calib_unittest.cpp:59
CImage.h
mrpt::hwdrivers
Contains classes for various device interfaces.
Definition:
C2DRangeFinderAbstract.h:19
mrpt::hwdrivers::CFFMPEG_InputStream::m_grab_as_grayscale
bool m_grab_as_grayscale
Definition:
CFFMPEG_InputStream.h:47
mrpt::hwdrivers::CFFMPEG_InputStream
A generic class which process a video file or other kind of input stream (http, rtsp) and allows the ...
Definition:
CFFMPEG_InputStream.h:39
mrpt::hwdrivers::CFFMPEG_InputStream::Impl
Definition:
CFFMPEG_InputStream.cpp:63
mrpt::hwdrivers::CFFMPEG_InputStream::isOpen
bool isOpen() const
Return whether the video source was open correctly.
Definition:
CFFMPEG_InputStream.cpp:103
mrpt::hwdrivers::CFFMPEG_InputStream::m_impl
mrpt::pimpl< Impl > m_impl
Definition:
CFFMPEG_InputStream.h:43
url
string url
Definition:
vision_stereo_rectify/test.cpp:23
mrpt::hwdrivers::CFFMPEG_InputStream::openURL
bool openURL(const std::string &url, bool grab_as_grayscale=false, bool verbose=false)
Open a video file or a video stream (rtsp://) This can be used to open local video files (eg...
Definition:
CFFMPEG_InputStream.cpp:116
mrpt::hwdrivers::CFFMPEG_InputStream::m_url
std::string m_url
The open URL.
Definition:
CFFMPEG_InputStream.h:46
mrpt::hwdrivers::CFFMPEG_InputStream::CFFMPEG_InputStream
CFFMPEG_InputStream()
Default constructor, does not open any video source at startup.
Definition:
CFFMPEG_InputStream.cpp:73
mrpt::hwdrivers::CFFMPEG_InputStream::close
void close()
Close the video stream (this is called automatically at destruction).
Definition:
CFFMPEG_InputStream.cpp:274
mrpt::hwdrivers::CFFMPEG_InputStream::~CFFMPEG_InputStream
virtual ~CFFMPEG_InputStream()
Destructor.
Definition:
CFFMPEG_InputStream.cpp:92
mrpt::hwdrivers::CFFMPEG_InputStream::getVideoFPS
double getVideoFPS() const
Get the frame-per-second (FPS) of the video source, or "-1" if the video is not open.
Definition:
CFFMPEG_InputStream.cpp:422
mrpt::img::CImage
A class for storing images as grayscale or RGB bitmaps.
Definition:
img/CImage.h:148
pimpl.h
Page generated by
Doxygen 1.8.14
for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020