MRPT  1.9.9
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-2019, 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  */
40 {
41  private:
42  /** The internal ffmpeg state */
43  struct Impl;
45  /** The open URL */
48 
49  public:
50  /** Default constructor, does not open any video source at startup */
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
bool retrieveFrame(mrpt::img::CImage &out_img)
Get the next frame from the video stream.
spimpl::impl_ptr< T > pimpl
Definition: pimpl.h:15
Contains classes for various device interfaces.
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:4116
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:147



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 45d659fbb Tue Dec 10 18:21:14 2019 +0100 at mar dic 10 18:30:09 CET 2019