sort for Hough sanity checks
authormarina.kolpakova <marina.kolpakova@itseez.com>
Mon, 15 Oct 2012 16:07:24 +0000 (20:07 +0400)
committermarina.kolpakova <marina.kolpakova@itseez.com>
Mon, 26 Nov 2012 19:54:10 +0000 (23:54 +0400)
modules/gpu/perf/perf_imgproc.cpp

index 30377e1..2ecfd7d 100644 (file)
@@ -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<char>(0));
+        cv::Vec2f* end = (cv::Vec2f*)(h_lines.ptr<char>(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<char>(0));
+        cv::Vec3f* end = (cv::Vec3f*)(h_circles.ptr<char>(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);
     }
 }