From 78a0b9787c938f792353bca7ff8fee2c19e1dfc6 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Mon, 15 Oct 2012 13:55:32 +0400 Subject: [PATCH] fixed build errors on Mac; moved test for #2332 from imgproc to highgui --- modules/core/src/parallel.cpp | 3 ++- modules/highgui/test/test_grfmt.cpp | 28 ++++++++++++++++++++++++++++ modules/imgproc/test/test_color.cpp | 25 ------------------------- 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/modules/core/src/parallel.cpp b/modules/core/src/parallel.cpp index 872a69ca0b..87bfbe9f5e 100644 --- a/modules/core/src/parallel.cpp +++ b/modules/core/src/parallel.cpp @@ -85,6 +85,7 @@ #include #elif defined HAVE_GCD #include + #include #include #elif defined HAVE_CONCURRENCY #include @@ -371,7 +372,7 @@ int cv::getThreadNum(void) #elif defined HAVE_OPENMP return omp_get_thread_num(); #elif defined HAVE_GCD - return statc_cast(pthread_self()); // no zero-based indexing + return (int)(size_t)(void*)pthread_self(); // no zero-based indexing #elif defined HAVE_CONCURRENCY return std::max(0, (int)Concurrency::Context::VirtualProcessorId()); // zero for master thread, unique number for others but not necessary 1,2,3,... #else diff --git a/modules/highgui/test/test_grfmt.cpp b/modules/highgui/test/test_grfmt.cpp index d6fc65a6b4..1906bc11ac 100644 --- a/modules/highgui/test/test_grfmt.cpp +++ b/modules/highgui/test/test_grfmt.cpp @@ -255,3 +255,31 @@ public: TEST(Highgui_Image, encode_png) { CV_GrfmtPNGEncodeTest test; test.safe_run(); } #endif + +#ifdef HAVE_JPEG +TEST(Highgui_ImreadVSCvtColor, regression) +{ + cvtest::TS& ts = *cvtest::TS::ptr(); + + const int MAX_MEAN_DIFF = 3; + const int MAX_ABS_DIFF = 10; + + string imgName = string(ts.get_data_path()) + "/../cv/shared/lena.jpg"; + Mat original_image = imread(imgName); + Mat gray_by_codec = imread(imgName, 0); + Mat gray_by_cvt; + + cvtColor(original_image, gray_by_cvt, CV_BGR2GRAY); + + Mat diff; + absdiff(gray_by_codec, gray_by_cvt, diff); + + double actual_avg_diff = (double)mean(diff)[0]; + double actual_maxval, actual_minval; + minMaxLoc(diff, &actual_minval, &actual_maxval); + + EXPECT_LT(actual_avg_diff, MAX_MEAN_DIFF); + EXPECT_LT(actual_maxval, MAX_ABS_DIFF); +} +#endif + diff --git a/modules/imgproc/test/test_color.cpp b/modules/imgproc/test/test_color.cpp index 39839e45f5..66aec19268 100644 --- a/modules/imgproc/test/test_color.cpp +++ b/modules/imgproc/test/test_color.cpp @@ -1683,31 +1683,6 @@ TEST(Imgproc_ColorLuv, accuracy) { CV_ColorLuvTest test; test.safe_run(); } TEST(Imgproc_ColorRGB, accuracy) { CV_ColorRGBTest test; test.safe_run(); } TEST(Imgproc_ColorBayer, accuracy) { CV_ColorBayerTest test; test.safe_run(); } -TEST(Imgproc_ImreadVSCvtColor, regression) -{ - cvtest::TS& ts = *cvtest::TS::ptr(); - - const int MAX_MEAN_DIFF = 3; - const int MAX_ABS_DIFF = 10; - - string imgName = string(ts.get_data_path()) + "/shared/lena.jpg"; - Mat original_image = imread(imgName); - Mat gray_by_codec = imread(imgName, 0); - Mat gray_by_cvt; - - cvtColor(original_image, gray_by_cvt, CV_BGR2GRAY); - - Mat diff; - absdiff(gray_by_codec, gray_by_cvt, diff); - - double actual_avg_diff = (double)sum(diff)[0] / countNonZero(diff); - double actual_maxval, actual_minval; - minMaxLoc(diff, &actual_minval, &actual_maxval); - - EXPECT_LT(actual_avg_diff, MAX_MEAN_DIFF); - EXPECT_LT(actual_maxval, MAX_ABS_DIFF); -} - TEST(Imgproc_ColorBayer, regression) { cvtest::TS& ts = *cvtest::TS::ptr();