From 22b0ea1cf0f620bc51aab9278252aeb9420350df Mon Sep 17 00:00:00 2001 From: "marina.kolpakova" Date: Mon, 15 Oct 2012 20:07:24 +0400 Subject: [PATCH] sort for Hough sanity checks --- modules/gpu/perf/perf_imgproc.cpp | 40 +++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/modules/gpu/perf/perf_imgproc.cpp b/modules/gpu/perf/perf_imgproc.cpp index 30377e148..2ecfd7dde 100644 --- a/modules/gpu/perf/perf_imgproc.cpp +++ b/modules/gpu/perf/perf_imgproc.cpp @@ -1706,10 +1706,30 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidGetLayer, Combine(GPU_TYPICAL_MAT_S } } +namespace { + struct Vec3fComparator + { + bool operator()(const cv::Vec3f& a, const cv::Vec3f b) const + { + if(a[0] != b[0]) return a[0] < b[0]; + else if(a[1] != b[1]) return a[1] < b[1]; + else return a[2] < b[2]; + } + }; + struct Vec2fComparator + { + bool operator()(const cv::Vec2f& a, const cv::Vec2f b) const + { + if(a[0] != b[0]) return a[0] < b[0]; + else return a[1] < b[1]; + } + }; +} + ////////////////////////////////////////////////////////////////////// // HoughLines -PERF_TEST_P(Sz, DISABLED_ImgProc_HoughLines, GPU_TYPICAL_MAT_SIZES) +PERF_TEST_P(Sz, ImgProc_HoughLines, GPU_TYPICAL_MAT_SIZES) { declare.time(30.0); @@ -1744,7 +1764,11 @@ PERF_TEST_P(Sz, DISABLED_ImgProc_HoughLines, GPU_TYPICAL_MAT_SIZES) cv::gpu::HoughLines(d_src, d_lines, d_buf, rho, theta, threshold); } - GPU_SANITY_CHECK(d_lines); + cv::Mat h_lines(d_lines); + cv::Vec2f* begin = (cv::Vec2f*)(h_lines.ptr(0)); + cv::Vec2f* end = (cv::Vec2f*)(h_lines.ptr(0) + (h_lines.cols) * 2 * sizeof(float)); + std::sort(begin, end, Vec2fComparator()); + SANITY_CHECK(h_lines); } else { @@ -1756,7 +1780,8 @@ PERF_TEST_P(Sz, DISABLED_ImgProc_HoughLines, GPU_TYPICAL_MAT_SIZES) cv::HoughLines(src, lines, rho, theta, threshold); } - CPU_SANITY_CHECK(lines); + std::sort(lines.begin(), lines.end(), Vec2fComparator()); + SANITY_CHECK(lines); } } @@ -1804,7 +1829,11 @@ PERF_TEST_P(Sz_Dp_MinDist, ImgProc_HoughCircles, Combine(GPU_TYPICAL_MAT_SIZES, cv::gpu::HoughCircles(d_src, d_circles, d_buf, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius); } - GPU_SANITY_CHECK(d_circles); + cv::Mat h_circles(d_circles); + cv::Vec3f* begin = (cv::Vec3f*)(h_circles.ptr(0)); + cv::Vec3f* end = (cv::Vec3f*)(h_circles.ptr(0) + (h_circles.cols) * 3 * sizeof(float)); + std::sort(begin, end, Vec3fComparator()); + SANITY_CHECK(h_circles); } else { @@ -1817,7 +1846,8 @@ PERF_TEST_P(Sz_Dp_MinDist, ImgProc_HoughCircles, Combine(GPU_TYPICAL_MAT_SIZES, cv::HoughCircles(src, circles, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius); } - CPU_SANITY_CHECK(circles); + std::sort(circles.begin(), circles.end(), Vec3fComparator()); + SANITY_CHECK(circles); } }