From cf09ec936348f1d59473cb50b35fe80addacfc44 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 21 Jun 2016 11:10:45 +0200 Subject: tracker/pt: fix points at (0,0) which are really NaN Issue: #318 cf. http://forum.il2sturmovik.ru/topic/2291-open-track/page-26 --- tracker-pt/point_extractor.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tracker-pt') 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 + PointExtractor::PointExtractor() { blobs.reserve(max_blobs); @@ -81,7 +83,13 @@ const std::vector& 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; -- cgit v1.2.3