Peter_Pi
Posts: 2
Joined: Sat Nov 23, 2013 7:57 pm

Using lower resolution on Pi with USB WebCam

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!

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Using lower resolution on Pi with USB WebCam

Sat Nov 30, 2013 2:22 pm

Take a look at the guvcview source code, you should be able to find where they get that working and borrow their code.

http://sourceforge.net/p/guvcview/git-m ... ster/tree/
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “General discussion”