@@ -79,12 +79,13 @@ namespace
7979static const V4L2Grabber::HyperHdrFormat supportedFormats[] =
8080{
8181 { V4L2_PIX_FMT_YUYV, PixelFormat::YUYV },
82+ { V4L2_PIX_FMT_UYVY, PixelFormat::UYVY },
8283 { V4L2_PIX_FMT_XRGB32, PixelFormat::XRGB },
8384 { V4L2_PIX_FMT_RGB24, PixelFormat::RGB24 },
8485 { V4L2_PIX_FMT_YUV420, PixelFormat::I420 },
8586 { V4L2_PIX_FMT_NV12, PixelFormat::NV12 },
8687 { V4L2_PIX_FMT_MJPEG, PixelFormat::MJPEG },
87- { V4L2_PIX_FMT_P010, PixelFormat::P010 }
88+ { V4L2_PIX_FMT_P010, PixelFormat::P010 }
8889};
8990
9091
@@ -147,7 +148,7 @@ void V4L2Grabber::setHdrToneMappingEnabled(int mode)
147148 {
148149 Debug (_log, " setHdrToneMappingMode replacing LUT and restarting" );
149150 _V4L2WorkerManager.Stop ();
150- if ((_actualVideoFormat == PixelFormat::YUYV) || (_actualVideoFormat == PixelFormat::I420) || (_actualVideoFormat == PixelFormat::NV12)
151+ if ((_actualVideoFormat == PixelFormat::YUYV) || (_actualVideoFormat == PixelFormat::UYVY) || (_actualVideoFormat == PixelFormat:: I420) || (_actualVideoFormat == PixelFormat::NV12)
151152 || (_actualVideoFormat == PixelFormat::P010) || (_actualVideoFormat == PixelFormat::MJPEG))
152153 loadLutFile (PixelFormat::YUYV);
153154 else
@@ -577,6 +578,28 @@ void V4L2Grabber::enumerateV4L2devices(bool silent)
577578 }
578579 }
579580
581+ if (properties.valid .size () == 0 && devName == " /dev/video0" )
582+ {
583+ DevicePropertiesItem di;
584+ di.x = fmt.fmt .pix .width ;
585+ di.y = fmt.fmt .pix .height ;
586+ di.fps = 0 ;
587+ di.pf = identifyFormat (fmt.fmt .pix .pixelformat );
588+ di.v4l2PixelFormat = fmt.fmt .pix .pixelformat ;
589+ di.input = inputIndex;
590+
591+ QString pixelFormat = pixelFormatToString (di.pf );
592+ if (di.pf == PixelFormat::NO_CHANGE)
593+ {
594+ Debug (_log, " %s %d x %d @ %d fps %s (unsupported)" , QSTRING_CSTR (properties.name ), di.x , di.y , di.fps , QSTRING_CSTR (pixelFormat));
595+ }
596+ else
597+ {
598+ Debug (_log, " %s %d x %d @ %d fps %s, input = %i (seems supported, device not fully compatible with v4l2 grabber model, frame rate is unknown)" , QSTRING_CSTR (properties.name ), di.x , di.y , di.fps , QSTRING_CSTR (pixelFormat), di.input );
599+ properties.valid .append (di);
600+ }
601+ }
602+
580603 _deviceProperties.insert (realName, properties);
581604
582605 if (!silent)
@@ -904,7 +927,7 @@ bool V4L2Grabber::init_device(QString selectedDeviceName, DevicePropertiesItem p
904927
905928 streamparms.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
906929 // Check that the driver knows about framerate get/set
907- if (xioctl (VIDIOC_G_PARM, &streamparms) >= 0 )
930+ if (props. fps > 0 && xioctl (VIDIOC_G_PARM, &streamparms) >= 0 )
908931 {
909932 // Check if the device is able to accept a capture framerate set.
910933 if (streamparms.parm .capture .capability == V4L2_CAP_TIMEPERFRAME)
@@ -918,6 +941,13 @@ bool V4L2Grabber::init_device(QString selectedDeviceName, DevicePropertiesItem p
918941 Info (_log, " Set framerate to %d FPS" , streamparms.parm .capture .timeperframe .denominator );
919942 }
920943 }
944+ else
945+ {
946+ if (props.fps == 0 )
947+ Warning (_log, " The device doesnt report frame rate settings" );
948+ else
949+ Error (_log, " The device doesnt support VIDIOC_G_PARM for frame rate settings" );
950+ }
921951
922952 // set the line length
923953 _lineLength = fmt.fmt .pix .bytesperline ;
@@ -974,6 +1004,15 @@ bool V4L2Grabber::init_device(QString selectedDeviceName, DevicePropertiesItem p
9741004 }
9751005 break ;
9761006
1007+ case V4L2_PIX_FMT_UYVY:
1008+ {
1009+ loadLutFile (PixelFormat::YUYV);
1010+ _actualVideoFormat = PixelFormat::UYVY;
1011+ _frameByteSize = props.x * props.y * 2 ;
1012+ Info (_log, " Video pixel format is set to: UYVY" );
1013+ }
1014+ break ;
1015+
9771016 case V4L2_PIX_FMT_XRGB32:
9781017 {
9791018 loadLutFile (PixelFormat::RGB24);
@@ -1209,10 +1248,11 @@ bool V4L2Grabber::process_image(v4l2_buffer* buf, const void* frameImageBuffer,
12091248 {
12101249 V4L2Worker* _workerThread = _V4L2WorkerManager.workers [i];
12111250
1212- if ((_actualVideoFormat == PixelFormat::YUYV || _actualVideoFormat == PixelFormat::I420 ||
1251+ if ((_actualVideoFormat == PixelFormat::YUYV || _actualVideoFormat == PixelFormat::UYVY || _actualVideoFormat == PixelFormat:: I420 ||
12131252 _actualVideoFormat == PixelFormat::NV12 || _hdrToneMappingEnabled) && !_lutBufferInit)
12141253 {
1215- if ((_actualVideoFormat == PixelFormat::YUYV) || (_actualVideoFormat == PixelFormat::I420) || (_actualVideoFormat == PixelFormat::NV12) || (_actualVideoFormat == PixelFormat::MJPEG))
1254+ if ((_actualVideoFormat == PixelFormat::YUYV) || (_actualVideoFormat == PixelFormat::UYVY) || (_actualVideoFormat == PixelFormat::I420) ||
1255+ (_actualVideoFormat == PixelFormat::NV12) || (_actualVideoFormat == PixelFormat::MJPEG))
12161256 {
12171257 loadLutFile (PixelFormat::YUYV, true );
12181258 }
0 commit comments