fixed bug in gpu::HOGDescriptor::computeConfidenceMultiScale
authorVladislav Vinogradov <vlad.vinogradov@itseez.com>
Fri, 12 Oct 2012 08:47:07 +0000 (12:47 +0400)
committerVladislav Vinogradov <vlad.vinogradov@itseez.com>
Fri, 12 Oct 2012 08:49:10 +0000 (12:49 +0400)
modules/gpu/src/hog.cpp

index 9de31cb..0e38ead 100644 (file)
@@ -311,50 +311,51 @@ void cv::gpu::HOGDescriptor::computeConfidenceMultiScale(const GpuMat& img, vect
                             double hit_threshold, Size win_stride, Size padding,\r
                             vector<HOGConfidence> &conf_out, int group_threshold)\r
 {\r
-  vector<double> level_scale;\r
-  double scale = 1.;\r
-  int levels = 0;\r
+    vector<double> level_scale;\r
+    double scale = 1.;\r
+    int levels = 0;\r
 \r
-  for (levels = 0; levels < (int)conf_out.size(); levels++)\r
+    for (levels = 0; levels < (int)conf_out.size(); levels++)\r
     {\r
-      scale = conf_out[levels].scale;\r
-      level_scale.push_back(scale);\r
-      if (cvRound(img.cols/scale) < win_size.width ||\r
-     cvRound(img.rows/scale) < win_size.height)\r
-   break;\r
+        scale = conf_out[levels].scale;\r
+        level_scale.push_back(scale);\r
+        if (cvRound(img.cols/scale) < win_size.width || cvRound(img.rows/scale) < win_size.height)\r
+            break;\r
     }\r
 \r
-  levels = std::max(levels, 1);\r
-  level_scale.resize(levels);\r
+    levels = std::max(levels, 1);\r
+    level_scale.resize(levels);\r
 \r
-  std::vector<Rect> all_candidates;\r
-  vector<Point> locations;\r
+    std::vector<Rect> all_candidates;\r
+    vector<Point> locations;\r
 \r
-  for (size_t i = 0; i < level_scale.size(); i++)\r
+    for (size_t i = 0; i < level_scale.size(); i++)\r
     {\r
-      double _scale = level_scale[i];\r
-      Size sz(cvRound(img.cols / _scale), cvRound(img.rows / _scale));\r
-      GpuMat smaller_img;\r
-\r
-      if (sz == img.size())\r
-   smaller_img = img;\r
-      else\r
-   {\r
-     smaller_img.create(sz, img.type());\r
-     switch (img.type()) {\r
-     case CV_8UC1: hog::resize_8UC1(img, smaller_img); break;\r
-     case CV_8UC4: hog::resize_8UC4(img, smaller_img); break;\r
-     }\r
-   }\r
-\r
-      computeConfidence(smaller_img, locations, hit_threshold, win_stride, padding, conf_out[i].locations, conf_out[i].confidences);\r
-\r
-      Size scaled_win_size(cvRound(win_size.width * scale), cvRound(win_size.height * scale));\r
-      for (size_t j = 0; j < locations.size(); j++)\r
-   all_candidates.push_back(Rect(Point2d((CvPoint)locations[j]) * scale, scaled_win_size));\r
+        scale = level_scale[i];\r
+        Size sz(cvRound(img.cols / scale), cvRound(img.rows / scale));\r
+        GpuMat smaller_img;\r
+\r
+        if (sz == img.size())\r
+            smaller_img = img;\r
+        else\r
+        {\r
+            smaller_img.create(sz, img.type());\r
+            switch (img.type())\r
+            {\r
+            case CV_8UC1: hog::resize_8UC1(img, smaller_img); break;\r
+            case CV_8UC4: hog::resize_8UC4(img, smaller_img); break;\r
+            }\r
+        }\r
+\r
+        computeConfidence(smaller_img, locations, hit_threshold, win_stride, padding, conf_out[i].locations, conf_out[i].confidences);\r
+\r
+        Size scaled_win_size(cvRound(win_size.width * scale), cvRound(win_size.height * scale));\r
+        for (size_t j = 0; j < locations.size(); j++)\r
+            all_candidates.push_back(Rect(Point2d((CvPoint)locations[j]) * scale, scaled_win_size));\r
     }\r
-  found_locations.assign(all_candidates.begin(), all_candidates.end());\r
-  groupRectangles(found_locations, group_threshold, 0.2/*magic number copied from CPU version*/);\r
+\r
+    found_locations.assign(all_candidates.begin(), all_candidates.end());\r
+    groupRectangles(found_locations, group_threshold, 0.2/*magic number copied from CPU version*/);\r
 }\r
 \r
 \r