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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.