一、V4L2 获取和配置摄像头程序示例:
#include #include #include #include #include #include #include #includeint fd;
const char *input_dev = "/dev/video0";
const char *qctrl_name = NULL;
int qctrl_value = 0;
struct v4l2_capability cap;
struct v4l2_queryctrl qctrl;
static void print_qctrl(struct v4l2_queryctrl *qctrl)
{
struct v4l2_control ctrl;
ctrl.id = qctrl->id;
if (ioctl(fd, VIDIOC_G_CTRL, &ctrl) < 0)
{
perror("get ctrl failed");
ctrl.value = -999;
}
printf("%-14s : id=%08x, type=%d, minimum=%d, maximum=%d\n"
"\t\t value = %d, step=%d, default_value=%d\n",
qctrl->name, qctrl->id, qctrl->type, qctrl->minimum, qctrl->maximum,
ctrl.value, qctrl->step, qctrl->default_v