5

I've followed this tutorial to install OpenCV 2.3.1 in raspberry and it has worked fine. I've also installed from here the uv4l raspicam driver. But now I need to modify some capture properties as the width and the height of the frames. So I've tried with:

import cv2
cv2.namedWindow("preview")
vc = cv2.VideoCapture(0) #assigned by the uv4l driver
vc.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH,640.0)
vc.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT,480.0)
if vc.isOpened():
 rval, frame = vc.read()
else:
 rval = False
while rval:
 cv2.imshow("preview", frame)
 rval, frame = vc.read()
 key = cv2.waitKey(33)
 if key == 27:
 break

but in the linux-shell it returns:

HIGHGUI ERROR: V4L: Initial Capture Error: Unable to load initial memory buffers

So I've tried also to edit those properties in the Idle shell with:

>>import cv2
>>vc = cv2.VideoCapture(0)
>>prop = vc.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)

it returns me always 64.0 (the default width), and when I try with:

>>prop = vc.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, 640.0)

it returns False

How can I set my resolution? Thanks

asked Dec 14, 2014 at 22:47

1 Answer 1

1

In order to set the height and width:

vc.set(3,640)
vc.set(4,480)

Where 640x480 is you resolution. This is just another way to what you're doing right now, so I doubt there will a different result.


The main issue with this is that not all cameras support all OpenCV parameters, and there's no real way to fix that without new hardware.


Also since you're compiling from source (as the tutorial indicates), there's a change that there was an issue when compiling or in the conf file. I'd try using the packages in the official repository and see if it works. To install:

sudo apt-get install libopencv-dev python-opencv

And since numpy is used in most places of OpenCV's python bindings:

sudo apt-get install python-numpy

I just did a just bit of research into your exact error and it could be driver based. The last post here, shows that you might want to try a alternative driver.

answered Feb 10, 2015 at 1:00

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.