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 37 of file CFFMPEG_InputStream.h.
#include <mrpt/hwdrivers/CFFMPEG_InputStream.h>
Public Member Functions | |
CFFMPEG_InputStream () | |
Default constructor, does not open any video source at startup. | |
virtual | ~CFFMPEG_InputStream () |
Destructor. | |
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). | |
double | getVideoFPS () const |
Get the frame-per-second (FPS) of the video source, or "-1" if the video is not open. | |
bool | retrieveFrame (mrpt::utils::CImage &out_img) |
Get the next frame from the video stream. | |
Private Attributes | |
mrpt::utils::void_ptr_noncopy | m_state |
The internal ffmpeg state. | |
std::string | m_url |
The open URL. | |
bool | m_grab_as_grayscale |
mrpt::hwdrivers::CFFMPEG_InputStream::CFFMPEG_InputStream | ( | ) |
Default constructor, does not open any video source at startup.
|
virtual |
Destructor.
void mrpt::hwdrivers::CFFMPEG_InputStream::close | ( | ) |
Close the video stream (this is called automatically at destruction).
double mrpt::hwdrivers::CFFMPEG_InputStream::getVideoFPS | ( | ) | const |
Get the frame-per-second (FPS) of the video source, or "-1" if the video is not open.
bool mrpt::hwdrivers::CFFMPEG_InputStream::isOpen | ( | ) | const |
Return whether the video source was open correctly.
bool mrpt::hwdrivers::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.
bool mrpt::hwdrivers::CFFMPEG_InputStream::retrieveFrame | ( | mrpt::utils::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.
|
private |
Definition at line 42 of file CFFMPEG_InputStream.h.
|
private |
The internal ffmpeg state.
Definition at line 40 of file CFFMPEG_InputStream.h.
|
private |
The open URL.
Definition at line 41 of file CFFMPEG_InputStream.h.
Page generated by Doxygen 1.9.8 for MRPT 1.4.0 SVN: at Thu Dec 14 16:54:58 UTC 2023 |