I am trying to get images from my webcam using Python code that imports OpenCV. The code is as follows:
import sys sys.path.append("C:\\opencv\\build\\python\\2.7") import cv2 import cv2.cv as cv import time # Set resolution cap = cv2.VideoCapture(0) print "Frame default resolution: (" + str(cap.get(cv.CV_CAP_PROP_FRAME_WIDTH)) + "; " + str(cap.get(cv.CV_CAP_PROP_FRAME_HEIGHT)) + ")" cap.set(cv.CV_CAP_PROP_FRAME_WIDTH, 800) cap.set(cv.CV_CAP_PROP_FRAME_HEIGHT, 600) print "Frame resolution set to: (" + str(cap.get(cv.CV_CAP_PROP_FRAME_WIDTH)) + "; " + str(cap.get(cv.CV_CAP_PROP_FRAME_HEIGHT)) + ")" # Acquire frame capture = cv.CreateCameraCapture(0) img = cv.QueryFrame(capture)
The code works fine, except that the default resolution for the camera is 640x480, and my code seems to only be able to set resolution values โโbelow this. For example, I can set the image size to 320x240, but I cannot change it to 800x600. I have no error: just the resolution is set to the default value (640x480) as I try to set it to higher values.
The camera I use (no other webcam is connected to the computer) is QuickCam V-UBK45: with the software provided by Logitech, I can shoot in full resolution (1280x960) and in all intermediate ones (for example, 800x600).
Therefore, the sizes of these frames are supported from the hardware, but my code cannot access them.
Does anyone know what I can do?
source share