V4L2编程 VIDIOC_ENUM_FMT 获取摄像头格式问题,求高手帮助!

Xiao_ZJ Xiao_ZJ 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
大家好,我在做一个摄像头的毕业设计,但是用到VIDIOC_ENUM_FMT的时候,那个摄像头就显示还有YUV格式,但是我在PC上面用luvcview -L 查看下支持格式,他竟然显示了很多格式,连RGB都有,搞了1个多月都不知道什么问题!是内核问题?驱动?还是我程序有问题啊,求助!!


static int GetVideo_Support_fmt(pVd vd)
{
struct v4l2_fmtdesc fmt_desc;
int ret = -1;

memset(&fmt_desc, 0, sizeof(struct v4l2_fmtdesc));
fmt_desc.index=0;
fmt_desc.type= vd->type; //V4L2_BUF_TYPE_VIDEO_CAPTURE;

printf("Support format:\n");
while(ioctl(vd->fd, VIDIOC_ENUM_FMT, &fmt_desc) != -1)
{
fmt_desc.index++;
printf("\t%d.%s\n",fmt_desc.index,fmt_desc.description);
printf("{ pixelformat = ''%c%c%c%c'', description = ''%s'' }\n", \
fmt_desc.pixelformat & 0xFF, \
(fmt_desc.pixelformat >> 8) & 0xFF, \
(fmt_desc.pixelformat >> 16) & 0xFF, \
(fmt_desc.pixelformat >> 24) & 0xFF,\
fmt_desc.description);
ret = enum_frame_sizes(vd->fd , fmt_desc.pixelformat);
if (ret != 0)
printf("Unable to enumerate frame sizes\n");
}
//printf("\n");
if(errno != EINVAL) {
printf("error num:%d",errno);
perror("ERROR enumerating frame formats:");
// return (-1);
}
return 0;
}
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
Xiao_ZJ
Linux/Unix社区 23,224 成员 74,535 内容