YARP
Yet Another Robot Platform

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

#include <opencv/OpenCVGrabber.h>

+ Inheritance diagram for OpenCVGrabber:

Public Member Functions

 OpenCVGrabber ()
 Create an OpenCV image grabber. More...
 
virtual ~OpenCVGrabber ()
 Destroy an OpenCV image grabber. More...
 
bool open (yarp::os::Searchable &config) override
 Open the DeviceDriver. More...
 
bool close () override
 Close a grabber. More...
 
bool getImage (yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) override
 Get an rgb image from the frame grabber, if required demosaicking/color reconstruction is applied. More...
 
virtual bool sendImage (const cv::Mat &frame, yarp::sig::ImageOf< yarp::sig::PixelRgb > &image)
 Read an image from the grabber. More...
 
int height () const override
 Get the height of images a grabber produces. More...
 
int width () const override
 Get the width of images a grabber produces. More...
 
yarp::os::Stamp getLastInputStamp () override
 Implements the IPreciselyTimed interface. More...
 
- Public Member Functions inherited from yarp::dev::IFrameGrabberImage
virtual ~IFrameGrabberImage ()
 Destructor. More...
 
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 rgb image from the frame grabber, if required demosaicking/color reconstruction is applied. More...
 
- Public Member Functions inherited from yarp::dev::DeviceDriver
 ~DeviceDriver () override=default
 Destructor. More...
 
template<class T >
bool view (T *&x)
 Get an interface to the device driver. More...
 
virtual DeviceDrivergetImplementation ()
 Some drivers are bureaucrats, pointing at others. More...
 
- Public Member Functions inherited from yarp::os::IConfig
virtual ~IConfig ()
 Destructor. More...
 
virtual bool configure (Searchable &config)
 Change online parameters. More...
 
- Public Member Functions inherited from yarp::dev::IPreciselyTimed
virtual ~IPreciselyTimed ()
 

Protected Attributes

size_t m_w
 Width of the images a grabber produces. More...
 
size_t m_h
 Height of the images a grabber produces. More...
 
bool m_loop
 Whether to loop or not. More...
 
bool m_saidSize
 
bool m_saidResize
 
bool fromFile
 Whether reading from file or camera. More...
 
cv::VideoCapture m_cap
 OpenCV image capture object. More...
 
bool m_transpose
 
bool m_flip_x
 
bool m_flip_y
 
yarp::os::Property m_config
 Saved copy of the device configuration. More...
 
yarp::os::Stamp m_laststamp
 

Detailed Description

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

Definition at line 44 of file OpenCVGrabber.h.

Constructor & Destructor Documentation

◆ OpenCVGrabber()

OpenCVGrabber::OpenCVGrabber ( )
inline

Create an OpenCV image grabber.

This initializes members to reasonable default values, the real initialization is done in open().

Definition at line 56 of file OpenCVGrabber.h.

◆ ~OpenCVGrabber()

virtual OpenCVGrabber::~OpenCVGrabber ( )
inlinevirtual

Destroy an OpenCV image grabber.

Definition at line 70 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 164 of file OpenCVGrabber.cpp.

◆ getImage()

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

Get an rgb image from the frame grabber, if required demosaicking/color reconstruction is applied.

Parameters
imagethe image to be filled
Returns
true/false upon success/failure

Implements yarp::dev::IFrameGrabberImage.

Definition at line 227 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 94 of file OpenCVGrabber.h.

◆ height()

int OpenCVGrabber::height ( ) const
inlineoverridevirtual

Get the height of images a grabber produces.

Returns
The image height.

Implements yarp::dev::IFrameGrabberImage.

Definition at line 84 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 71 of file OpenCVGrabber.cpp.

◆ sendImage()

bool OpenCVGrabber::sendImage ( const cv::Mat &  frame,
yarp::sig::ImageOf< yarp::sig::PixelRgb > &  image 
)
virtual

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.

Definition at line 182 of file OpenCVGrabber.cpp.

◆ width()

int OpenCVGrabber::width ( ) const
inlineoverridevirtual

Get the width of images a grabber produces.

Returns
The image width.

Implements yarp::dev::IFrameGrabberImage.

Definition at line 88 of file OpenCVGrabber.h.

Member Data Documentation

◆ fromFile

bool OpenCVGrabber::fromFile
protected

Whether reading from file or camera.

Definition at line 110 of file OpenCVGrabber.h.

◆ m_cap

cv::VideoCapture OpenCVGrabber::m_cap
protected

OpenCV image capture object.

Definition at line 113 of file OpenCVGrabber.h.

◆ m_config

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

Saved copy of the device configuration.

Definition at line 121 of file OpenCVGrabber.h.

◆ m_flip_x

bool OpenCVGrabber::m_flip_x
protected

Definition at line 117 of file OpenCVGrabber.h.

◆ m_flip_y

bool OpenCVGrabber::m_flip_y
protected

Definition at line 118 of file OpenCVGrabber.h.

◆ m_h

size_t OpenCVGrabber::m_h
protected

Height of the images a grabber produces.

Definition at line 101 of file OpenCVGrabber.h.

◆ m_laststamp

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

Definition at line 123 of file OpenCVGrabber.h.

◆ m_loop

bool OpenCVGrabber::m_loop
protected

Whether to loop or not.

Definition at line 104 of file OpenCVGrabber.h.

◆ m_saidResize

bool OpenCVGrabber::m_saidResize
protected

Definition at line 107 of file OpenCVGrabber.h.

◆ m_saidSize

bool OpenCVGrabber::m_saidSize
protected

Definition at line 106 of file OpenCVGrabber.h.

◆ m_transpose

bool OpenCVGrabber::m_transpose
protected

Definition at line 116 of file OpenCVGrabber.h.

◆ m_w

size_t OpenCVGrabber::m_w
protected

Width of the images a grabber produces.

Definition at line 99 of file OpenCVGrabber.h.


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