From 25f33a7e305dc9e35e2b63ce107dc220c46db336 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Thu, 18 Dec 2014 11:36:43 +0300 Subject: [PATCH 1/2] update cudev color conversions according to the latest changes in CPU code --- .../include/opencv2/cudev/functional/detail/color_cvt.hpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/cudev/include/opencv2/cudev/functional/detail/color_cvt.hpp b/modules/cudev/include/opencv2/cudev/functional/detail/color_cvt.hpp index 9b20fcc2c6..b2c9ae53e6 100644 --- a/modules/cudev/include/opencv2/cudev/functional/detail/color_cvt.hpp +++ b/modules/cudev/include/opencv2/cudev/functional/detail/color_cvt.hpp @@ -797,8 +797,7 @@ namespace color_cvt_detail if (diff > numeric_limits::epsilon()) { - s = (l < 0.5f) * diff / (vmax + vmin); - s += (l >= 0.5f) * diff / (2.0f - vmax - vmin); + s = l < 0.5f ? diff / (vmax + vmin) : diff / (2 - vmax - vmin); diff = 60.f / diff; @@ -1190,7 +1189,7 @@ namespace color_cvt_detail dst.x = saturate_cast(buf.x * 2.55f); dst.y = saturate_cast(buf.y * 0.72033898305084743f + 96.525423728813564f); - dst.z = saturate_cast(buf.z * 0.99609375f + 139.453125f); + dst.z = saturate_cast(buf.z * 0.9732824427480916f + 136.259541984732824f); return dst; } @@ -1255,7 +1254,7 @@ namespace color_cvt_detail buf.x = src.x * (100.f / 255.f); buf.y = src.y * 1.388235294117647f - 134.f; - buf.z = src.z * 1.003921568627451f - 140.f; + buf.z = src.z * 1.027450980392157f - 140.f; Luv2RGB cvtf; buf = cvtf(buf); From ec33c4ae367d994128fd06433bfedcd1a1494c3c Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Thu, 18 Dec 2014 11:37:26 +0300 Subject: [PATCH 2/2] increase epsilons for tests due to different optimizations (IPP vs CUDA, float vs double) --- modules/cudev/test/test_arithm_func.cu | 4 ++-- modules/cudev/test/test_color_cvt.cu | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/cudev/test/test_arithm_func.cu b/modules/cudev/test/test_arithm_func.cu index c9bc0d8f35..8d6826bccd 100644 --- a/modules/cudev/test/test_arithm_func.cu +++ b/modules/cudev/test/test_arithm_func.cu @@ -69,7 +69,7 @@ public: Mat dst_gold; cv::sqrt(src, dst_gold); - EXPECT_MAT_NEAR(dst_gold, dst, 0.0); + EXPECT_MAT_NEAR(dst_gold, dst, 1e-4); } void test_expr() @@ -88,7 +88,7 @@ public: cv::multiply(src1, src2, dst_gold); cv::sqrt(dst_gold, dst_gold); - EXPECT_MAT_NEAR(dst_gold, dst, 0.0); + EXPECT_MAT_NEAR(dst_gold, dst, 1e-4); } }; diff --git a/modules/cudev/test/test_color_cvt.cu b/modules/cudev/test/test_color_cvt.cu index 62cd49ca6b..53154f99c6 100644 --- a/modules/cudev/test/test_color_cvt.cu +++ b/modules/cudev/test/test_color_cvt.cu @@ -69,7 +69,7 @@ enum { GpuMat_::type> dstb = src_space ## _to_ ## dst_space ## _(d_srcb); \ Mat dstb_gold; \ cv::cvtColor(srcb, dstb_gold, COLOR_ ## src_space ## 2 ## dst_space); \ - EXPECT_MAT_NEAR(dstb_gold, dstb, 1.0); \ + EXPECT_MAT_NEAR(dstb_gold, dstb, 2.0); \ Mat bgrf = randomMat(size, CV_32FC3, 0, 1); \ Mat srcf; \ cv::cvtColor(bgrf, srcf, COLOR_BGR ## 2 ## src_space, src_cn); \ @@ -77,7 +77,7 @@ enum { GpuMat_::type> dstf = src_space ## _to_ ## dst_space ## _(d_srcf); \ Mat dstf_gold; \ cv::cvtColor(srcf, dstf_gold, COLOR_ ## src_space ## 2 ## dst_space); \ - EXPECT_MAT_NEAR(dstf_gold, dstf, 1.0); \ + EXPECT_MAT_NEAR(dstf_gold, dstf, 2.0); \ } // RGB <-> BGR