@@ -79,12 +79,13 @@ namespace
79
79
static const V4L2Grabber::HyperHdrFormat supportedFormats[] =
80
80
{
81
81
{ V4L2_PIX_FMT_YUYV, PixelFormat::YUYV },
82
+ { V4L2_PIX_FMT_UYVY, PixelFormat::UYVY },
82
83
{ V4L2_PIX_FMT_XRGB32, PixelFormat::XRGB },
83
84
{ V4L2_PIX_FMT_RGB24, PixelFormat::RGB24 },
84
85
{ V4L2_PIX_FMT_YUV420, PixelFormat::I420 },
85
86
{ V4L2_PIX_FMT_NV12, PixelFormat::NV12 },
86
87
{ V4L2_PIX_FMT_MJPEG, PixelFormat::MJPEG },
87
- { V4L2_PIX_FMT_P010, PixelFormat::P010 }
88
+ { V4L2_PIX_FMT_P010, PixelFormat::P010 }
88
89
};
89
90
90
91
@@ -147,7 +148,7 @@ void V4L2Grabber::setHdrToneMappingEnabled(int mode)
147
148
{
148
149
Debug (_log, " setHdrToneMappingMode replacing LUT and restarting" );
149
150
_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)
151
152
|| (_actualVideoFormat == PixelFormat::P010) || (_actualVideoFormat == PixelFormat::MJPEG))
152
153
loadLutFile (PixelFormat::YUYV);
153
154
else
@@ -577,6 +578,28 @@ void V4L2Grabber::enumerateV4L2devices(bool silent)
577
578
}
578
579
}
579
580
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
+
580
603
_deviceProperties.insert (realName, properties);
581
604
582
605
if (!silent)
@@ -904,7 +927,7 @@ bool V4L2Grabber::init_device(QString selectedDeviceName, DevicePropertiesItem p
904
927
905
928
streamparms.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
906
929
// 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 )
908
931
{
909
932
// Check if the device is able to accept a capture framerate set.
910
933
if (streamparms.parm .capture .capability == V4L2_CAP_TIMEPERFRAME)
@@ -918,6 +941,13 @@ bool V4L2Grabber::init_device(QString selectedDeviceName, DevicePropertiesItem p
918
941
Info (_log, " Set framerate to %d FPS" , streamparms.parm .capture .timeperframe .denominator );
919
942
}
920
943
}
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
+ }
921
951
922
952
// set the line length
923
953
_lineLength = fmt.fmt .pix .bytesperline ;
@@ -974,6 +1004,15 @@ bool V4L2Grabber::init_device(QString selectedDeviceName, DevicePropertiesItem p
974
1004
}
975
1005
break ;
976
1006
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
+
977
1016
case V4L2_PIX_FMT_XRGB32:
978
1017
{
979
1018
loadLutFile (PixelFormat::RGB24);
@@ -1209,10 +1248,11 @@ bool V4L2Grabber::process_image(v4l2_buffer* buf, const void* frameImageBuffer,
1209
1248
{
1210
1249
V4L2Worker* _workerThread = _V4L2WorkerManager.workers [i];
1211
1250
1212
- if ((_actualVideoFormat == PixelFormat::YUYV || _actualVideoFormat == PixelFormat::I420 ||
1251
+ if ((_actualVideoFormat == PixelFormat::YUYV || _actualVideoFormat == PixelFormat::UYVY || _actualVideoFormat == PixelFormat:: I420 ||
1213
1252
_actualVideoFormat == PixelFormat::NV12 || _hdrToneMappingEnabled) && !_lutBufferInit)
1214
1253
{
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))
1216
1256
{
1217
1257
loadLutFile (PixelFormat::YUYV, true );
1218
1258
}
0 commit comments