CAVAPA-GUI  30.5.2014
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cavapa_gui::Source Class Referenceabstract

The camera and video file source base class. More...

#include <source.h>

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

Public Member Functions

 DISALLOW_COPY_AND_ASSIGN (Source)
 Copy and assign of the class is not allowed.
 
virtual bool canRecord () const =0
 Returns information on the source recording abilities. More...
 
virtual FrameCapture get (FrameTime passed_time)=0
 Retrieves the next frame from the camera. More...
 
virtual double getBarrelCorrection ()=0
 Returns the barrel correction applied to the source frames. More...
 
virtual std::string getDescription () const =0
 Retrieves the description of the source. More...
 
virtual double getFramerate () const =0
 Retrieves the framerate. More...
 
virtual SourceID getID () const final
 Gets the unique source ID number. More...
 
virtual cv::Size getResolution () const =0
 Retrieves the resolution of the source. More...
 
virtual FrameTime getPosition () const =0
 Retrieves the current time position of the source. More...
 
virtual SourceType getSourceType () const
 Returns the type of the source. More...
 
virtual SourceStats getStats ()=0
 Retrieves the source statistical information. More...
 
virtual bool hasNew ()=0
 Checks whether the device has a new image to be retrieved or not. More...
 
virtual bool isOpen () const =0
 Checks whether the source has been initialized or not. More...
 
virtual bool isPlaying () const =0
 Checks whether the source is playing or not. More...
 
virtual void play ()
 Starts to play the source. More...
 
virtual bool record (const std::string &filename, const std::string &codec="")=0
 Starts the recording of the source to the file. More...
 
virtual void resetStats () final
 Resets the source statistics.
 
virtual void setBarrelCorrection (double amount)=0
 Sets the new barrel correction value. More...
 
virtual bool setResolution (const cv::Size &new_size)=0
 Sets the source resolution. More...
 
virtual void stop ()=0
 Stops the source. More...
 

Protected Member Functions

 Source (SourceID desired_id=UNDEFINED_SOURCE)
 General Source creator. More...
 

Protected Attributes

SourceStats statistics = EMPTY_SOURCE_STATS
 The statistics of the source.
 

Detailed Description

The camera and video file source base class.

The base class for any kind of frame source that provides the frame updates with buffering. The inherits from the class can provide their own functionality such as recording, resolution changes and/or framerate alterations.

Author
Petri Partanen

Constructor & Destructor Documentation

cavapa_gui::Source::Source ( SourceID  desired_id = UNDEFINED_SOURCE)
inlineprotected

General Source creator.

Parameters
desired_idThe desired ID number for the source.
Remarks
This does not perform any checks if the desired ID number is already used. You must perform that check somewhere else. The function does however ensure that the sources that have no desired ID's defined will never be given the desired source ID number.

Member Function Documentation

virtual bool cavapa_gui::Source::canRecord ( ) const
pure virtual

Returns information on the source recording abilities.

Returns
True if the source can record, false otherwise.

Implemented in cavapa_gui::Camera, and cavapa_gui::VideoFile.

virtual FrameCapture cavapa_gui::Source::get ( FrameTime  passed_time)
pure virtual

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.

Implemented in cavapa_gui::Camera, cavapa_gui::VideoFile, and cavapa_gui::VideoFileSet.

virtual double cavapa_gui::Source::getBarrelCorrection ( )
pure virtual

Returns the barrel correction applied to the source frames.

Returns
The barrel effect value.

Implemented in cavapa_gui::Camera, cavapa_gui::VideoFile, and cavapa_gui::VideoFileSet.

virtual std::string cavapa_gui::Source::getDescription ( ) const
pure virtual

Retrieves the description of the source.

Returns
The source description.

Implemented in cavapa_gui::Camera, cavapa_gui::VideoFile, and cavapa_gui::VideoFileSet.

virtual double cavapa_gui::Source::getFramerate ( ) const
pure virtual

Retrieves the framerate.

Returns
The framerate or 0.0 if not supported.

Implemented in cavapa_gui::Camera, cavapa_gui::VideoFile, and cavapa_gui::VideoFileSet.

virtual SourceID cavapa_gui::Source::getID ( ) const
inlinefinalvirtual

Gets the unique source ID number.

Returns
The source ID number.
virtual FrameTime cavapa_gui::Source::getPosition ( ) const
pure virtual

Retrieves the current time position of the source.

Returns
The source time position.

Implemented in cavapa_gui::Camera, and cavapa_gui::VideoFile.

virtual cv::Size cavapa_gui::Source::getResolution ( ) const
pure virtual

Retrieves the resolution of the source.

Returns
The source resolution.

Implemented in cavapa_gui::Camera, cavapa_gui::VideoFile, and cavapa_gui::VideoFileSet.

virtual SourceType cavapa_gui::Source::getSourceType ( ) const
inlinevirtual

Returns the type of the source.

Returns
The source type.

Reimplemented in cavapa_gui::Camera, cavapa_gui::VideoFile, and cavapa_gui::VideoFileSet.

virtual SourceStats cavapa_gui::Source::getStats ( )
pure virtual

Retrieves the source statistical information.

Returns
The source statistics.

Implemented in cavapa_gui::Camera, cavapa_gui::VideoFile, and cavapa_gui::VideoFileSet.

virtual bool cavapa_gui::Source::hasNew ( )
pure virtual

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.

Implemented in cavapa_gui::Camera, cavapa_gui::VideoFile, and cavapa_gui::VideoFileSet.

virtual bool cavapa_gui::Source::isOpen ( ) const
pure virtual

Checks whether the source has been initialized or not.

Returns
True if it is initialized or false otherwise.

Implemented in cavapa_gui::Camera, and cavapa_gui::VideoFile.

virtual bool cavapa_gui::Source::isPlaying ( ) const
pure virtual

Checks whether the source is playing or not.

Returns
True if the source is playing or false otherwise.

Implemented in cavapa_gui::Camera, and cavapa_gui::VideoFile.

virtual void cavapa_gui::Source::play ( )
inlinevirtual

Starts to play the source.

Depending on the source type, this might have no effect.

Reimplemented in cavapa_gui::VideoFile, and cavapa_gui::VideoFileSet.

virtual bool cavapa_gui::Source::record ( const std::string &  filename,
const std::string &  codec = "" 
)
pure virtual

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.

Parameters
filenameThe path of the recording file.
codecThe codec to be used for recording.
Returns
True if the recording started or false otherwise.

Implemented in cavapa_gui::Camera, and cavapa_gui::VideoFile.

virtual void cavapa_gui::Source::setBarrelCorrection ( double  amount)
pure virtual

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.

Implemented in cavapa_gui::VideoFile, cavapa_gui::Camera, and cavapa_gui::VideoFileSet.

virtual bool cavapa_gui::Source::setResolution ( const cv::Size &  new_size)
pure virtual

Sets the source resolution.

Parameters
new_sizeThe new resolution for the source.
Returns
True if the resolution was set, false otherwise.

Implemented in cavapa_gui::VideoFile, and cavapa_gui::Camera.

virtual void cavapa_gui::Source::stop ( )
pure virtual

Stops the source.

Depending on the source type this will have a different effect.

Implemented in cavapa_gui::VideoFile, cavapa_gui::Camera, and cavapa_gui::VideoFileSet.


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