diff options
author | Stéphane Lenclud <github@lenclud.com> | 2019-04-14 23:21:08 +0200 |
---|---|---|
committer | Stéphane Lenclud <github@lenclud.com> | 2019-04-14 23:21:08 +0200 |
commit | a7261a99cf96f8b0c64cc9eea63057562ce89baa (patch) | |
tree | c9f3dcf4799fef811d6d6df72f79804f037bac6d /tracker-easy/point-extractor.cpp | |
parent | 56160ea9dedc086e74962f8c74a7f96d576653c3 (diff) |
Easy Tracker: Removed area check from bounding box validation. Using simpler contours.
Diffstat (limited to 'tracker-easy/point-extractor.cpp')
-rw-r--r-- | tracker-easy/point-extractor.cpp | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/tracker-easy/point-extractor.cpp b/tracker-easy/point-extractor.cpp index d8ea3c53..037d06c0 100644 --- a/tracker-easy/point-extractor.cpp +++ b/tracker-easy/point-extractor.cpp @@ -80,7 +80,7 @@ namespace EasyTracker // Contours detection std::vector<std::vector<cv::Point> > contours; - cv::findContours(iFrameGray, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); + cv::findContours(iFrameGray, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE); // Workout which countours are valid points for (size_t i = 0; i < contours.size(); i++) @@ -93,22 +93,12 @@ namespace EasyTracker cv::Rect bBox; bBox = cv::boundingRect(contours[i]); - - float ratio = (float)bBox.width / (float)bBox.height; - if (ratio > 1.0f) - ratio = 1.0f / ratio; - - // Searching for a bBox almost square - float minArea = s.min_point_size*s.min_point_size; - float maxArea = s.max_point_size*s.max_point_size; + // Make sure bounding box matches our criteria if (bBox.width >= s.min_point_size && bBox.height >= s.min_point_size && bBox.width <= s.max_point_size - && bBox.height <= s.max_point_size - && bBox.area() >= minArea - && bBox.area() <= maxArea - /*&& ratio > 0.75 &&*/) + && bBox.height <= s.max_point_size) { vec2 center; center[0] = bBox.x + bBox.width / 2; |