The class for a camera source. More...
#include <camera.h>
Public Member Functions | |
Camera (SourceID desired_id=UNDEFINED_SOURCE) | |
Creates a new source. More... | |
DISALLOW_COPY_AND_ASSIGN (Camera) | |
Copy and assign of the class is not allowed. | |
bool | canRecord () const override |
Returns information on the source recording abilities. 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... | |
int | getDeviceID () const |
Retrieves the device number used to initialize the device. More... | |
double | getFramerate () const override |
Retrieves the framerate. More... | |
FrameTime | getPosition () const overridefinal |
Retrieves the current time position of the source. More... | |
std::vector< std::string > | getRecordings () const |
Returns the names of the video files that were recorded. 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 (int index) |
Opens a new camera object. More... | |
bool | open (const std::string &url) |
Opens a new camera object. More... | |
bool | isOpen () const override |
Checks if the source has been initialized. More... | |
bool | isPlaying () const override |
Checks whether the source is playing or not. More... | |
bool | record (const std::string &filename, const std::string &codec="") override |
Starts the recording of the source to the file. More... | |
void | setBarrelCorrection (double amount) override |
Sets the new barrel correction value. More... | |
bool | setResolution (const cv::Size &new_size) override |
Sets the source resolution. More... | |
void | stop () override |
Stops the camera from recording. 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 | play () |
Starts to play the source. More... | |
virtual void | resetStats () final |
Resets the source statistics. | |
Static Public Member Functions | |
static std::string | getCodec () |
Retrieves the current codec used. More... | |
static double | getDefaultFPS () |
Retrieves the default framerate that has been set. More... | |
static bool | setCodec (const std::string &codec) |
Sets recorders codec for new videos. More... | |
static void | setDefaultFPS (double fps) |
Sets the cameras default framerate. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from cavapa_gui::Source | |
Source (SourceID desired_id=UNDEFINED_SOURCE) | |
General Source creator. More... | |
Protected Attributes inherited from cavapa_gui::Source | |
SourceStats | statistics = EMPTY_SOURCE_STATS |
The statistics of the source. | |
The class for a camera source.
The class is used to retrieve frames from HW cameras and network streams. The class provides a Recorder that can save frames to disk into video file.
HW camera frame retrievals take about 2ms. Recording the frame to a file at the same time takes about 3ms per camera. However, if the FPS retrieval is too high for that particular camera, it starts lag and can take up to 30-90 ms per image retrieval. This is solved in the OpenCVCapture by multithreading the retrieval process.
By multithreading the retrieval process, the programs base application can be sure that it get's either a new image from the camera or a duplicate of the last image it already showed. Showing the last image twice in a row is not a problem at all, because that's exactly what happens when you cut your frame rate in half, you just see the same image a little bit longer.
|
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 to another new sources with UNDEFINED_SOURCE ID number. |
|
inlineoverridevirtual |
Returns information on the source recording abilities.
Implements cavapa_gui::Source.
|
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). |
TODO: Handle error flag!
Implements cavapa_gui::Source.
|
inlineoverridevirtual |
Returns the barrel correction applied to the source frames.
Implements cavapa_gui::Source.
|
inlinestatic |
Retrieves the current codec used.
|
inlinestatic |
Retrieves the default framerate that has been set.
The framerate used for the cameras do not give any information on their current framerate capabilities.
|
inlineoverridevirtual |
Retrieves the description of the source.
Implements cavapa_gui::Source.
|
inline |
Retrieves the device number used to initialize the device.
|
overridevirtual |
Retrieves the framerate.
Implements cavapa_gui::Source.
|
inlinefinaloverridevirtual |
Retrieves the current time position of the source.
Implements cavapa_gui::Source.
std::vector< string > cavapa_gui::Camera::getRecordings | ( | ) | const |
Returns the names of the video files that were recorded.
|
inlineoverridevirtual |
Retrieves the resolution of the source.
Implements cavapa_gui::Source.
|
overridevirtual |
|
overridevirtual |
Retrieves the source statistical information.
Implements cavapa_gui::Source.
|
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.
|
inlineoverridevirtual |
Checks if the source has been initialized.
Implements cavapa_gui::Source.
|
inlineoverridevirtual |
Checks whether the source is playing or not.
Implements cavapa_gui::Source.
bool cavapa_gui::Camera::open | ( | int | index | ) |
Opens a new camera object.
index | The device index number. |
bool cavapa_gui::Camera::open | ( | const std::string & | url | ) |
Opens a new camera object.
url | The device url. |
|
overridevirtual |
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. |
Implements cavapa_gui::Source.
|
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.
amount | The barrel value. |
Implements cavapa_gui::Source.
|
static |
Sets recorders codec for new videos.
See the list of codecs at http://www.fourcc.org/codecs.php
codec | The new Codec. |
|
inlinestatic |
Sets the cameras default framerate.
This is applied to the cameras that do not give out any other framerate values. This will affect most USB cameras for example.
fps | The new framerate to be set. |
|
overridevirtual |
Sets the source resolution.
new_size | The new resolution for the source. |
Implements cavapa_gui::Source.
|
overridevirtual |
Stops the camera from recording.
This stops the recorder and let's it write the rest of the buffer to the file.
Implements cavapa_gui::Source.