Merge pull request #21992 from tumicdq:v4l2

* Added support for 4B RGB V4L2 pixel formats

Added support for V4L2_PIX_FMT_XBGR32 and V4L2_PIX_FMT_ABGR32 pixel
formats.

* Added workaround for missing V4L2_PIX_FMT_ABGR32 and V4L2_PIX_FMT_XBGR32
defines
This commit is contained in:
Martin Tůma 2022-05-19 14:37:10 +02:00 committed by GitHub
parent 11f36bdf9a
commit df2e7fa6eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -268,6 +268,13 @@ typedef uint32_t __u32;
#define V4L2_PIX_FMT_Y12 v4l2_fourcc('Y', '1', '2', ' ')
#endif
#ifndef V4L2_PIX_FMT_ABGR32
#define V4L2_PIX_FMT_ABGR32 v4l2_fourcc('A', 'R', '2', '4')
#endif
#ifndef V4L2_PIX_FMT_XBGR32
#define V4L2_PIX_FMT_XBGR32 v4l2_fourcc('X', 'R', '2', '4')
#endif
/* Defaults - If your board can do better, set it here. Set for the most common type inputs. */
#define DEFAULT_V4L_WIDTH 640
#define DEFAULT_V4L_HEIGHT 480
@ -564,6 +571,8 @@ bool CvCaptureCAM_V4L::autosetup_capture_mode_v4l2()
V4L2_PIX_FMT_NV21,
V4L2_PIX_FMT_SBGGR8,
V4L2_PIX_FMT_SGBRG8,
V4L2_PIX_FMT_XBGR32,
V4L2_PIX_FMT_ABGR32,
V4L2_PIX_FMT_SN9C10X,
#ifdef HAVE_JPEG
V4L2_PIX_FMT_MJPEG,
@ -632,6 +641,8 @@ bool CvCaptureCAM_V4L::convertableToRgb() const
case V4L2_PIX_FMT_Y10:
case V4L2_PIX_FMT_GREY:
case V4L2_PIX_FMT_BGR24:
case V4L2_PIX_FMT_XBGR32:
case V4L2_PIX_FMT_ABGR32:
return true;
default:
break;
@ -651,6 +662,8 @@ void CvCaptureCAM_V4L::v4l2_create_frame()
switch (palette) {
case V4L2_PIX_FMT_BGR24:
case V4L2_PIX_FMT_RGB24:
case V4L2_PIX_FMT_XBGR32:
case V4L2_PIX_FMT_ABGR32:
break;
case V4L2_PIX_FMT_YUYV:
case V4L2_PIX_FMT_UYVY:
@ -1613,6 +1626,10 @@ void CvCaptureCAM_V4L::convertToRgb(const Buffer &currentBuffer)
case V4L2_PIX_FMT_GREY:
cv::cvtColor(cv::Mat(imageSize, CV_8UC1, currentBuffer.start), destination, COLOR_GRAY2BGR);
break;
case V4L2_PIX_FMT_XBGR32:
case V4L2_PIX_FMT_ABGR32:
cv::cvtColor(cv::Mat(imageSize, CV_8UC4, currentBuffer.start), destination, COLOR_BGRA2BGR);
break;
case V4L2_PIX_FMT_BGR24:
default:
memcpy((char *)frame.imageData, (char *)currentBuffer.start,