The class for the video file source. More...
#include <videofile.h>
Public Member Functions | |
VideoFile (SourceID desired_id=UNDEFINED_SOURCE) | |
Creates a new source. More... | |
bool | canRecord () const overridefinal |
Returns information on the source recording abilities. More... | |
virtual void | fetchFirstFrame () |
Seeks the startup point of the video and the first frame. | |
virtual FrameCapture | get (FrameTime passed_time) override |
Retrieves the next frame from the camera. More... | |
virtual double | getBarrelCorrection () override |
Returns the barrel correction applied to the source frames. More... | |
int | getCurrentFrame () const |
Returns the current frame of the video shown. More... | |
virtual std::string | getDescription () const override |
Retrieves the description of the source. More... | |
virtual std::vector< std::string > | getFilenames () const |
Returns the filenames of the source. More... | |
virtual double | getFramerate () const override |
Retrieves the framerate. More... | |
virtual FrameTime | getLength () const final |
Retrieves the video file length. More... | |
virtual FrameTime | getPosition () const overridefinal |
Retrieves the current time position of the source. More... | |
virtual cv::Size | getResolution () const override |
Retrieves the resolution of the source. More... | |
virtual SourceType | getSourceType () const override |
Returns the type of the source. More... | |
virtual SourceStats | getStats () override |
Retrieves the source statistical information. More... | |
virtual bool | hasNew () override |
Checks whether the device has a new image to be retrieved or not. More... | |
virtual bool | isOpen () const override |
Checks whether the source has been initialized or not. More... | |
virtual bool | isPlaying () const override |
Checks whether the source is playing or not. More... | |
virtual bool | open (const std::string &filename, bool get_first, FrameTime start_point) |
Opens a video file. More... | |
virtual void | play () override |
Starts frame updates on the file. More... | |
bool | record (const std::string &filename, const std::string &codec="") overridefinal |
Starts the recording of the source to the file. More... | |
virtual void | release () |
Forces the release of the worker thread. More... | |
bool | seekTime (FrameTime pos) |
Seeks a specific position of the video frame. More... | |
virtual bool | skipFrame (int step) |
Skips the specific amount of frames on the video. More... | |
virtual void | setBarrelCorrection (double amount) override |
Sets the new barrel correction value. More... | |
void | setCurrentAsStartPoint () |
Sets the current video time as the seeking start point. More... | |
bool | setResolution (const cv::Size &new_size) overridefinal |
Should change resolution, but does not have an effect on video files. More... | |
virtual FrameTime | startPoint () const final |
Returns the start point of the video file. More... | |
virtual void | stop () override |
Will stop the file from playing. More... | |
int | totalFrames () const |
Returns the total count of the frames in the video file. More... | |
Public Member Functions inherited from cavapa_gui::Source | |
DISALLOW_COPY_AND_ASSIGN (Source) | |
Copy and assign of the class is not allowed. | |
virtual SourceID | getID () const final |
Gets the unique source ID number. More... | |
virtual void | resetStats () final |
Resets the source statistics. | |
Static Public Member Functions | |
static void | setSpeed (double multiplier) |
Sets playing speed of the video file. More... | |
Protected Member Functions | |
FrameTime | currentFrameTime () const |
Returns the time of the currently buffered frame. More... | |
int | frameFromFrameTime (FrameTime time) const |
Returns the expected frame number from the frame time. More... | |
FrameTime | frameTimeFromFrame (int frame) const |
Returns the expected frame time of the given frame. More... | |
Protected Member Functions inherited from cavapa_gui::Source | |
Source (SourceID desired_id=UNDEFINED_SOURCE) | |
General Source creator. More... | |
Protected Attributes | |
int | current_frame |
The number of the currently buffered frame. | |
FrameTime | initial_position |
The initial position of the video file. | |
bool | opened = false |
The open status of the video file. | |
bool | playing = false |
The flag indicates if the video file is playing or not. | |
int | total_frames = 0 |
The total frames in the video file. | |
FrameTime | video_time = 0 |
The current time of the video file. | |
Protected Attributes inherited from cavapa_gui::Source | |
SourceStats | statistics = EMPTY_SOURCE_STATS |
The statistics of the source. | |
Static Protected Attributes | |
static double | speed_ratio = 1.0 |
The multiplier of the video file playing speed. | |
The class for the video file source.
The class uses OpenCV to retrieve images from the video files. The video files can be played, stopped and stepped frame by frame. You can also seek the specific point of the video. Unlike Camera, the class does not support recording, or any alterations to framerate or resolution of the source.
|
inline |
Creates a new source.
desired_id | The desired ID number. Use UNDEFINED_SOURCE if you do not want to define it to a specific ID. This does not check if the source with the given ID already exists. The ID number will not be given other new sources with UNDEFINED_SOURCE ID numbers. |
|
inlinefinaloverridevirtual |
Returns information on the source recording abilities.
Implements cavapa_gui::Source.
|
inlineprotected |
Returns the time of the currently buffered frame.
|
inlineprotected |
Returns the expected frame number from the frame time.
This is used to skip video frames if the retrieval is lagging behind on what the real time actually is.
time | The frame time where frame number is to be calculated. |
|
inlineprotected |
Returns the expected frame time of the given frame.
frame | The number of the frame. |
|
overridevirtual |
Retrieves the next frame from the camera.
The time supplied to the function informs the source about how much time has passed since the last image retrieval. The source will depend on its internal clock, either retrieving a new image or returning the buffered image that it retrieved previously.
passed_time | The time passed since the last call (in milliseconds). |
Implements cavapa_gui::Source.
Reimplemented in cavapa_gui::VideoFileSet.
|
inlineoverridevirtual |
Returns the barrel correction applied to the source frames.
Implements cavapa_gui::Source.
Reimplemented in cavapa_gui::VideoFileSet.
|
inline |
Returns the current frame of the video shown.
|
overridevirtual |
Retrieves the description of the source.
Implements cavapa_gui::Source.
Reimplemented in cavapa_gui::VideoFileSet.
|
inlinevirtual |
Returns the filenames of the source.
Reimplemented in cavapa_gui::VideoFileSet.
|
inlineoverridevirtual |
Retrieves the framerate.
Implements cavapa_gui::Source.
Reimplemented in cavapa_gui::VideoFileSet.
|
inlinefinalvirtual |
Retrieves the video file length.
|
inlinefinaloverridevirtual |
Retrieves the current time position of the source.
Implements cavapa_gui::Source.
|
inlineoverridevirtual |
Retrieves the resolution of the source.
Implements cavapa_gui::Source.
Reimplemented in cavapa_gui::VideoFileSet.
|
inlineoverridevirtual |
Returns the type of the source.
Reimplemented from cavapa_gui::Source.
Reimplemented in cavapa_gui::VideoFileSet.
|
overridevirtual |
Retrieves the source statistical information.
Implements cavapa_gui::Source.
Reimplemented in cavapa_gui::VideoFileSet.
|
inlineoverridevirtual |
Checks whether the device has a new image to be retrieved or not.
This checks if the FrameTime on the buffered image differs from what was retrieved on the last get().
Implements cavapa_gui::Source.
Reimplemented in cavapa_gui::VideoFileSet.
|
inlineoverridevirtual |
Checks whether the source has been initialized or not.
Implements cavapa_gui::Source.
|
inlineoverridevirtual |
Checks whether the source is playing or not.
Implements cavapa_gui::Source.
|
virtual |
Opens a video file.
filename | The path of the video file. |
get_first | If the first image of the video should be retrieved or not. This is useful in most cases, but if we are opening multiple video files of the same source it might be wise to set this false. This way a worker thread of the frame retrieval is not automatically started. |
start_point | The video start point. This will be used as the initial position of the video. All seekTime() calls will be based on the position. |
Reimplemented in cavapa_gui::VideoFileSet.
|
inlineoverridevirtual |
Starts frame updates on the file.
After the video file has been set to play, it will start to retrieve new frames for each get() call.
Reimplemented from cavapa_gui::Source.
Reimplemented in cavapa_gui::VideoFileSet.
|
inlinefinaloverridevirtual |
Starts the recording of the source to the file.
This can also be used to start an entirely new video file during the recording. The recording file will change immediately.
filename | The path of the recording file. |
codec | The codec to be used for recording. |
filename | Not used. |
codec | Not used. |
Implements cavapa_gui::Source.
|
inlinevirtual |
Forces the release of the worker thread.
This is used when multiple video files are combined as a one source of video. When the particular video file is currently not being accessed, the worker thread can be released to free up system's resources. The worker thread is again automatically started when the get() function is called. These threads are sleeping when no frames are being fetched, but the system still has limited amount of threads at its disposal. If you plan to use hundreds of them, then you should release the ones you don't need at the time.
bool cavapa_gui::VideoFile::seekTime | ( | FrameTime | pos | ) |
Seeks a specific position of the video frame.
This does not use the actual start position of the video.
pos | The new desired video frame position. |
|
inlineoverridevirtual |
Sets the new barrel correction value.
The value is used to correct barrel effect (lens correction) on each image that the source will return.
amount | The barrel value. |
Implements cavapa_gui::Source.
Reimplemented in cavapa_gui::VideoFileSet.
|
inline |
Sets the current video time as the seeking start point.
|
inlinefinaloverridevirtual |
Should change resolution, but does not have an effect on video files.
It is safe to call this.
new_size | Not used. |
Implements cavapa_gui::Source.
|
inlinestatic |
Sets playing speed of the video file.
multiplier | The speed multiplier for the video file. The default is 1.0. |
|
virtual |
Skips the specific amount of frames on the video.
The positive numbers skip forward and negatives skip backward. The frame will be limited to the actual limits of the video, skipping 10 million frames will just seek to the last frame of the video.
step | The desired frame change. |
Reimplemented in cavapa_gui::VideoFileSet.
|
inlinefinalvirtual |
Returns the start point of the video file.
|
inlineoverridevirtual |
Will stop the file from playing.
Any calls to function get() will return the same buffered image and will not advance the videos internal clock. Use play() to start retrieving images again.
Implements cavapa_gui::Source.
Reimplemented in cavapa_gui::VideoFileSet.
|
inline |
Returns the total count of the frames in the video file.