3

I'm using the OpenCV python bindings to put together a quick script/prototype, but for some odd reason,

camera.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, 640.0) 

...does nothing at all. By this, I mean it returns True, but the frame height is constant. No, returning a constant is not a fault, as camera.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT) will return 240.0 as the default value.

I don't have any clue on why is this failing. Any ideas?

For what it's worth, I'm running this code on windows 8.1.

DavidG
  • 24,279
  • 14
  • 89
  • 82
grenadier
  • 383
  • 1
  • 3
  • 6

2 Answers2

1

It's often not possible to change the camera settings through openCV.

It depends on how well the camera implements the interface to Microsoft's Directshow. Since Directshow is difficult to understand, poorly documented and hard to test and cameras are cheaply made.....

Martin Beckett
  • 94,801
  • 28
  • 188
  • 263
  • @grenadier can you change the size in any util/viewer that came with the camera? You might also have to select another image format if it is a USB camera, it migth not be able to send full res at full speed – Martin Beckett Dec 05 '13 at 00:08
  • @MartinBeckett +1 Nice answer. Maybe you could add a link to [this answer](http://stackoverflow.com/q/14287/176769) if you think it is relevant. – karlphillip Dec 05 '13 at 00:25
  • @karlphillip - don't know if that answer is still relevant. I submitted a bunch of fixes to 2.4 to allow opencv to set all the parameters if directshow actually implements it – Martin Beckett Dec 05 '13 at 00:49
  • Just to get back to your first comment: Setting the resolution in OpenCV on windows works on most webcams (at least all the ones I have used so far worked). Make sure the right drivers are installed. – littleimp Dec 05 '13 at 14:13
1

You have to set both WIDTH and HEIGHT in order to change camera resolution. Some says that changing the height automatically adjusts the width, but this did not worked for me.

See my other answer on this topic.

Community
  • 1
  • 1
asif
  • 975
  • 8
  • 16