The OpenCV capturing class. More...
#include <opencvcapture.h>
Public Member Functions | |
DISALLOW_COPY_AND_ASSIGN (OpenCVCapture) | |
Copy and assign of the class is not allowed. | |
double | getBarrelCorrection () override |
Retrieves the barrel correction applied to the source. More... | |
FrameCapture | getBuffered () override |
Retrieves the currently buffered frame. More... | |
std::string | getDescription () const override |
Retrieves the description of the device. More... | |
int | getDeviceID () const override |
Returns the ID number the device was initialized with. More... | |
double | getFramerate () const override |
Retrieves the capture device framerate. More... | |
int | getMissedFrames () const override |
Retrieves the logged frame misses. More... | |
FrameCapture | getNext (bool skip, bool *error) override |
Retrieves the next frame. More... | |
std::string | getPath () const override |
Retrieves the path given during the initialization. More... | |
double | getProperty (int propId) |
Gets the OpenCV specific source properties. More... | |
cv::Size | getResolution () const override |
Retrieves the capture device resolution. More... | |
int | getRetrievedFrames () const override |
Retrieves the total logged frames. More... | |
INTERFACE_TYPE | getType () const overridefinal |
Retrieves the type of the device. More... | |
bool | hasNew () override |
Checks whether the device has a new image to be retrieved or not. More... | |
bool | isOpen () const override |
Checks whether the source has been initialized or not. More... | |
bool | open (int index) |
Opens OpenCV VideoCapture for the hardware device. More... | |
bool | open (const std::string &path) override |
Opens the video file or the stream. More... | |
void | release () |
Forces the release of the worker thread. More... | |
void | resetStats () override |
Resets the statistical counters. More... | |
void | setBarrelCorrection (double amount) override |
Sets the amount of the barrel correction to be applied. More... | |
bool | setProperty (int propId, double value) |
Sets OpenCV specific source properties. More... | |
bool | setResolution (const cv::Size &new_size) override |
Sets the capturing device resolution. More... | |
Public Member Functions inherited from cavapa_gui::CaptureInterface | |
DISALLOW_COPY_AND_ASSIGN (CaptureInterface) | |
Copy and assign of the class is not allowed. | |
Additional Inherited Members | |
Public Types inherited from cavapa_gui::CaptureInterface | |
enum | INTERFACE_TYPE { HTTP, OPENCV } |
Used to define the type of source interface. | |
The OpenCV capturing class.
The class provides OpenCV-powered VideoCapture. It can be used for hardware cameras, network streams or video files. The class multithreads the actual retrievals and offers some buffering for possible frame misses and device lag time. The class does not handle HTTP image sources as current version of OpenCV (2.4.9) is unable to retrieve them multiple times.
OpenCV allows limited access to resolution and framerate changing on most device sources. Unfortunately, it seriously lacks any kind of error catching method. Special statistical values are used to catch missed frames and other problems.
As an extension of the CaptureInterface class, the class is initialized with open() that opens the connection to the actual capturing device. Once connection has been established, images can be retrieved with getNext(). Some OpenCV devices also support the change of image size and framerate.
|
overridevirtual |
Retrieves the barrel correction applied to the source.
Implements cavapa_gui::CaptureInterface.
|
overridevirtual |
Retrieves the currently buffered frame.
Implements cavapa_gui::CaptureInterface.
|
overridevirtual |
Retrieves the description of the device.
Implements cavapa_gui::CaptureInterface.
|
inlineoverridevirtual |
Returns the ID number the device was initialized with.
Implements cavapa_gui::CaptureInterface.
|
inlineoverridevirtual |
Retrieves the capture device framerate.
Implements cavapa_gui::CaptureInterface.
|
inlineoverridevirtual |
Retrieves the logged frame misses.
A frame miss occurs everytime when getNext() is called and the previous retrieval was still ongoing.
Implements cavapa_gui::CaptureInterface.
|
overridevirtual |
Retrieves the next frame.
Basically it returns the currently buffered frame and signals the device to grab a new image for next call to the function. If the device has not returned from previous image grab the call is recorded as a missed frame.
skip | Specifies if the frame can be skipped. When set to true, this will force the main thread to wait for a new image from the device. This can result in a huge lag if the device is not capable of retrieving images fast enough. |
error | Will receive an error message if something went wrong. |
Implements cavapa_gui::CaptureInterface.
|
inlineoverridevirtual |
Retrieves the path given during the initialization.
Implements cavapa_gui::CaptureInterface.
double cavapa_gui::OpenCVCapture::getProperty | ( | int | propId | ) |
Gets the OpenCV specific source properties.
See OpenCV VideoCapture class for more info.
propId | VideoCapture::get property. |
|
inlineoverridevirtual |
Retrieves the capture device resolution.
Implements cavapa_gui::CaptureInterface.
|
inlineoverridevirtual |
Retrieves the total logged frames.
Basically, this is a counter on how many times getNext() has been called.
Implements cavapa_gui::CaptureInterface.
|
inlinefinaloverridevirtual |
Retrieves the type of the device.
Implements cavapa_gui::CaptureInterface.
|
overridevirtual |
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::CaptureInterface.
|
inlineoverridevirtual |
Checks whether the source has been initialized or not.
Implements cavapa_gui::CaptureInterface.
bool cavapa_gui::OpenCVCapture::open | ( | int | index | ) |
Opens OpenCV VideoCapture for the hardware device.
index | The device index number. |
|
overridevirtual |
Opens the video file or the stream.
path | The path of the video file or the network stream. |
Implements cavapa_gui::CaptureInterface.
void cavapa_gui::OpenCVCapture::release | ( | ) |
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 getNext() function is called.
|
inlineoverridevirtual |
Resets the statistical counters.
This affects the missed and total frame counters.
Implements cavapa_gui::CaptureInterface.
|
overridevirtual |
Sets the amount of the barrel correction to be applied.
amount | The barrel effect. 0.0 means none. |
Implements cavapa_gui::CaptureInterface.
bool cavapa_gui::OpenCVCapture::setProperty | ( | int | propId, |
double | value | ||
) |
Sets OpenCV specific source properties.
See OpenCV VideoCapture for more info.
propId | VideoCapture::set property. You should NOT change resolution or framerate directly by using this. |
value | The new value of the property. |
|
overridevirtual |
Sets the capturing device resolution.
new_size | The size to be set. |
Implements cavapa_gui::CaptureInterface.