MRPT
2.0.4
|
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.
Video sources can be open with "openURL", which can manage both video files and "rtsp://" sources (IP cameras).
Frames are retrieved by calling CFFMPEG_InputStream::retrieveFrame
For an example of usage, see the file "samples/grab_camera_ffmpeg"
Definition at line 39 of file CFFMPEG_InputStream.h.
#include <mrpt/hwdrivers/CFFMPEG_InputStream.h>
Classes | |
struct | Impl |
Public Member Functions | |
CFFMPEG_InputStream () | |
Default constructor, does not open any video source at startup. More... | |
virtual | ~CFFMPEG_InputStream () |
Destructor. More... | |
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. More... | |
bool | isOpen () const |
Return whether the video source was open correctly. More... | |
void | close () |
Close the video stream (this is called automatically at destruction). More... | |
double | getVideoFPS () const |
Get the frame-per-second (FPS) of the video source, or "-1" if the video is not open. More... | |
bool | retrieveFrame (mrpt::img::CImage &out_img) |
Get the next frame from the video stream. More... | |
Private Attributes | |
mrpt::pimpl< Impl > | m_impl |
std::string | m_url |
The open URL. More... | |
bool | m_grab_as_grayscale |
CFFMPEG_InputStream::CFFMPEG_InputStream | ( | ) |
Default constructor, does not open any video source at startup.
Definition at line 73 of file CFFMPEG_InputStream.cpp.
|
virtual |
Destructor.
Definition at line 92 of file CFFMPEG_InputStream.cpp.
References close().
void CFFMPEG_InputStream::close | ( | ) |
Close the video stream (this is called automatically at destruction).
Definition at line 274 of file CFFMPEG_InputStream.cpp.
References isOpen(), and m_impl.
Referenced by openURL(), mrpt::hwdrivers::CRovio::thread_video(), and ~CFFMPEG_InputStream().
double CFFMPEG_InputStream::getVideoFPS | ( | ) | const |
Get the frame-per-second (FPS) of the video source, or "-1" if the video is not open.
Definition at line 422 of file CFFMPEG_InputStream.cpp.
References isOpen(), and m_impl.
bool CFFMPEG_InputStream::isOpen | ( | ) | const |
Return whether the video source was open correctly.
Definition at line 103 of file CFFMPEG_InputStream.cpp.
References m_impl.
Referenced by close(), getVideoFPS(), and retrieveFrame().
bool CFFMPEG_InputStream::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.
"myVideo.avi", "c:\a.mpeg") and also IP cameras (e. "rtsp://a.b.c.d/live.sdp"). However, note that there is currently no support for user/password in IP access. If verbose is set to true, more information about the video will be dumped to cout.
Definition at line 116 of file CFFMPEG_InputStream.cpp.
References close(), m_grab_as_grayscale, m_impl, m_url, url, and verbose.
Referenced by mrpt::hwdrivers::CRovio::thread_video().
bool CFFMPEG_InputStream::retrieveFrame | ( | mrpt::img::CImage & | out_img | ) |
Get the next frame from the video stream.
Note that for remote streams (IP cameras) this method may block until enough information is read to generate a new frame. Images are returned as 8-bit depth grayscale if "grab_as_grayscale" is true.
Definition at line 321 of file CFFMPEG_InputStream.cpp.
References isOpen(), mrpt::img::CImage::loadFromMemoryBuffer(), m_grab_as_grayscale, m_impl, and THROW_EXCEPTION.
Referenced by mrpt::hwdrivers::CRovio::thread_video().
|
private |
Definition at line 47 of file CFFMPEG_InputStream.h.
Referenced by openURL(), and retrieveFrame().
|
private |
Definition at line 43 of file CFFMPEG_InputStream.h.
Referenced by close(), getVideoFPS(), isOpen(), openURL(), and retrieveFrame().
|
private |
Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020 |