Main MRPT website > C++ reference for MRPT 1.9.9
CFFMPEG_InputStream.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #ifndef CFFMPEG_InputStream_H
11 #define CFFMPEG_InputStream_H
12 
13 #include <mrpt/utils/utils_defs.h>
14 #include <mrpt/utils/CImage.h>
16 
17 /*---------------------------------------------------------------
18  Class
19  ---------------------------------------------------------------*/
20 namespace mrpt
21 {
22 namespace hwdrivers
23 {
24 /** A generic class which process a video file or other kind of input stream
25  * (http, rtsp) and allows the extraction of images frame by frame.
26  * Video sources can be open with "openURL", which can manage both video files
27  * and "rtsp://" sources (IP cameras).
28  *
29  * Frames are retrieved by calling CFFMPEG_InputStream::retrieveFrame
30  *
31  * For an example of usage, see the file "samples/grab_camera_ffmpeg"
32  *
33  * \note This class is an easy to use C++ wrapper for ffmpeg libraries
34  * (libavcodec). In Unix systems these libraries must be installed in the system
35  * as explained in <a
36  * href="http://www.mrpt.org/Building_and_Installing_Instructions" > MRPT's
37  * wiki</a>. In Win32, a precompiled version for Visual Studio must be also
38  * downloaded as explained in <a
39  * href="http://www.mrpt.org/Building_and_Installing_Instructions" >the
40  * wiki</a>.
41  * \ingroup mrpt_hwdrivers_grp
42  */
44 {
45  private:
46  /** The internal ffmpeg state */
48  /** The open URL */
51 
52  public:
53  /** Default constructor, does not open any video source at startup */
55  /** Destructor */
56  virtual ~CFFMPEG_InputStream();
57 
58  /** Open a video file or a video stream (rtsp://)
59  * This can be used to open local video files (eg. "myVideo.avi",
60  * "c:\a.mpeg") and also IP cameras (e. "rtsp://a.b.c.d/live.sdp").
61  * However, note that there is currently no support for user/password in
62  * IP access.
63  * If verbose is set to true, more information about the video will be
64  * dumped to cout.
65  *
66  * \sa close, retrieveFrame
67  * \return false on any error (and error info dumped to cerr), true on
68  * success.
69  */
70  bool openURL(
71  const std::string& url, bool grab_as_grayscale = false,
72  bool verbose = false);
73 
74  /** Return whether the video source was open correctly */
75  bool isOpen() const;
76 
77  /** Close the video stream (this is called automatically at destruction).
78  * \sa openURL
79  */
80  void close();
81 
82  /** Get the frame-per-second (FPS) of the video source, or "-1" if the video
83  * is not open. */
84  double getVideoFPS() const;
85 
86  /** Get the next frame from the video stream.
87  * Note that for remote streams (IP cameras) this method may block until
88  * enough information is read to generate a new frame.
89  * Images are returned as 8-bit depth grayscale if "grab_as_grayscale" is
90  * true.
91  * \return false on any error, true on success.
92  * \sa openURL, close, isOpen
93  */
94  bool retrieveFrame(mrpt::utils::CImage& out_img);
95 };
96 }
97 }
98 
99 #endif
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:118
bool retrieveFrame(mrpt::utils::CImage &out_img)
Get the next frame from the video stream.
A generic class which process a video file or other kind of input stream (http, rtsp) and allows the ...
bool isOpen() const
Return whether the video source was open correctly.
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...
GLsizei const GLchar ** string
Definition: glext.h:4101
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::utils::void_ptr_noncopy m_state
The internal ffmpeg state.
CFFMPEG_InputStream()
Default constructor, does not open any video source at startup.
void close()
Close the video stream (this is called automatically at destruction).
double getVideoFPS() const
Get the frame-per-second (FPS) of the video source, or "-1" if the video is not open.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019