Ask Your Question

How to set resolution of video capture in python with Logitech c910 & c920

asked 2012-09-04 13:24:48 -0600

Mike Lawrence gravatar image

I have two webcams, Logitech c910 and c920. When I use the python interface to opencv2.4.1 on Ubuntu 12.04, I cannot seem to change the width or height of the capture from either camera. For example, if I run the code:

import cv2
cam = cv2.VideoCapture(-1)

I get a 640x480 image/numpy array. However, if I try to run:

import cv2
cam = cv2.VideoCapture(-1)

I first get the printout False after each attempt to set the resolution, and then the console hangs when it gets to

On the other hand, when I run the above on my mac, everything works fine and I get the expected 1920x1080 image/numpy array.

Getting this working with Ubuntu is really mission critical for me, so any help would be greatly appreciated!

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2012-10-05 11:54:57 -0600

karlphillip gravatar image

Unfortunately, setting the size of the capture doesn't always work. One of the reasons being that sometimes the camera simply doesn't support the dimensions you are trying to set.

According to this thread, you can try to use the old python interface (something like this):

from import *  
from opencv.highgui import *

capture = cvCreateCameraCapture(0)

cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640)
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480)

If this approach doesn't work, you'll have to resize the captured frame yourself! Check cv2.resize()

edit flag offensive delete link more

answered 2013-08-20 02:11:05 -0600

NikolasE gravatar image

I have had the same problem and solved it by upgrading to the dev-version of opencv (2.9).

edit flag offensive delete link more


This is because a fix was probably supplied. However it is weird it doesn't work for 2.4 then, since the version is influenced also. Maybe look for the corresponding bug report and mention that the fix doesn't work for 2.4.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-21 02:21:08 -0600 )edit

Question Tools



Asked: 2012-09-04 13:24:48 -0600

Seen: 72,860 times

Last updated: Aug 20 '13