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



Page generated by Doxygen 1.9.1 for MRPT 1.9.9 Git: 814d80880 Fri Aug 24 01:51:28 2018 +0200 at mar 26 may 2026 12:30:59 CEST