manual focus with usb_cam
Hi all,
I would like to know how I could manually set the focal length. I know that I can set the autofocus option to false in the launchfile of the usb_cam package but where or how can I use the camera then?
Because now just everything is blurry and I don't know where to start looking. Thank you.
EDIT I found that there is a different in the binary (which doesen't have the option) and the installation from source (which offers the option in the launchfile). I looked up the libusb source code and I found the following at the end but I have no idea how to enable/disable or to set the focus manually.
// enables/disables auto focus
void usb_cam_camera_set_auto_focus(int value)
{
struct v4l2_queryctrl queryctrl;
struct v4l2_ext_control control;
memset(&queryctrl, 0, sizeof(queryctrl));
queryctrl.id = V4L2_CID_FOCUS_AUTO;
if (-1 == xioctl(fd, VIDIOC_QUERYCTRL, &queryctrl)) {
if (errno != EINVAL) {
perror("VIDIOC_QUERYCTRL");
return;
} else {
printf("V4L2_CID_FOCUS_AUTO is not supported\n");
return;
}
} else if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
printf("V4L2_CID_FOCUS_AUTO is not supported\n");
return;
} else {
memset(&control, 0, sizeof(control));
control.id = V4L2_CID_FOCUS_AUTO;
control.value = value;
if (-1 == xioctl(fd, VIDIOC_S_CTRL, &control)) {
perror("VIDIOC_S_CTRL");
return;
}
}
}