RGB24 and BGR24 cleanup (#1749)

* RGB24 and BGR24 cleanup

* Fix MF-Grabber

* Add BGR32 to V42L Grabber

* Add BGR32 to V42L Grabber

* Add BGR16 to V42L

* Revert "Add BGR16 to V42L"

This reverts commit 42975380f4.
This commit is contained in:
LordGrey
2024-06-01 20:26:20 +02:00
committed by GitHub
parent 76fff98f5c
commit 15c305b8f2
4 changed files with 62 additions and 12 deletions

View File

@@ -54,6 +54,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(ControlIDPropertyMap, _controlIDPropertyMap, (initCont
static PixelFormat GetPixelFormat(const unsigned int format)
{
if (format == V4L2_PIX_FMT_RGB32) return PixelFormat::RGB32;
if (format == V4L2_PIX_FMT_BGR32) return PixelFormat::BGR32;
if (format == V4L2_PIX_FMT_RGB24) return PixelFormat::RGB24;
if (format == V4L2_PIX_FMT_BGR24) return PixelFormat::BGR24;
if (format == V4L2_PIX_FMT_YUYV) return PixelFormat::YUYV;
if (format == V4L2_PIX_FMT_UYVY) return PixelFormat::UYVY;
@@ -557,6 +559,14 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB32;
break;
case PixelFormat::BGR32:
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_BGR32;
break;
case PixelFormat::RGB24:
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24;
break;
case PixelFormat::BGR24:
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_BGR24;
break;
@@ -691,6 +701,22 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
}
break;
case V4L2_PIX_FMT_BGR32:
{
_pixelFormat = PixelFormat::BGR32;
_frameByteSize = _width * _height * 4;
Debug(_log, "Pixel format=BGR32");
}
break;
case V4L2_PIX_FMT_RGB24:
{
_pixelFormat = PixelFormat::RGB24;
_frameByteSize = _width * _height * 3;
Debug(_log, "Pixel format=RGB24");
}
break;
case V4L2_PIX_FMT_BGR24:
{
_pixelFormat = PixelFormat::BGR24;
@@ -699,7 +725,6 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
}
break;
case V4L2_PIX_FMT_YUYV:
{
_pixelFormat = PixelFormat::YUYV;
@@ -743,9 +768,9 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
default:
#ifdef HAVE_TURBO_JPEG
throw_exception("Only pixel formats RGB32, BGR24, YUYV, UYVY, NV12, I420 and MJPEG are supported");
throw_exception("Only pixel formats RGB32, BGR32, RGB24, BGR24, YUYV, UYVY, NV12, I420 and MJPEG are supported");
#else
throw_exception("Only pixel formats RGB32, BGR24, YUYV, UYVY, NV12 and I420 are supported");
throw_exception("Only pixel formats RGB32, BGR32, RGB24, BGR24, YUYV, UYVY, NV12 and I420 are supported");
#endif
return;
}