From b07b9aca5aec2b8cc61d5724d85f6c28a8f02437 Mon Sep 17 00:00:00 2001
From: Ilya Lavrenov <ilya.lavrenov@itseez.com>
Date: Mon, 9 Sep 2013 17:16:47 +0400
Subject: [PATCH] fixed HOG perf test

---
 modules/ocl/perf/perf_hog.cpp | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/modules/ocl/perf/perf_hog.cpp b/modules/ocl/perf/perf_hog.cpp
index 15846d831..fe5d9d190 100644
--- a/modules/ocl/perf/perf_hog.cpp
+++ b/modules/ocl/perf/perf_hog.cpp
@@ -49,6 +49,23 @@ using namespace perf;
 
 ///////////// HOG////////////////////////
 
+struct RectLess :
+        public std::binary_function<cv::Rect, cv::Rect, bool>
+{
+    bool operator()(const cv::Rect& a,
+        const cv::Rect& b) const
+    {
+        if (a.x != b.x)
+            return a.x < b.x;
+        else if (a.y != b.y)
+            return a.y < b.y;
+        else if (a.width != b.width)
+            return a.width < b.width;
+        else
+            return a.height < b.height;
+    }
+};
+
 PERF_TEST(HOGFixture, HOG)
 {
     Mat src = imread(getDataPath("gpu/hog/road.png"), cv::IMREAD_GRAYSCALE);
@@ -64,6 +81,7 @@ PERF_TEST(HOGFixture, HOG)
 
         TEST_CYCLE() hog.detectMultiScale(src, found_locations);
 
+        std::sort(found_locations.begin(), found_locations.end(), RectLess());
         SANITY_CHECK(found_locations, 1 + DBL_EPSILON);
     }
     else if (RUN_OCL_IMPL)
@@ -74,6 +92,7 @@ PERF_TEST(HOGFixture, HOG)
 
         OCL_TEST_CYCLE() ocl_hog.detectMultiScale(oclSrc, found_locations);
 
+        std::sort(found_locations.begin(), found_locations.end(), RectLess());
         SANITY_CHECK(found_locations, 1 + DBL_EPSILON);
     }
     else