MRPT  1.9.9
mrpt::hwdrivers::CImageGrabber_OpenCV Class Reference

Detailed Description

A class for grabing 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.

Note
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

Definition at line 73 of file CImageGrabber_OpenCV.h.

#include <mrpt/hwdrivers/CImageGrabber_OpenCV.h>

Public Member Functions

 CImageGrabber_OpenCV (int cameraIndex=-1, TCameraType cameraType=CAMERA_CV_AUTODETECT, const TCaptureCVOptions &options=TCaptureCVOptions())
 Constructor for cameras: More...
 
 CImageGrabber_OpenCV (const std::string &AVI_fileName)
 Constructor for AVI files: More...
 
virtual ~CImageGrabber_OpenCV ()
 Destructor. More...
 
bool isOpen () const
 Check whether the camera has been open successfully. More...
 
bool getObservation (mrpt::obs::CObservationImage &out_observation)
 Grab an image from the opened camera. More...
 

Protected Attributes

bool m_bInitialized
 Set to false if we could not initialize the camera. More...
 
mrpt::void_ptr_noncopy m_capture
 Internal use: More...
 

Constructor & Destructor Documentation

◆ CImageGrabber_OpenCV() [1/2]

CImageGrabber_OpenCV::CImageGrabber_OpenCV ( int  cameraIndex = -1,
TCameraType  cameraType = CAMERA_CV_AUTODETECT,
const TCaptureCVOptions options = TCaptureCVOptions() 
)

Constructor for cameras:

Parameters
cameraIndexSet the camera index, or -1 if it does not matter and you select AUTODETECT as cameraType.
cameraTypeCan be any value of TCameraType, or CAMERA_CV_AUTODETECT if there is only one camera.
optionsCapture options, defined in mrpt::hwdrivers::TCaptureCVOptions. If not provided, all the default options will be used.

Definition at line 27 of file CImageGrabber_OpenCV.cpp.

References mrpt::hwdrivers::CAMERA_CV_AUTODETECT, mrpt::hwdrivers::CAMERA_CV_DC1394, mrpt::hwdrivers::CAMERA_CV_DSHOW, mrpt::hwdrivers::CAMERA_CV_MIL, mrpt::hwdrivers::CAMERA_CV_VFL, mrpt::hwdrivers::CAMERA_CV_VFW, mrpt::hwdrivers::TCaptureCVOptions::frame_height, mrpt::hwdrivers::TCaptureCVOptions::frame_width, mrpt::hwdrivers::TCaptureCVOptions::gain, mrpt::hwdrivers::TCaptureCVOptions::ieee1394_fps, mrpt::hwdrivers::TCaptureCVOptions::ieee1394_grayscale, M_CAPTURE, MRPT_END, MRPT_START, THROW_EXCEPTION, and THROW_EXCEPTION_FMT.

◆ CImageGrabber_OpenCV() [2/2]

CImageGrabber_OpenCV::CImageGrabber_OpenCV ( const std::string AVI_fileName)

Constructor for AVI files:

Definition at line 206 of file CImageGrabber_OpenCV.cpp.

References MRPT_END, MRPT_START, and THROW_EXCEPTION.

◆ ~CImageGrabber_OpenCV()

CImageGrabber_OpenCV::~CImageGrabber_OpenCV ( )
virtual

Destructor.

Definition at line 235 of file CImageGrabber_OpenCV.cpp.

References M_CAPTURE.

Member Function Documentation

◆ getObservation()

bool CImageGrabber_OpenCV::getObservation ( mrpt::obs::CObservationImage out_observation)

Grab an image from the opened camera.

Parameters
out_observationThe object to be filled with sensed data.
Returns
false on any error, true if all go fine.

Definition at line 250 of file CImageGrabber_OpenCV.cpp.

References mrpt::obs::CObservationImage::image, M_CAPTURE, MRPT_END, MRPT_START, mrpt::system::now(), mrpt::img::CImage::setFromIplImageReadOnly(), THROW_EXCEPTION, and mrpt::obs::CObservation::timestamp.

◆ isOpen()

bool mrpt::hwdrivers::CImageGrabber_OpenCV::isOpen ( ) const
inline

Check whether the camera has been open successfully.

Definition at line 107 of file CImageGrabber_OpenCV.h.

References m_bInitialized.

Member Data Documentation

◆ m_bInitialized

bool mrpt::hwdrivers::CImageGrabber_OpenCV::m_bInitialized
protected

Set to false if we could not initialize the camera.

Definition at line 78 of file CImageGrabber_OpenCV.h.

Referenced by isOpen().

◆ m_capture

mrpt::void_ptr_noncopy mrpt::hwdrivers::CImageGrabber_OpenCV::m_capture
protected

Internal use:

Definition at line 82 of file CImageGrabber_OpenCV.h.




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020