Using lower resolution on Pi with USB WebCam
Posted: Sat Nov 30, 2013 12:10 am
Hi,
With OpenCv, because 640 x 480 is too slow on Rpi, I have been trying to use 320 x 240 resolution on Rpi with USB WebCam Logitech c110.
#include <stdio.h>
#include </usr/local/include/opencv2/objdetect/objdetect.hpp>
#include </usr/local/include/opencv2/highgui/highgui.hpp>
#include </usr/local/include/opencv2/imgproc/imgproc.hpp>
#include </usr/local/include/opencv/cv.h>
#include <iostream>
int main(int argc, char** argv){
cvNamedWindow("Camera", CV_WINDOW_AUTOSIZE);
CvCapture* capture = cvCreateCameraCapture(0);
IplImage* frame;
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 320);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 240);
//cvSetCaptureProperty(capture, CV_CAP_PROP_FPS, 10);
while(1){
frame = cvQueryFrame(capture);
if(!frame)break;
cvShowImage("Camera", frame);
char c = cvWaitKey(33);
if(c == 27) break;
}
cvReleaseCapture(&capture);
cvDestroyWindow("Camera");
}
and I execute this with v4l2convert.so library. The program gives this error message, HIGH ERROR: V4L/V4L2: VIDIOC_S_CROP, ane the camera works though its 640 x 320. I know c110 supports 320 x 240 cuz when I run it with gucview, then it works. Seems like I have to change camera setting in some OpenCV code forcefully. The above setting doesn't work.
I am pretty sure that I am not the only one having the same problem. What should I do? This shouldn't be too hard. Need your help!
With OpenCv, because 640 x 480 is too slow on Rpi, I have been trying to use 320 x 240 resolution on Rpi with USB WebCam Logitech c110.
#include <stdio.h>
#include </usr/local/include/opencv2/objdetect/objdetect.hpp>
#include </usr/local/include/opencv2/highgui/highgui.hpp>
#include </usr/local/include/opencv2/imgproc/imgproc.hpp>
#include </usr/local/include/opencv/cv.h>
#include <iostream>
int main(int argc, char** argv){
cvNamedWindow("Camera", CV_WINDOW_AUTOSIZE);
CvCapture* capture = cvCreateCameraCapture(0);
IplImage* frame;
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 320);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 240);
//cvSetCaptureProperty(capture, CV_CAP_PROP_FPS, 10);
while(1){
frame = cvQueryFrame(capture);
if(!frame)break;
cvShowImage("Camera", frame);
char c = cvWaitKey(33);
if(c == 27) break;
}
cvReleaseCapture(&capture);
cvDestroyWindow("Camera");
}
and I execute this with v4l2convert.so library. The program gives this error message, HIGH ERROR: V4L/V4L2: VIDIOC_S_CROP, ane the camera works though its 640 x 320. I know c110 supports 320 x 240 cuz when I run it with gucview, then it works. Seems like I have to change camera setting in some OpenCV code forcefully. The above setting doesn't work.
I am pretty sure that I am not the only one having the same problem. What should I do? This shouldn't be too hard. Need your help!