From 545071e998806235442edda5f575ee61e836abe9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 3 Jan 2019 00:09:09 +0100 Subject: cruft --- tracker-pt/CMakeLists.txt | 2 +- tracker-pt/ftnoir_tracker_pt.cpp | 2 +- tracker-pt/module/point_extractor.cpp | 12 ++++++------ tracker-pt/module/point_extractor.h | 2 +- tracker-pt/point_tracker.cpp | 22 ++++++++++++---------- tracker-pt/pt-api.cpp | 2 +- 6 files changed, 22 insertions(+), 20 deletions(-) (limited to 'tracker-pt') diff --git a/tracker-pt/CMakeLists.txt b/tracker-pt/CMakeLists.txt index 4010b6c1..f12f530b 100644 --- a/tracker-pt/CMakeLists.txt +++ b/tracker-pt/CMakeLists.txt @@ -2,7 +2,7 @@ find_package(OpenCV QUIET) if(OpenCV_FOUND) otr_module(tracker-pt-base STATIC) target_include_directories(${self} SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) - target_link_libraries(${self} opentrack-cv opencv_core opencv_imgproc opencv_videoio) + target_link_libraries(${self} opencv_imgproc opentrack-cv opencv_core) set_property(TARGET ${self} PROPERTY OUTPUT_NAME "pt-base") endif() add_subdirectory(module) diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp index f52564f7..c72a7ffa 100644 --- a/tracker-pt/ftnoir_tracker_pt.cpp +++ b/tracker-pt/ftnoir_tracker_pt.cpp @@ -174,7 +174,7 @@ void Tracker_PT::data(double *data) alpha = atan2( R(1,0), R(0,0) ); gamma = atan2( R(2,1), R(2,2) ); - constexpr f rad2deg = f(180/M_PI); + constexpr f rad2deg = f(180/pi); data[Yaw] = rad2deg * alpha; data[Pitch] = -rad2deg * beta; diff --git a/tracker-pt/module/point_extractor.cpp b/tracker-pt/module/point_extractor.cpp index e6364a88..0f7af939 100644 --- a/tracker-pt/module/point_extractor.cpp +++ b/tracker-pt/module/point_extractor.cpp @@ -182,20 +182,20 @@ void PointExtractor::threshold_image(const cv::Mat& frame_gray, cv::Mat1b& outpu const f radius = (f) threshold_radius_value(frame_gray.cols, frame_gray.rows, threshold_slider_value); float const* const __restrict ptr = hist.ptr(0); - const unsigned area = uround(3 * M_PI * radius*radius); + const unsigned area = uround(3 * pi * radius*radius); const unsigned sz = unsigned(hist.cols * hist.rows); constexpr unsigned min_thres = 64; unsigned thres = min_thres; for (unsigned i = sz-1, cnt = 0; i > 32; i--) { - cnt += ptr[i]; + cnt += (unsigned)ptr[i]; if (cnt >= area) break; thres = i; } if (thres > min_thres) - thres *= .8; + thres = uround(thres * .8); cv::threshold(frame_gray, output, thres, 255, cv::THRESH_BINARY); } @@ -263,12 +263,12 @@ void PointExtractor::extract_points(const pt_frame& frame_, pt_preview& preview_ } } - const double radius = std::sqrt(cnt / M_PI); + const double radius = std::sqrt(cnt / pi); if (radius > region_size_max || radius < region_size_min) continue; blobs.emplace_back(radius, - vec2(rect.width/2., rect.height/2.), + vec2(rect.width/f(2), rect.height/f(2)), std::pow(f(norm), f(1.1))/cnt, rect); @@ -294,7 +294,7 @@ end: for (idx = 0; idx < sz; ++idx) { - blob &b = blobs[idx]; + blob& b = blobs[idx]; cv::Rect rect = b.rect; rect.x -= rect.width / 2; diff --git a/tracker-pt/module/point_extractor.h b/tracker-pt/module/point_extractor.h index 7dd82234..bbe202fa 100644 --- a/tracker-pt/module/point_extractor.h +++ b/tracker-pt/module/point_extractor.h @@ -19,7 +19,7 @@ namespace pt_module { using namespace types; -struct blob +struct blob final { f radius, brightness; vec2 pos; diff --git a/tracker-pt/point_tracker.cpp b/tracker-pt/point_tracker.cpp index b04c8eb1..68e8c286 100644 --- a/tracker-pt/point_tracker.cpp +++ b/tracker-pt/point_tracker.cpp @@ -67,18 +67,19 @@ void PointModel::set_model(const pt_settings& s) void PointModel::get_d_order(const vec2* points, unsigned* d_order, const vec2& d) const { + constexpr unsigned cnt = PointModel::N_POINTS; // fit line to orthographically projected points using t = std::pair; - t d_vals[3]; + t d_vals[cnt]; // get sort indices with respect to d scalar product - for (unsigned i = 0; i < PointModel::N_POINTS; ++i) + for (unsigned i = 0; i < cnt; ++i) d_vals[i] = t(d.dot(points[i]), i); std::sort(d_vals, d_vals + 3u, [](const t& a, const t& b) { return a.first < b.first; }); - for (unsigned i = 0; i < PointModel::N_POINTS; ++i) + for (unsigned i = 0; i < cnt; ++i) d_order[i] = d_vals[i].second; } @@ -98,18 +99,19 @@ PointTracker::PointOrder PointTracker::find_correspondences_previous(const vec2* const int diagonal = int(std::sqrt(f(info.res_x*info.res_x + info.res_y*info.res_y))); constexpr int div = 80; const int max_dist = diagonal / div; // 10 pixels for 640x480 + constexpr unsigned sz = PointModel::N_POINTS; // set correspondences by minimum distance to projected model point - bool point_taken[PointModel::N_POINTS]; - for (unsigned i=0; i