Added perf test for RGB(A)/BGR(A) to YCrCb conversion
authorAndrey Kamaev <no@email>
Mon, 9 Jan 2012 16:38:44 +0000 (16:38 +0000)
committerAndrey Kamaev <no@email>
Mon, 9 Jan 2012 16:38:44 +0000 (16:38 +0000)
modules/imgproc/perf/perf_cvt_color.cpp
modules/imgproc/src/color.cpp

index aacdf97..fec01b3 100644 (file)
@@ -10,7 +10,8 @@ CV_ENUM(CvtMode, CV_YUV2BGR, CV_YUV2RGB, //YUV
         CV_YUV420i2BGR, CV_YUV420i2RGB, CV_YUV420sp2BGR, CV_YUV420sp2RGB, //YUV420
         CV_RGB2GRAY, CV_RGBA2GRAY, CV_BGR2GRAY, CV_BGRA2GRAY, //Gray
         CV_GRAY2RGB, CV_GRAY2RGBA, /*CV_GRAY2BGR, CV_GRAY2BGRA*/ //Gray2
-        CV_BGR2HSV, CV_RGB2HSV, CV_BGR2HLS, CV_RGB2HLS //H
+        CV_BGR2HSV, CV_RGB2HSV, CV_BGR2HLS, CV_RGB2HLS, //H
+        CV_BGR2YCrCb, CV_RGB2YCrCb
         )
 
 typedef std::tr1::tuple<Size, CvtMode> Size_CvtMode_t;
@@ -82,7 +83,7 @@ PERF_TEST_P(Size_CvtMode, cvtColorGray,
     
     TEST_CYCLE() cvtColor(src, dst, mode);
     
-    SANITY_CHECK(dst);
+    SANITY_CHECK(dst, 1);
 }
 
 
@@ -126,3 +127,28 @@ PERF_TEST_P(Size_CvtMode, cvtColorH,
     SANITY_CHECK(dst, 1);
 }
 
+typedef std::tr1::tuple<Size, CvtMode, int> Size_CvtMode_Ch_t;
+typedef perf::TestBaseWithParam<Size_CvtMode_Ch_t> Size_CvtMode_Ch;
+
+PERF_TEST_P(Size_CvtMode_Ch, cvtColorYCrCb,
+            testing::Combine(
+                testing::Values(TYPICAL_MAT_SIZES),
+                testing::Values((int)CV_BGR2YCrCb, (int)CV_RGB2YCrCb),
+                testing::Values(3, 4)
+                )
+            )
+{
+    Size sz = get<0>(GetParam());
+    int mode = get<1>(GetParam());
+    int ch = get<2>(GetParam());
+
+    Mat src(sz, CV_8UC(ch));
+    Mat dst(sz, CV_8UC3);
+
+    declare.in(src, WARMUP_RNG).out(dst);
+
+    TEST_CYCLE() cvtColor(src, dst, mode);
+
+    SANITY_CHECK(dst, 1);
+}
+
index 02c927f..2dde5df 100644 (file)
@@ -2906,7 +2906,13 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
             dst = _dst.getMat();
             
             if( depth == CV_8U )
+            {
+#ifdef HAVE_TEGRA_OPTIMIZATION
+                if((code == CV_RGB2YCrCb || code == CV_BGR2YCrCb) && tegra::RGB2YCrCb(src, dst, bidx))
+                    break;
+#endif
                 CvtColorLoop(src, dst, RGB2YCrCb_i<uchar>(scn, bidx, coeffs_i));
+            }
             else if( depth == CV_16U )
                 CvtColorLoop(src, dst, RGB2YCrCb_i<ushort>(scn, bidx, coeffs_i));
             else