YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
OpenCVGrabber Class Reference

opencv_grabber: An image frame grabber device using OpenCV to capture images from cameras and AVI files. More...

#include <opencvGrabber/OpenCVGrabber.h>

+ Inheritance diagram for OpenCVGrabber:

Public Member Functions

 OpenCVGrabber ()
 
virtual ~OpenCVGrabber ()
 
bool open (yarp::os::Searchable &config) override
 Open the DeviceDriver.
 
bool close () override
 Close a grabber.
 
bool getImage (yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) override
 Read an image from the grabber.
 
int height () const override
 Return the height of each frame.
 
int width () const override
 Return the width of each frame.
 
yarp::os::Stamp getLastInputStamp () override
 Implements the IPreciselyTimed interface.
 
- Public Member Functions inherited from yarp::dev::IFrameGrabberOf< yarp::sig::ImageOf< yarp::sig::PixelRgb > >
virtual bool getImageCrop (cropType_id_t cropType, yarp::sig::VectorOf< std::pair< int, int > > vertices, yarp::sig::ImageOf< yarp::sig::PixelRgb > &image)
 Get a crop of the image from the frame grabber.
 
- Public Member Functions inherited from yarp::dev::IFrameGrabberImageBase
virtual ~IFrameGrabberImageBase ()
 Destructor.
 
- Public Member Functions inherited from yarp::dev::DeviceDriver
 DeviceDriver ()
 
 DeviceDriver (const DeviceDriver &other)=delete
 
 DeviceDriver (DeviceDriver &&other) noexcept=delete
 
DeviceDriveroperator= (const DeviceDriver &other)=delete
 
DeviceDriveroperator= (DeviceDriver &&other) noexcept=delete
 
virtual ~DeviceDriver ()
 
virtual std::string id () const
 Return the id assigned to the PolyDriver.
 
virtual void setId (const std::string &id)
 Set the id for this device.
 
template<class T >
bool view (T *&x)
 Get an interface to the device driver.
 
virtual DeviceDrivergetImplementation ()
 Some drivers are bureaucrats, pointing at others.
 
- Public Member Functions inherited from yarp::dev::IPreciselyTimed
virtual ~IPreciselyTimed ()
 
- Public Member Functions inherited from OpenCVGrabber_ParamsParser
 OpenCVGrabber_ParamsParser ()
 
 ~OpenCVGrabber_ParamsParser () override=default
 
bool parseParams (const yarp::os::Searchable &config) override
 Parse the DeviceDriver parameters.
 
std::string getDeviceClassName () const override
 Get the name of the DeviceDriver class.
 
