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



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at mié abr 15 19:30:12 CEST 2020