关于V4l2设置分辨率失败
-
我在使用V4l2获取图像时,使用了如下命令设置分辨率:
struct v4l2_format fmt;
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
ioctl(priv->fd,VIDIOC_G_FMT,&fmt);
printf("width : %d,height : %d\n",fmt.fmt.pix.width,fmt.fmt.pix.height);
printf("field : %d,bytesperline : %d\n",fmt.fmt.pix.field,fmt.fmt.pix.bytesperline);
printf("sizeimage : %d,flags : %d\n",fmt.fmt.pix.sizeimage,fmt.fmt.pix.flags);
printf("pixelformat : %d,quantization : %d\n",fmt.fmt.pix.pixelformat,fmt.fmt.pix.quantization);
fmt.fmt.pix.width = USERWIDTH;
fmt.fmt.pix.height = USERHEIGHT;
ioctl(priv->fd,VIDIOC_S_FMT,&fmt);
ioctl(priv->fd,VIDIOC_G_FMT,&fmt);
printf("width : %d,height : %d\n",fmt.fmt.pix.width,fmt.fmt.pix.height);
printf("field : %d,bytesperline : %d\n",fmt.fmt.pix.field,fmt.fmt.pix.bytesperline);
printf("sizeimage : %d,flags : %d\n",fmt.fmt.pix.sizeimage,fmt.fmt.pix.flags);
printf("pixelformat : %d,quantization : %d\n",fmt.fmt.pix.pixelformat,fmt.fmt.pix.quantization);结果生成的图像并不符合我的期望,如,我设置了640480的分辨率,fmt.fmt.pix.sizeimage应该为614400,但实际查询值为1228800,解码也是按1280480解才能正常显示,左边是我的图像但是右边是640*480的纯绿色色块,请问我需要设置什么值才能使他正常
-
@robot
你好,请问你用的哪款摄像头模组,用的什么主控平台? -
@veye_xumm
cssc132相机,jeston nano平台
我已找到有问题的参数为fmt.fmt.pix.bytesperline = USERWIDTH;
问题已解决,谢谢了 -
@robot 点赞! 不客气~
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login