std::string getDeviceName () const override
 Get the name of the device (i.e.
 
std::string getDocumentationOfDeviceParams () const override
 Get the documentation of the DeviceDriver's parameters.
 
std::vector< std::string > getListOfParams () const override
 Return a list of all params used by the device.
 
- Public Member Functions inherited from yarp::dev::IDeviceDriverParams
virtual ~IDeviceDriverParams ()
 

Protected Attributes

bool m_saidSize = false
 
bool m_saidResize = false
 
bool fromFile = false
 Whether reading from file or camera.
 
cv::VideoCapture m_cap
 OpenCV image capture object.
 
yarp::os::Property m_config
 Saved copy of the device configuration.
 
yarp::os::Stamp m_laststamp
 

Additional Inherited Members

- Public Attributes inherited from OpenCVGrabber_ParamsParser
const std::string m_device_classname = {"OpenCVGrabber"}
 
const std::string m_device_name = {"opencv_grabber"}
 
bool m_parser_is_strict = false
 
const parser_version_type m_parser_version = {}
 
const std::string m_movie_defaultValue = {""}
 
const std::string m_loop_defaultValue = {"false"}
 
const std::string m_camera_defaultValue = {"0"}
 
const std::string m_framerate_defaultValue = {"-1"}
 
const std::string m_width_defaultValue = {"0"}
 
const std::string m_height_defaultValue = {"0"}
 
const std::string m_flip_x_defaultValue = {"false"}
 
const std::string m_flip_y_defaultValue = {"false"}
 
const std::string m_transpose_defaultValue = {"false"}
 
std::string m_movie = {}
 
bool m_loop = {false}
 
int m_camera = {0}
 
double m_framerate = {-1}
 
int m_width = {0}
 
int m_height = {0}
 
bool m_flip_x = {false}
 
bool m_flip_y = {false}
 
bool m_transpose = {false}
 

Detailed Description

opencv_grabber: An image frame grabber device using OpenCV to capture images from cameras and AVI files.

Parameters required by this device are shown in class: OpenCVGrabber_ParamsParser

Definition at line 28 of file OpenCVGrabber.h.

Constructor & Destructor Documentation

◆ OpenCVGrabber()

OpenCVGrabber::OpenCVGrabber ( )
inline

Definition at line 36 of file OpenCVGrabber.h.

◆ ~OpenCVGrabber()

virtual OpenCVGrabber::~OpenCVGrabber ( )
inlinevirtual

Definition at line 42 of file OpenCVGrabber.h.

Member Function Documentation

◆ close()

bool OpenCVGrabber::close ( )
overridevirtual

Close a grabber.

This is called by yarp to free any allocated hardware or software resources when the driver instance is no longer needed.

Returns
True if the device was successfully closed. In any case the device will be unusable after this function is called.

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 128 of file OpenCVGrabber.cpp.

◆ getImage()

bool OpenCVGrabber::getImage ( yarp::sig::ImageOf< yarp::sig::PixelRgb > &  image)
overridevirtual

Read an image from the grabber.

Parameters
imageThe image to read. The image will be resized to the dimensions the grabber is using, and the captured image data will be written to it.
Returns
True if an image was successfully captured. If false returned, the image will be resized to the dimensions used by the grabber, but all pixels will be zeroed.

Implements yarp::dev::IFrameGrabberOf< yarp::sig::ImageOf< yarp::sig::PixelRgb > >.

Definition at line 146 of file OpenCVGrabber.cpp.

◆ getLastInputStamp()

yarp::os::Stamp OpenCVGrabber::getLastInputStamp ( )
inlineoverridevirtual

Implements the IPreciselyTimed interface.

Returns
the yarp::os::Stamp of the last image acquired

Implements yarp::dev::IPreciselyTimed.

Definition at line 56 of file OpenCVGrabber.h.

◆ height()

int OpenCVGrabber::height ( ) const
inlineoverridevirtual

Return the height of each frame.

Returns
image height

Implements yarp::dev::IFrameGrabberImageBase.

Definition at line 49 of file OpenCVGrabber.h.

◆ open()

bool OpenCVGrabber::open ( yarp::os::Searchable config)
overridevirtual

Open the DeviceDriver.

Parameters
configis a list of parameters for the device. Which parameters are effective for your device can vary. See device invocation examples. If there is no example for your device, you can run the "yarpdev" program with the verbose flag set to probe what parameters the device is checking. If that fails too, you'll need to read the source code (please nag one of the yarp developers to add documentation for your device).
Returns
true/false upon success/failure

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 56 of file OpenCVGrabber.cpp.

◆ width()

int OpenCVGrabber::width ( ) const
inlineoverridevirtual

Return the width of each frame.

Returns
image width

Implements yarp::dev::IFrameGrabberImageBase.

Definition at line 50 of file OpenCVGrabber.h.

Member Data Documentation

◆ fromFile

bool OpenCVGrabber::fromFile = false
protected

Whether reading from file or camera.

Definition at line 64 of file OpenCVGrabber.h.

◆ m_cap

cv::VideoCapture OpenCVGrabber::m_cap
protected

OpenCV image capture object.

Definition at line 67 of file OpenCVGrabber.h.

◆ m_config

yarp::os::Property OpenCVGrabber::m_config
protected

Saved copy of the device configuration.

Definition at line 70 of file OpenCVGrabber.h.

◆ m_laststamp

yarp::os::Stamp OpenCVGrabber::m_laststamp
protected

Definition at line 72 of file OpenCVGrabber.h.

◆ m_saidResize

bool OpenCVGrabber::m_saidResize = false
protected

Definition at line 61 of file OpenCVGrabber.h.

◆ m_saidSize

bool OpenCVGrabber::m_saidSize = false
protected

Definition at line 60 of file OpenCVGrabber.h.


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