用以下语句,得到的摄像头采集支持的格式是 pixelformat = ”MJPG“,description = ”MJPEG“。
memset(&fmt, 0, sizeof(fmt));
struct v4l2_fmtdesc fmt;
fmt.index = 0;
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
while ((ret = ioctl(cam_c_fp, VIDIOC_ENUM_FMT, &fmt)) == 0)
{
fmt.index++;
printf("{ pixelformat = ''%c%c%c%c'', description = ''%s'' }\n\n\n",
fmt.pixelformat & 0xFF, (fmt.pixelformat >> 8) & 0xFF, (fmt.pixelformat >> 16) & 0xFF,(fmt.pixelformat >> 24) & 0xFF, fmt.description);
}
这样是不是说,摄像头即使设置为YUV也不行??因为我设置了codec_fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUY420;但设置返回V4L2 : ioctl on VIDIOC_S_FMT failled。
memset ( &codec_fmt, 0, sizeof(codec_fmt) );
codec_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
ret = ioctl(cam_c_fp , VIDIOC_G_FMT, &codec_fmt);
if (ret < 0) {
printf("V4L2 : ioctl on VIDIOC_G_FMT failled\n");
exit(1);
}
codec_fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420;
ret = ioctl(cam_c_fp , VIDIOC_S_FMT, &codec_fmt);
if (ret < 0) {
printf("V4L2 : ioctl on VIDIOC_S_FMT failled\n");
exit(1);
}
或者,不知哪位高手有MJPG转为YUV的程序呢?
急求帮助!!谢谢!!!