43 #include <visp3/sensor/vpOpenCVGrabber.h>
45 #if ( defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION < 0x020408))
47 #include <visp3/core/vpImageConvert.h>
48 #include <visp3/core/vpFrameGrabberException.h>
56 vpOpenCVGrabber::vpOpenCVGrabber()
57 : capture(NULL), DeviceType(0), flip(false)
72 vpOpenCVGrabber::~vpOpenCVGrabber( )
81 void vpOpenCVGrabber::open()
84 capture = cvCreateCameraCapture(DeviceType);
95 "Initialization not done : camera already used or no camera found") );
144 "Initialization not done") );
147 cvGrabFrame(capture);
148 im = cvRetrieveFrame(capture);
168 "Initialization not done") );
171 cvGrabFrame(capture);
172 im = cvRetrieveFrame(capture);
184 IplImage* vpOpenCVGrabber::acquire()
192 "Initialization not done") );
195 cvGrabFrame(capture);
196 im = cvRetrieveFrame(capture);
203 void vpOpenCVGrabber::close()
206 cvReleaseCapture( &capture );
217 void vpOpenCVGrabber::getFramerate(
double & framerate)
219 framerate = cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
229 void vpOpenCVGrabber::setFramerate(
const double framerate)
231 cvSetCaptureProperty(capture, CV_CAP_PROP_FPS, framerate);
245 void vpOpenCVGrabber::setWidth(
const unsigned int w)
247 if ( cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, w))
252 "Impossible to set the size of the grabber") );
268 void vpOpenCVGrabber::setHeight(
const unsigned int h)
270 if ( cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, h))
275 "Impossible to set the size of the grabber") );
295 void vpOpenCVGrabber::setDeviceType(
int type)
299 if ( DeviceType != 0 && DeviceType != 100 &&DeviceType != 200 && DeviceType != 300)
301 vpTRACE(
"The expected type of device may be unknown.");
315 void vpOpenCVGrabber::setFlip(
bool flipType)
320 #elif !defined(VISP_BUILD_SHARED_LIBS)
322 void dummy_vpOpenCVGrabber() {};
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
Error that can be emited by the vpFrameGrabber class and its derivates.
unsigned int height
Number of rows in the image.
bool init
Set to true if the frame grabber has been initialized.
unsigned int width
Number of columns in the image.