class mrpt::hwdrivers::CImageGrabber_OpenCV
Overview
A class for grabbing images from a “OpenCV”-compatible camera, or from an AVI video file.
See the constructor for the options when opening the camera.
Unless input from AVI files is required, it is recommended to use the more generic class mrpt::hwdrivers::CCameraSensor.
This class is only available when compiling MRPT with the flag “MRPT_HAS_OPENCV” defined.
Some code is based on the class CaptureCamera from the Orocos project.
See also:
mrpt::hwdrivers::CCameraSensor, CImageGrabber_dc1394
The most generic camera grabber in MRPT: mrpt::hwdrivers::CCameraSensor
#include <mrpt/hwdrivers/CImageGrabber_OpenCV.h> class CImageGrabber_OpenCV { public: // structs struct Impl; // construction CImageGrabber_OpenCV(int cameraIndex = -1, TCameraType cameraType = CAMERA_CV_AUTODETECT, const TCaptureCVOptions& options = TCaptureCVOptions()); CImageGrabber_OpenCV(const std::string& AVI_fileName); // methods bool isOpen() const; bool getObservation(mrpt::obs::CObservationImage& out_observation); };
Construction
CImageGrabber_OpenCV(int cameraIndex = -1, TCameraType cameraType = CAMERA_CV_AUTODETECT, const TCaptureCVOptions& options = TCaptureCVOptions())
Constructor for cameras:
Parameters:
cameraIndex |
Set the camera index, or -1 if it does not matter and you select AUTODETECT as cameraType. |
cameraType |
Can be any value of TCameraType, or CAMERA_CV_AUTODETECT if there is only one camera. |
options |
Capture options, defined in mrpt::hwdrivers::TCaptureCVOptions. If not provided, all the default options will be used. |
CImageGrabber_OpenCV(const std::string& AVI_fileName)
Constructor for AVI files:
Methods
bool isOpen() const
Check whether the camera has been open successfully.
bool getObservation(mrpt::obs::CObservationImage& out_observation)
Grab an image from the opened camera.
Parameters:
out_observation |
The object to be filled with sensed data. |
Returns:
false on any error, true if all go fine.