V4L2: Add V4L2_PIX_FMT_Y10 (10 bit grey) support

pull/15001/head
Tomasz Gorochowik 6 years ago
parent 1e9e2aa95c
commit 4997a6bf06
  1. 12
      modules/videoio/src/cap_v4l.cpp

@ -496,7 +496,8 @@ bool CvCaptureCAM_V4L::autosetup_capture_mode_v4l2()
V4L2_PIX_FMT_JPEG,
#endif
V4L2_PIX_FMT_Y16,
V4L2_PIX_FMT_GREY
V4L2_PIX_FMT_Y10,
V4L2_PIX_FMT_GREY,
};
for (size_t i = 0; i < sizeof(try_order) / sizeof(__u32); i++) {
@ -543,6 +544,7 @@ bool CvCaptureCAM_V4L::convertableToRgb() const
case V4L2_PIX_FMT_SGBRG8:
case V4L2_PIX_FMT_RGB24:
case V4L2_PIX_FMT_Y16:
case V4L2_PIX_FMT_Y10:
case V4L2_PIX_FMT_GREY:
case V4L2_PIX_FMT_BGR24:
return true;
@ -577,6 +579,7 @@ void CvCaptureCAM_V4L::v4l2_create_frame()
size.height = size.height * 3 / 2; // "1.5" channels
break;
case V4L2_PIX_FMT_Y16:
case V4L2_PIX_FMT_Y10:
depth = IPL_DEPTH_16U;
/* fallthru */
case V4L2_PIX_FMT_GREY:
@ -1451,6 +1454,13 @@ void CvCaptureCAM_V4L::convertToRgb(const Buffer &currentBuffer)
cv::cvtColor(temp, destination, COLOR_GRAY2BGR);
return;
}
case V4L2_PIX_FMT_Y10:
{
cv::Mat temp(imageSize, CV_8UC1, buffers[MAX_V4L_BUFFERS].start);
cv::Mat(imageSize, CV_16UC1, currentBuffer.start).convertTo(temp, CV_8U, 1.0 / 4);
cv::cvtColor(temp, destination, COLOR_GRAY2BGR);
return;
}
case V4L2_PIX_FMT_GREY:
cv::cvtColor(cv::Mat(imageSize, CV_8UC1, currentBuffer.start), destination, COLOR_GRAY2BGR);
break;

Loading…
Cancel
Save