44 #include <visp3/sensor/vpOpenCVGrabber.h> 46 #if (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION < 0x020408)) 48 #include <visp3/core/vpFrameGrabberException.h> 49 #include <visp3/core/vpImageConvert.h> 57 vpOpenCVGrabber::vpOpenCVGrabber() : capture(NULL), DeviceType(0), flip(false)
71 vpOpenCVGrabber::~vpOpenCVGrabber() {
close(); }
76 void vpOpenCVGrabber::open()
79 capture = cvCreateCameraCapture(DeviceType);
81 if (capture != NULL) {
88 "Initialization not done : camera already used or no camera found"));
129 cvGrabFrame(capture);
130 im = cvRetrieveFrame(capture);
151 cvGrabFrame(capture);
152 im = cvRetrieveFrame(capture);
164 IplImage *vpOpenCVGrabber::acquire()
173 cvGrabFrame(capture);
174 im = cvRetrieveFrame(capture);
181 void vpOpenCVGrabber::close()
184 cvReleaseCapture(&capture);
194 void vpOpenCVGrabber::getFramerate(
double &framerate) { framerate = cvGetCaptureProperty(capture, CV_CAP_PROP_FPS); }
202 void vpOpenCVGrabber::setFramerate(
const double framerate)
204 cvSetCaptureProperty(capture, CV_CAP_PROP_FPS, framerate);
217 void vpOpenCVGrabber::setWidth(
const unsigned int w)
219 if (cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, w)) {
223 "Impossible to set the size of the grabber"));
239 void vpOpenCVGrabber::setHeight(
const unsigned int h)
241 if (cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, h)) {
245 "Impossible to set the size of the grabber"));
265 void vpOpenCVGrabber::setDeviceType(
int type)
269 if (DeviceType != 0 && DeviceType != 100 && DeviceType != 200 && DeviceType != 300) {
270 vpTRACE(
"The expected type of device may be unknown.");
285 void vpOpenCVGrabber::setFlip(
bool flipType) { flip = flipType; }
287 #elif !defined(VISP_BUILD_SHARED_LIBS) 290 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.