From 838947bb8ea4dbc4d8490541513453355dd6d2fc Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sat, 10 Oct 2015 13:42:26 +0200 Subject: [PATCH] replace custom yuyv_to_rgb24 implementation by cvtColor --- modules/videoio/src/cap_v4l.cpp | 47 +++------------------------------ modules/videoio/src/precomp.hpp | 1 + 2 files changed, 5 insertions(+), 43 deletions(-) diff --git a/modules/videoio/src/cap_v4l.cpp b/modules/videoio/src/cap_v4l.cpp index 5ec5278f0..4f00e43d5 100644 --- a/modules/videoio/src/cap_v4l.cpp +++ b/modules/videoio/src/cap_v4l.cpp @@ -1516,49 +1516,10 @@ yuv411p_to_rgb24(int width, int height, #ifdef HAVE_CAMV4L2 static void -yuyv_to_rgb24 (int width, int height, unsigned char *src, unsigned char *dst) -{ - unsigned char *s; - unsigned char *d; - int l, c; - int r, g, b, cr, cg, cb, y1, y2; - - l = height; - s = src; - d = dst; - while (l--) { - c = width >> 1; - while (c--) { - y1 = *s++; - cb = ((*s - 128) * 454) >> 8; - cg = (*s++ - 128) * 88; - y2 = *s++; - cr = ((*s - 128) * 359) >> 8; - cg = (cg + (*s++ - 128) * 183) >> 8; - - r = y1 + cr; - b = y1 + cb; - g = y1 - cg; - SAT(r); - SAT(g); - SAT(b); - - *d++ = b; - *d++ = g; - *d++ = r; - - r = y2 + cr; - b = y2 + cb; - g = y2 - cg; - SAT(r); - SAT(g); - SAT(b); - - *d++ = b; - *d++ = g; - *d++ = r; - } - } +yuyv_to_rgb24(int width, int height, unsigned char* src, unsigned char* dst) { + using namespace cv; + cvtColor(Mat(height, width, CV_8UC2, src), Mat(height, width, CV_8UC3, dst), + COLOR_YUV2BGR_YUYV); } static void diff --git a/modules/videoio/src/precomp.hpp b/modules/videoio/src/precomp.hpp index d60b00f94..442eaa19a 100644 --- a/modules/videoio/src/precomp.hpp +++ b/modules/videoio/src/precomp.hpp @@ -49,6 +49,7 @@ #include "opencv2/imgcodecs.hpp" +#include "opencv2/imgproc.hpp" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/imgcodecs/imgcodecs_c.h" #include "opencv2/videoio/videoio_c.h"