Tomáš Zato Tomáš Zato -4 years ago 87
C++ Question

Configuring camera properties in new OCV 2.4.3

I may just be googling wrong, but I cannot find out a way (read function) to change properties of camera in the new Open CV. I need to disable auto exposure and auto gain of the camera.

Is that even possible?

Answer Source

This is an old question but I want to add a solution to this.

opencv calls underlying v4l methods to query frames, set/get camera properties etc. And the problem is, the calls are not complete. Also for some reason, the library calls v4l methods instead of v4l2 ones. Similar issue here. It is solved through modifying opencv code, it seems.

I also checked if opencv can set a property supported in v4l2 -like "manual exposure", "or exposure auto priority". It couldn't. I played around v4l2 to solve this:

#include <libv4l2.h>
#include <linux/videodev2.h>
#include <sys/ioctl.h>
#include <fcntl.h>

// open capture
int descriptor = v4l2_open("/dev/video0", O_RDWR);

// manual exposure control
v4l2_control c; = V4L2_CID_EXPOSURE_AUTO;
if(v4l2_ioctl(descriptor, VIDIOC_S_CTRL, &c) == 0)
    cout << "success";

// auto priority control = V4L2_CID_EXPOSURE_AUTO_PRIORITY;
c.value = 0;
if(v4l2_ioctl(descriptor, VIDIOC_S_CTRL, &c) == 0)
    cout << "success";

You can then work with opencv.

Full list of camera controls are here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download