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-2018, 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/img/CImage.h>
14 #include <mrpt/core/pimpl.h>
15 
16 /*---------------------------------------------------------------
17  Class
18  ---------------------------------------------------------------*/
19 namespace mrpt
20 {
21 namespace hwdrivers
22 {
23 /** A generic class which process a video file or other kind of input stream
24  * (http, rtsp) and allows the extraction of images frame by frame.
25  * Video sources can be open with "openURL", which can manage both video files
26  * and "rtsp://" sources (IP cameras).
27  *
28  * Frames are retrieved by calling CFFMPEG_InputStream::retrieveFrame
29  *
30  * For an example of usage, see the file "samples/grab_camera_ffmpeg"
31  *
32  * \note This class is an easy to use C++ wrapper for ffmpeg libraries
33  * (libavcodec). In Unix systems these libraries must be installed in the system
34  * as explained in <a
35  * href="http://www.mrpt.org/Building_and_Installing_Instructions" > MRPT's
36  * wiki</a>. In Win32, a precompiled version for Visual Studio must be also
37  * downloaded as explained in <a
38  * href="http://www.mrpt.org/Building_and_Installing_Instructions" >the
39  * wiki</a>.
40  * \ingroup mrpt_hwdrivers_grp
41  */
43 {
44  private:
45  /** The internal ffmpeg state */
46  struct Impl;
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::img::CImage& out_img);
95 };
96 }
97 }
98 
99 #endif
bool retrieveFrame(mrpt::img::CImage &out_img)
Get the next frame from the video stream.
spimpl::impl_ptr< T > pimpl
Definition: pimpl.h:15
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.
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.
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019