Created
August 8, 2013 02:49
-
-
Save jpzhu/6181031 to your computer and use it in GitHub Desktop.
video for linux 2, v4l. v4l2 demo code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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