我用脚本设置了view mode 4 ,但是通过如下代码获取摄像头的设置,发现设置右变回 view mode 1
//3. set form of acquisition
struct v4l2_format vfmt;
// vfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
// vfmt.fmt.pix.width = 2592;
// vfmt.fmt.pix.height = 1944;
// vfmt.fmt.pix.field = V4L2_FIELD_ANY;
// vfmt.fmt.pix.pixelformat = V4L2_PIX_FMT_UYVY;
//
// int ret = ioctl(fd, VIDIOC_S_FMT, &vfmt);
// if(ret < 0){
// perror("set form fail!");
// }
//
memset(&vfmt, 0, sizeof(vfmt));
vfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
ret = ioctl(fd, VIDIOC_G_FMT, &vfmt);
if(ret < 0){
perror("get form fail!");
}
printf("width = %d\n", vfmt.fmt.pix.width);
printf("height = %d\n", vfmt.fmt.pix.height);
unsigned char *p = (unsigned char *)&vfmt.fmt.pix.pixelformat;
printf("pixelformat=%c%c%c%c\n", p[0], p[1], p[2], p[3]);
// printf("pixelformat = %d\n", vfmt.fmt.pix.pixelformat);