summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-01-03 00:09:09 +0100
committerStanislaw Halik <sthalik@misaki.pl>2019-01-16 07:48:20 +0100
commit545071e998806235442edda5f575ee61e836abe9 (patch)
tree45579d717361f24c6f4a06354f5836447e691771 /tracker-pt
parent4766be01022d6de50f7b42647299860c2d9909b8 (diff)
cruft
Diffstat (limited to 'tracker-pt')
-rw-r--r--tracker-pt/CMakeLists.txt2
-rw-r--r--tracker-pt/ftnoir_tracker_pt.cpp2
-rw-r--r--tracker-pt/module/point_extractor.cpp12
-rw-r--r--tracker-pt/module/point_extractor.h2
-rw-r--r--tracker-pt/point_tracker.cpp22
-rw-r--r--tracker-pt/pt-api.cpp2
6 files changed, 22 insertions, 20 deletions
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<float>(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<f,unsigned>;
- 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<PointModel::N_POINTS; ++i) // NOLINT(modernize-loop-convert)
+ bool point_taken[sz];
+ for (unsigned i=0; i < sz; ++i) // NOLINT(modernize-loop-convert)
point_taken[i] = false;
- for (unsigned i=0; i<PointModel::N_POINTS; ++i)
+ for (unsigned i=0; i < sz; ++i)
{
f min_sdist = 0;
unsigned min_idx = 0;
// find closest point to projected model point i
- for (unsigned j=0; j<PointModel::N_POINTS; ++j)
+ for (unsigned j=0; j < sz; ++j)
{
vec2 d = p[i]-points[j];
f sdist = d.dot(d);
@@ -328,14 +330,14 @@ int PointTracker::POSIT(const PointModel& model, const PointOrder& order, f foca
// CAVEAT don't change to comparison with an epsilon -sh 20160423
if (JJ0 == II0) {
rho = sqrt(fabs(2*IJ0));
- theta = -M_PI/4;
+ theta = -pi/4;
if (IJ0<0) theta *= -1;
}
else {
rho = sqrt(sqrt( (JJ0-II0)*(JJ0-II0) + 4*IJ0*IJ0 ));
theta = atan( -2*IJ0 / (JJ0-II0) );
// avoid branch misprediction
- theta += (JJ0 - II0 < 0) * M_PI;
+ theta += (JJ0 - II0 < 0) * pi;
theta *= f(.5);
}
@@ -378,7 +380,7 @@ int PointTracker::POSIT(const PointModel& model, const PointOrder& order, f foca
// check for convergence condition
const f delta = fabs(epsilon_1 - old_epsilon_1) + fabs(epsilon_2 - old_epsilon_2);
- if (delta < constants::eps)
+ if (delta < eps)
break;
old_epsilon_1 = epsilon_1;
diff --git a/tracker-pt/pt-api.cpp b/tracker-pt/pt-api.cpp
index 128dcaea..415f1c13 100644
--- a/tracker-pt/pt-api.cpp
+++ b/tracker-pt/pt-api.cpp
@@ -10,7 +10,7 @@ double pt_camera_info::get_focal_length(f fov, int res_x, int res_y)
const double diag_len = std::sqrt(double(res_x*res_x + res_y*res_y));
const double aspect_x = res_x / diag_len;
//const double aspect_y = res_y / diag_len;
- const double diag_fov = fov * M_PI/180;
+ const double diag_fov = fov * pi/180;
const double fov_x = 2*std::atan(std::tan(diag_fov*.5) * aspect_x);
//const double fov_y = 2*atan(tan(diag_fov*.5) * aspect_y);
const double fx = .5 / std::tan(fov_x * .5);