From f4b06ac0af494206743189ebad570784cd7797b5 Mon Sep 17 00:00:00 2001 From: Alberto Panizzo Date: Sat, 6 Jul 2013 18:27:43 +0200 Subject: [PATCH] V4L2Camera: Check that the camera accept the frame size as well not only the pixel format USB UVC cameras may support different frame size sets for different pixel formats. So do not limitate to check that the current format is supported and then set the frame size but check that this frame size _with_ this pixel format works. Real case is a camera that accepts only QCIF in YUYV but can do VGA in MJPEG Signed-off-by: Alberto Panizzo --- V4L2Camera.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/V4L2Camera.cpp b/V4L2Camera.cpp index 70536ff..2a2b8cb 100644 --- a/V4L2Camera.cpp +++ b/V4L2Camera.cpp @@ -205,7 +205,9 @@ int V4L2Camera::Init(int width, int height, int fps) videoIn->format.fmt.pix.pixelformat = pixFmtsOrder[i].fmt; ret = ioctl(fd, VIDIOC_TRY_FMT, &videoIn->format); - if (ret >= 0) { + if (ret >= 0 && + videoIn->format.fmt.pix.width == (uint)closest.getWidth() && + videoIn->format.fmt.pix.height == (uint)closest.getHeight()) { break; } } -- 2.11.0