CAVAPA-GUI  30.5.2014
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
Public Types | Public Member Functions | List of all members
cavapa_gui::VideoFileSet Class Reference

The extension to the VideoFile class for handling multiple files. More...

#include <videofileset.h>

Inheritance diagram for cavapa_gui::VideoFileSet:
cavapa_gui::VideoFile cavapa_gui::Source

Public Types

enum  OpenError {
  FILE_OPEN_FAILED, INVALID_FRAMECOUNT, OK, WRONG_FRAMERATE,
  WRONG_RESOLUTION
}
 Values that the VideoFileSet::open() function can return.
 

Public Member Functions

 VideoFileSet (SourceID desired_id=UNDEFINED_SOURCE)
 Creates a new source. More...
 
FrameCapture get (FrameTime passed_time) override
 Retrieves the next frame from the camera. More...
 
double getBarrelCorrection () override
 Returns the barrel correction applied to the source frames. More...
 
std::string getDescription () const override
 Retrieves the description of the source. More...
 
double getFramerate () const override
 Retrieves the framerate. More...
 
std::vector< std::string > getFilenames () const override
 Returns the filenames of the source. More...
 
cv::Size getResolution () const override
 Retrieves the resolution of the source. More...
 
SourceType getSourceType () const override
 Returns the type of the source. More...
 
SourceStats getStats () override
 Retrieves the source statistical information. More...
 
bool hasNew () override
 Checks whether the device has a new image to be retrieved or not. More...
 
bool open (const std::string &filename, bool get_first, FrameTime start_point) override
 Opens a video file. More...
 
OpenError open (const std::vector< std::string > &paths, FrameTime start_point)
 Opens the multifile video source. More...
 
void play () override
 Starts frame updates on the file. More...
 
bool skipFrame (int step) override
 Skips the specific amount of frames on the video. More...
 
void setBarrelCorrection (double amount) override
 Sets the new barrel correction value. More...
 
void stop () override
 Will stop the file from playing. More...
 
- Public Member Functions inherited from cavapa_gui::VideoFile
 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.
 
int getCurrentFrame () const
 Returns the current frame of the video shown. 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 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...
 
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...
 
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...
 
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.
 

Additional Inherited Members

- Static Public Member Functions inherited from cavapa_gui::VideoFile
static void setSpeed (double multiplier)
 Sets playing speed of the video file. More...
 
- Protected Member Functions inherited from cavapa_gui::VideoFile
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 inherited from cavapa_gui::VideoFile
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 inherited from cavapa_gui::VideoFile
static double speed_ratio = 1.0
 The multiplier of the video file playing speed.
 

Detailed Description

The extension to the VideoFile class for handling multiple files.

When there is a need to play multiple video files in sequence, the VideoFile class is not enough. This class provides functionality to automatically switch between the files to provide a seamless playback.

Author
Petri Partanen
Remarks
The class was created in a short time period and it is therefore a less effective way of doing things because the class could provide a better way of threading the frame retrieval from multiple sources. Currently each video file will end up having it's own std::thread.

Constructor & Destructor Documentation

cavapa_gui::VideoFileSet::VideoFileSet ( SourceID  desired_id = UNDEFINED_SOURCE)
inline

Creates a new source.

Parameters
desired_idThe Desired ID number. Use UNDEFINED_SOURCE if you do not want to define it to a specific ID. This does not check if a source with the given ID already exists. The ID-number will not be given to other new sources with UNDEFINED_SOURCE ID numbers.

Member Function Documentation

FrameCapture cavapa_gui::VideoFileSet::get ( FrameTime  passed_time)
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.

Parameters
passed_timeThe time passed since the last call (in milliseconds).
Returns
The latest frame capture. This will actually return a reference to the original image, so you are NOT allowed to edit it! Otherwise the source buffer will be altered too. This is just the way OpenCV handles Mat memory.

Reimplemented from cavapa_gui::VideoFile.

double cavapa_gui::VideoFileSet::getBarrelCorrection ( )
overridevirtual

Returns the barrel correction applied to the source frames.

Returns
The barrel effect value.

Reimplemented from cavapa_gui::VideoFile.

string cavapa_gui::VideoFileSet::getDescription ( ) const
overridevirtual

Retrieves the description of the source.

Returns
The source description.
The description of the source will contain the names of the video files separated by a character ';'.

Reimplemented from cavapa_gui::VideoFile.

vector< string > cavapa_gui::VideoFileSet::getFilenames ( ) const
overridevirtual

Returns the filenames of the source.

Returns
The video filenames.

Reimplemented from cavapa_gui::VideoFile.

double cavapa_gui::VideoFileSet::getFramerate ( ) const
overridevirtual

Retrieves the framerate.

Returns
The framerate or 0.0 if not supported.

Reimplemented from cavapa_gui::VideoFile.

cv::Size cavapa_gui::VideoFileSet::getResolution ( ) const
overridevirtual

Retrieves the resolution of the source.

Returns
The source resolution.

Reimplemented from cavapa_gui::VideoFile.

SourceType cavapa_gui::VideoFileSet::getSourceType ( ) const
inlineoverridevirtual

Returns the type of the source.

Returns
The source type.

Reimplemented from cavapa_gui::VideoFile.

SourceStats cavapa_gui::VideoFileSet::getStats ( )
overridevirtual

Retrieves the source statistical information.

Returns
The source statistics.

Reimplemented from cavapa_gui::VideoFile.

bool cavapa_gui::VideoFileSet::hasNew ( )
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().

Returns
True if a new image available or false otherwise.
Remarks
This is protected by a mutex and should not be used when time is critical. Use it only when you know that any lag produced by this is not going to be a problem.

Reimplemented from cavapa_gui::VideoFile.

bool cavapa_gui::VideoFileSet::open ( const std::string &  filename,
bool  get_first,
FrameTime  start_point 
)
inlineoverridevirtual

Opens a video file.

Parameters
filenameThe path of the video file.
get_firstIf 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_pointThe video start point. This will be used as the initial position of the video. All seekTime() calls will be based on the position.
Returns
True if the file was opened successfully or false otherwise.
Remarks
For a single video it is recommended to use the VideoFile class.

Reimplemented from cavapa_gui::VideoFile.

VideoFileSet::OpenError cavapa_gui::VideoFileSet::open ( const std::vector< std::string > &  paths,
FrameTime  start_point 
)

Opens the multifile video source.

Parameters
pathsThe paths of the video files.
start_pointThe video start point. This will be used as the initial position of the video. All seekTime() calls will be based on this position.
Returns
The related VideoFileSetError key for the success or failure.
void cavapa_gui::VideoFileSet::play ( )
overridevirtual

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::VideoFile.

void cavapa_gui::VideoFileSet::setBarrelCorrection ( double  amount)
overridevirtual

Sets the new barrel correction value.

The value is used to correct barrel effect (lens correction) on each image that the source will return.

Parameters
amountThe barrel value.
Remarks
This might produce lag as there are lot's of mutex locks.

Reimplemented from cavapa_gui::VideoFile.

bool cavapa_gui::VideoFileSet::skipFrame ( int  step)
overridevirtual

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.

Parameters
stepThe desired frame change.
Returns
True if the skipping was successful or false otherwise.
Remarks
Unknown when this actually does fail. It might be never on video files.

Reimplemented from cavapa_gui::VideoFile.

void cavapa_gui::VideoFileSet::stop ( )
overridevirtual

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.

Reimplemented from cavapa_gui::VideoFile.


The documentation for this class was generated from the following files: