Skip to content

Instantly share code, notes, and snippets.

@jpzhu
Created August 8, 2013 02:49
Show Gist options
  • Save jpzhu/6181031 to your computer and use it in GitHub Desktop.
Save jpzhu/6181031 to your computer and use it in GitHub Desktop.
video for linux 2, v4l. v4l2 demo code.
#include <linux/videodev2.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
int main(int argc, char **argv)
{
int i, ctrl, fd = open(argc > 1 ? argv[1] : "/dev/video0", O_RDWR);
if(fd < 0) {
perror("open failed");
return 1;
}
struct v4l2_queryctrl qc;
for(ctrl=V4L2_CID_BASE; /**/; ctrl = qc.id) {
memset(&qc, 0, sizeof(qc));
qc.id = ctrl | V4L2_CTRL_FLAG_NEXT_CTRL;
if(ioctl(fd, VIDIOC_QUERYCTRL, &qc))
break;
printf("ctrl %0xx \"%s\" [%d,%d]@%d def %d flags 0x%x\n",
qc.id, qc.name, qc.minimum, qc.maximum, qc.step,
qc.default_value, qc.flags);
}
return 0;
}
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment