diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-06-21 11:10:45 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-06-21 11:10:45 +0200 |
commit | cf09ec936348f1d59473cb50b35fe80addacfc44 (patch) | |
tree | 233e95d18fecb50fb0f6eda0f2090952535b811d /tracker-pt | |
parent | eaf38d3ad753dd8f5a13a07c60bea6f028d28bac (diff) |
tracker/pt: fix points at (0,0) which are really NaN
Issue: #318
cf. http://forum.il2sturmovik.ru/topic/2291-open-track/page-26
Diffstat (limited to 'tracker-pt')
-rw-r--r-- | tracker-pt/point_extractor.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp index 96c70d11..e27bd3c7 100644 --- a/tracker-pt/point_extractor.cpp +++ b/tracker-pt/point_extractor.cpp @@ -13,6 +13,8 @@ # include "opentrack-compat/timer.hpp" #endif +#include <cmath> + PointExtractor::PointExtractor() { blobs.reserve(max_blobs); @@ -81,7 +83,13 @@ const std::vector<cv::Vec2f>& PointExtractor::extract_points(cv::Mat& frame) for (auto& c : contours) { + using std::fabs; + const auto m = cv::moments(cv::Mat(c)); + + if (fabs(m.m00) < 1e-3) + continue; + const cv::Vec2d pos(m.m10 / m.m00, m.m01 / m.m00); double radius; |