Usb camera resolution problem
I'm using logitech c270 cam with opencv 3.0.
The aim is to capture a frame and save it as jpg. It works great, but i can't change frame width/height. It's always 640x480 (tried bigger and smaller sizes).
Function VideoCapture.set(CAP_PROP_FRAME_WIDTH, val)
always returns false
.
Some steps:
- Changed the resolution with
v4l2-ctl --set-fmt-video
, but after launching my program, all settings are gone back to 640x480. - Test the same thing via
fswebcam --save -r 1280x960
and finally got image with needed sizes - Checked
v4l2-ctl --get-fmt-video
. There are correct values
It looks like opencv always sets default resolution and not provides opportunity to change it.
OpenCV only returns false if the used backend lib is not supported/allowed by your camera to change the resolution of the camera. Basically go into debug and report back which cap mechanism is used by OpenCV internally (look for the cap_ something file and gives us the something). Also make sure that you change these settings before grabbing frames or opening the camera.
Thank you or your answer. Could you please provide a bit more details? What you mean 'go into debug'? Are there any opencv logs or smting like that?
If you build OpenCV yourself in debug mode and not in release, then you can use the debug files to use your debugger to step into the OpenCV source code. This allows you to see what backend of the VideoCapture is used on your system.