Commit 7d7767ba authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #12134 from mshabunin:add-yuv420-v4l

parents 183cfd3a a2daf0c8
...@@ -431,6 +431,7 @@ static int autosetup_capture_mode_v4l2(CvCaptureCAM_V4L* capture) { ...@@ -431,6 +431,7 @@ static int autosetup_capture_mode_v4l2(CvCaptureCAM_V4L* capture) {
V4L2_PIX_FMT_BGR24, V4L2_PIX_FMT_BGR24,
V4L2_PIX_FMT_RGB24, V4L2_PIX_FMT_RGB24,
V4L2_PIX_FMT_YVU420, V4L2_PIX_FMT_YVU420,
V4L2_PIX_FMT_YUV420,
V4L2_PIX_FMT_YUV411P, V4L2_PIX_FMT_YUV411P,
V4L2_PIX_FMT_YUYV, V4L2_PIX_FMT_YUYV,
V4L2_PIX_FMT_UYVY, V4L2_PIX_FMT_UYVY,
...@@ -531,6 +532,7 @@ static int v4l2_set_fps(CvCaptureCAM_V4L* capture) { ...@@ -531,6 +532,7 @@ static int v4l2_set_fps(CvCaptureCAM_V4L* capture) {
static int v4l2_num_channels(__u32 palette) { static int v4l2_num_channels(__u32 palette) {
switch(palette) { switch(palette) {
case V4L2_PIX_FMT_YVU420: case V4L2_PIX_FMT_YVU420:
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_MJPEG: case V4L2_PIX_FMT_MJPEG:
case V4L2_PIX_FMT_JPEG: case V4L2_PIX_FMT_JPEG:
case V4L2_PIX_FMT_Y16: case V4L2_PIX_FMT_Y16:
...@@ -560,6 +562,7 @@ static void v4l2_create_frame(CvCaptureCAM_V4L *capture) { ...@@ -560,6 +562,7 @@ static void v4l2_create_frame(CvCaptureCAM_V4L *capture) {
size = CvSize(capture->buffers[capture->bufferIndex].length, 1); size = CvSize(capture->buffers[capture->bufferIndex].length, 1);
break; break;
case V4L2_PIX_FMT_YVU420: case V4L2_PIX_FMT_YVU420:
case V4L2_PIX_FMT_YUV420:
size.height = size.height * 3 / 2; // "1.5" channels size.height = size.height * 3 / 2; // "1.5" channels
break; break;
case V4L2_PIX_FMT_Y16: case V4L2_PIX_FMT_Y16:
...@@ -1019,10 +1022,10 @@ move_411_block(int yTL, int yTR, int yBL, int yBR, int u, int v, ...@@ -1019,10 +1022,10 @@ move_411_block(int yTL, int yTR, int yBL, int yBR, int u, int v,
/* Converts from planar YUV420P to RGB24. */ /* Converts from planar YUV420P to RGB24. */
static inline void static inline void
yuv420p_to_rgb24(int width, int height, uchar* src, uchar* dst) yuv420p_to_rgb24(int width, int height, uchar* src, uchar* dst, bool isYUV)
{ {
cvtColor(Mat(height * 3 / 2, width, CV_8U, src), Mat(height, width, CV_8UC3, dst), cvtColor(Mat(height * 3 / 2, width, CV_8U, src), Mat(height, width, CV_8UC3, dst),
COLOR_YUV2BGR_YV12); isYUV ? COLOR_YUV2BGR_IYUV : COLOR_YUV2BGR_YV12);
} }
// Consider a YUV411P image of 8x2 pixels. // Consider a YUV411P image of 8x2 pixels.
...@@ -1481,10 +1484,12 @@ static IplImage* icvRetrieveFrameCAM_V4L( CvCaptureCAM_V4L* capture, int) { ...@@ -1481,10 +1484,12 @@ static IplImage* icvRetrieveFrameCAM_V4L( CvCaptureCAM_V4L* capture, int) {
break; break;
case V4L2_PIX_FMT_YVU420: case V4L2_PIX_FMT_YVU420:
case V4L2_PIX_FMT_YUV420:
yuv420p_to_rgb24(capture->form.fmt.pix.width, yuv420p_to_rgb24(capture->form.fmt.pix.width,
capture->form.fmt.pix.height, capture->form.fmt.pix.height,
(unsigned char*)(capture->buffers[capture->bufferIndex].start), (unsigned char*)(capture->buffers[capture->bufferIndex].start),
(unsigned char*)capture->frame.imageData); (unsigned char*)capture->frame.imageData,
capture->palette == V4L2_PIX_FMT_YUV420);
break; break;
case V4L2_PIX_FMT_YUV411P: case V4L2_PIX_FMT_YUV411P:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment