From f2607137b744b66b84be799fe56db08595c38867 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 17 Oct 2015 13:02:08 +0200 Subject: pt: switch min/max point size to reals --- ftnoir_tracker_pt/FTNoIR_PT_Controls.ui | 58 ++++++++++++++------------ ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h | 7 ++-- ftnoir_tracker_pt/point_extractor.cpp | 4 +- 3 files changed, 37 insertions(+), 32 deletions(-) (limited to 'ftnoir_tracker_pt') diff --git a/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui b/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui index acdbda787..88575644a 100644 --- a/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui +++ b/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui @@ -299,19 +299,6 @@ Point extraction - - - - Maximum point diameter - - - px - - - 1024 - - - @@ -322,19 +309,6 @@ - - - - Minimum point diameter - - - px - - - 1024 - - - @@ -394,6 +368,38 @@ + + + + Maximum point diameter + + + px + + + 1 + + + 0.100000000000000 + + + + + + + Minimum point diameter + + + px + + + 1 + + + 0.100000000000000 + + + diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h index 57e68d0e6..d7ddb6a90 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h @@ -17,9 +17,8 @@ struct settings_pt : opts value cam_res_x, cam_res_y, cam_fps, - threshold, - min_point_size, - max_point_size; + threshold; + value min_point_size, max_point_size; value m01_x, m01_y, m01_z; value m02_x, m02_y, m02_z; @@ -42,7 +41,7 @@ struct settings_pt : opts cam_res_y(b, "camera-res-height", 480), cam_fps(b, "camera-fps", 30), threshold(b, "threshold-primary", 128), - min_point_size(b, "min-point-size", 10), + min_point_size(b, "min-point-size", 1), max_point_size(b, "max-point-size", 50), m01_x(b, "m_01-x", 0), m01_y(b, "m_01-y", 0), diff --git a/ftnoir_tracker_pt/point_extractor.cpp b/ftnoir_tracker_pt/point_extractor.cpp index 0ac2fc320..77f2473c2 100644 --- a/ftnoir_tracker_pt/point_extractor.cpp +++ b/ftnoir_tracker_pt/point_extractor.cpp @@ -28,8 +28,8 @@ std::vector PointExtractor::extract_points(cv::Mat& frame) cv::Mat frame_gray; cv::cvtColor(frame, frame_gray, cv::COLOR_RGB2GRAY); - const int region_size_min = s.min_point_size; - const int region_size_max = s.max_point_size; + const double region_size_min = s.min_point_size; + const double region_size_max = s.max_point_size; struct simple_blob { -- cgit v1.2.3 From f0800fee0d40b7375d3c7e7b7a7a99314c5fb251 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 17 Oct 2015 13:02:26 +0200 Subject: pt: rename ill-chosen name --- ftnoir_tracker_pt/point_extractor.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ftnoir_tracker_pt') diff --git a/ftnoir_tracker_pt/point_extractor.cpp b/ftnoir_tracker_pt/point_extractor.cpp index 77f2473c2..f9be259ad 100644 --- a/ftnoir_tracker_pt/point_extractor.cpp +++ b/ftnoir_tracker_pt/point_extractor.cpp @@ -31,18 +31,18 @@ std::vector PointExtractor::extract_points(cv::Mat& frame) const double region_size_min = s.min_point_size; const double region_size_max = s.max_point_size; - struct simple_blob + struct blob { double radius; cv::Vec2d pos; double confid; bool taken; double area; - simple_blob(double radius, const cv::Vec2d& pos, double confid, double area) : radius(radius), pos(pos), confid(confid), taken(false), area(area) + blob(double radius, const cv::Vec2d& pos, double confid, double area) : radius(radius), pos(pos), confid(confid), taken(false), area(area) { //qDebug() << "radius" << radius << "pos" << pos[0] << pos[1] << "confid" << confid; } - bool inside(const simple_blob& other) + bool inside(const blob& other) { cv::Vec2d tmp = pos - other.pos; return sqrt(tmp.dot(tmp)) < radius; @@ -52,7 +52,7 @@ std::vector PointExtractor::extract_points(cv::Mat& frame) // mask for everything that passes the threshold (or: the upper threshold of the hysteresis) cv::Mat frame_bin = cv::Mat::zeros(H, W, CV_8U); - std::vector blobs; + std::vector blobs; std::vector> contours; const int thres = s.threshold; @@ -148,13 +148,13 @@ std::vector PointExtractor::extract_points(cv::Mat& frame) cv::putText(frame, buf, cv::Point(pos[0]+30, pos[1]+20), cv::FONT_HERSHEY_DUPLEX, 1, cv::Scalar(0, 0, 255), 1); } - blobs.push_back(simple_blob(radius, pos, confid, area)); + blobs.push_back(blob(radius, pos, confid, area)); } // clear old points points.clear(); - using b = const simple_blob; + using b = const blob; std::sort(blobs.begin(), blobs.end(), [](b& b1, b& b2) {return b1.confid > b2.confid;}); for (auto& b : blobs) -- cgit v1.2.3 From b27141f3a4e4756c8019dabbdbd49b5a7da09ef0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 17 Oct 2015 13:04:01 +0200 Subject: pt: refactor auto threshold somewhat --- ftnoir_tracker_pt/point_extractor.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ftnoir_tracker_pt') diff --git a/ftnoir_tracker_pt/point_extractor.cpp b/ftnoir_tracker_pt/point_extractor.cpp index f9be259ad..a1e61f288 100644 --- a/ftnoir_tracker_pt/point_extractor.cpp +++ b/ftnoir_tracker_pt/point_extractor.cpp @@ -76,8 +76,8 @@ std::vector PointExtractor::extract_points(cv::Mat& frame) const int sz = hist.rows*hist.cols; int val = 0; int cnt = 0; - constexpr int min_pixels = 2000; - const int pixels_to_include = std::max(0, static_cast(min_pixels * (1. - s.threshold / 100.))); + constexpr int min_pixels = 250; + const auto pixels_to_include = std::max(0, min_pixels * s.threshold/100.); for (int i = sz-1; i >= 0; i--) { cnt += hist.at(i); @@ -87,8 +87,8 @@ std::vector PointExtractor::extract_points(cv::Mat& frame) break; } } - val *= .95; - //qDebug() << "cnt" << cnt << "val" << val; + val *= 240./256.; + //qDebug() << "val" << val; cv::Mat frame_bin_; cv::threshold(frame_gray, frame_bin_, val, 255, CV_THRESH_BINARY); -- cgit v1.2.3 From 6dc31bc869c44c84429f3e52a033cbc09c1d3844 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 17 Oct 2015 16:31:41 +0200 Subject: pt: reformat posit --- ftnoir_tracker_pt/point_tracker.cpp | 240 ++++++++++++++++++------------------ 1 file changed, 120 insertions(+), 120 deletions(-) (limited to 'ftnoir_tracker_pt') diff --git a/ftnoir_tracker_pt/point_tracker.cpp b/ftnoir_tracker_pt/point_tracker.cpp index cedf1979a..383061c52 100644 --- a/ftnoir_tracker_pt/point_tracker.cpp +++ b/ftnoir_tracker_pt/point_tracker.cpp @@ -110,7 +110,7 @@ void PointTracker::track(const std::vector& points, const PointModel& order = find_correspondences(points, model); else order = find_correspondences_previous(points, model, f); - + POSIT(model, order, f); init_phase = false; t.start(); @@ -142,127 +142,127 @@ PointTracker::PointOrder PointTracker::find_correspondences(const std::vector and - cv::Vec2f I0_M0i(order[1][0]*(1.0 + epsilon_1) - order[0][0], - order[2][0]*(1.0 + epsilon_2) - order[0][0]); - cv::Vec2f J0_M0i(order[1][1]*(1.0 + epsilon_1) - order[0][1], - order[2][1]*(1.0 + epsilon_2) - order[0][1]); - - // construct projection of I, J onto M0i plane: I0 and J0 - I0_coeff = model.P * I0_M0i; - J0_coeff = model.P * J0_M0i; - I0 = I0_coeff[0]*model.M01 + I0_coeff[1]*model.M02; - J0 = J0_coeff[0]*model.M01 + J0_coeff[1]*model.M02; - - // calculate u component of I, J - float II0 = I0.dot(I0); - float IJ0 = I0.dot(J0); - float JJ0 = J0.dot(J0); - float rho, theta; - if (JJ0 == II0) { - rho = std::sqrt(std::abs(2*IJ0)); - 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) ); - if (JJ0 - II0 < 0) theta += PI; - theta /= 2; - } - - // construct the two solutions - I_1 = I0 + rho*cos(theta)*model.u; - I_2 = I0 - rho*cos(theta)*model.u; - - J_1 = J0 + rho*sin(theta)*model.u; - J_2 = J0 - rho*sin(theta)*model.u; - - float norm_const = 1.0/cv::norm(I_1); // all have the same norm - - // create rotation matrices - I_1 *= norm_const; J_1 *= norm_const; - I_2 *= norm_const; J_2 *= norm_const; - - set_row(R_1, 0, I_1); - set_row(R_1, 1, J_1); - set_row(R_1, 2, I_1.cross(J_1)); - - set_row(R_2, 0, I_2); - set_row(R_2, 1, J_2); - set_row(R_2, 2, I_2.cross(J_2)); - - // the single translation solution - Z0 = norm_const * focal_length; - - // pick the rotation solution closer to the expected one - // in simple metric d(A,B) = || I - A * B^T || - float R_1_deviation = cv::norm(cv::Matx33f::eye() - R_expected * R_1.t()); - float R_2_deviation = cv::norm(cv::Matx33f::eye() - R_expected * R_2.t()); - - if (R_1_deviation < R_2_deviation) - R_current = &R_1; - else - R_current = &R_2; - - get_row(*R_current, 2, k); - - // check for convergence condition - if (std::abs(epsilon_1 - old_epsilon_1) + std::abs(epsilon_2 - old_epsilon_2) < EPS_THRESHOLD) - break; - old_epsilon_1 = epsilon_1; - old_epsilon_2 = epsilon_2; - } - - // apply results - X_CM.R = *R_current; - X_CM.t[0] = order[0][0] * Z0/focal_length; - X_CM.t[1] = order[0][1] * Z0/focal_length; - X_CM.t[2] = Z0; - - //qDebug() << "iter:" << i; - - return i; + // POSIT algorithm for coplanar points as presented in + // [Denis Oberkampf, Daniel F. DeMenthon, Larry S. Davis: "Iterative Pose Estimation Using Coplanar Feature Points"] + // we use the same notation as in the paper here + + // The expected rotation used for resolving the ambiguity in POSIT: + // In every iteration step the rotation closer to R_expected is taken + cv::Matx33f R_expected = cv::Matx33f::eye(); + + // initial pose = last (predicted) pose + cv::Vec3f k; + get_row(R_expected, 2, k); + float Z0 = 1000.f; + + float old_epsilon_1 = 0; + float old_epsilon_2 = 0; + float epsilon_1 = 1; + float epsilon_2 = 1; + + cv::Vec3f I0, J0; + cv::Vec2f I0_coeff, J0_coeff; + + cv::Vec3f I_1, J_1, I_2, J_2; + cv::Matx33f R_1, R_2; + cv::Matx33f* R_current; + + const int MAX_ITER = 100; + const float EPS_THRESHOLD = 1e-4; + + const cv::Vec2f* order = order_.points; + + int i=1; + for (; i and + cv::Vec2f I0_M0i(order[1][0]*(1.0 + epsilon_1) - order[0][0], + order[2][0]*(1.0 + epsilon_2) - order[0][0]); + cv::Vec2f J0_M0i(order[1][1]*(1.0 + epsilon_1) - order[0][1], + order[2][1]*(1.0 + epsilon_2) - order[0][1]); + + // construct projection of I, J onto M0i plane: I0 and J0 + I0_coeff = model.P * I0_M0i; + J0_coeff = model.P * J0_M0i; + I0 = I0_coeff[0]*model.M01 + I0_coeff[1]*model.M02; + J0 = J0_coeff[0]*model.M01 + J0_coeff[1]*model.M02; + + // calculate u component of I, J + float II0 = I0.dot(I0); + float IJ0 = I0.dot(J0); + float JJ0 = J0.dot(J0); + float rho, theta; + if (JJ0 == II0) { + rho = std::sqrt(std::abs(2*IJ0)); + 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) ); + if (JJ0 - II0 < 0) theta += PI; + theta /= 2; + } + + // construct the two solutions + I_1 = I0 + rho*cos(theta)*model.u; + I_2 = I0 - rho*cos(theta)*model.u; + + J_1 = J0 + rho*sin(theta)*model.u; + J_2 = J0 - rho*sin(theta)*model.u; + + float norm_const = 1.0/cv::norm(I_1); // all have the same norm + + // create rotation matrices + I_1 *= norm_const; J_1 *= norm_const; + I_2 *= norm_const; J_2 *= norm_const; + + set_row(R_1, 0, I_1); + set_row(R_1, 1, J_1); + set_row(R_1, 2, I_1.cross(J_1)); + + set_row(R_2, 0, I_2); + set_row(R_2, 1, J_2); + set_row(R_2, 2, I_2.cross(J_2)); + + // the single translation solution + Z0 = norm_const * focal_length; + + // pick the rotation solution closer to the expected one + // in simple metric d(A,B) = || I - A * B^T || + float R_1_deviation = cv::norm(cv::Matx33f::eye() - R_expected * R_1.t()); + float R_2_deviation = cv::norm(cv::Matx33f::eye() - R_expected * R_2.t()); + + if (R_1_deviation < R_2_deviation) + R_current = &R_1; + else + R_current = &R_2; + + get_row(*R_current, 2, k); + + // check for convergence condition + if (std::abs(epsilon_1 - old_epsilon_1) + std::abs(epsilon_2 - old_epsilon_2) < EPS_THRESHOLD) + break; + old_epsilon_1 = epsilon_1; + old_epsilon_2 = epsilon_2; + } + + // apply results + X_CM.R = *R_current; + X_CM.t[0] = order[0][0] * Z0/focal_length; + X_CM.t[1] = order[0][1] * Z0/focal_length; + X_CM.t[2] = Z0; + + //qDebug() << "iter:" << i; + + return i; } cv::Vec2f PointTracker::project(const cv::Vec3f& v_M, float f) { - cv::Vec3f v_C = X_CM * v_M; - return cv::Vec2f(f*v_C[0]/v_C[2], f*v_C[1]/v_C[2]); + cv::Vec3f v_C = X_CM * v_M; + return cv::Vec2f(f*v_C[0]/v_C[2], f*v_C[1]/v_C[2]); } -- cgit v1.2.3 From 22857e786cd7462eb087cf039cefd36076784280 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 17 Oct 2015 17:15:53 +0200 Subject: pt: reformat more --- ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 42 ++++++++++---------- ftnoir_tracker_pt/point_tracker.cpp | 68 ++++++++++++++++----------------- 2 files changed, 55 insertions(+), 55 deletions(-) (limited to 'ftnoir_tracker_pt') diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp index 19d1bd7f2..11fe64cc3 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -19,8 +19,8 @@ Tracker_PT::Tracker_PT() : mutex(QMutex::Recursive), commands(0), - video_widget(NULL), - video_frame(NULL), + video_widget(NULL), + video_frame(NULL), ever_success(false) { connect(s.b.get(), SIGNAL(saving()), this, SLOT(apply_settings())); @@ -28,8 +28,8 @@ Tracker_PT::Tracker_PT() Tracker_PT::~Tracker_PT() { - set_command(ABORT); - wait(); + set_command(ABORT); + wait(); delete video_widget; video_widget = NULL; if (video_frame->layout()) delete video_frame->layout(); @@ -39,13 +39,13 @@ Tracker_PT::~Tracker_PT() void Tracker_PT::set_command(Command command) { //QMutexLocker lock(&mutex); - commands |= command; + commands |= command; } void Tracker_PT::reset_command(Command command) { //QMutexLocker lock(&mutex); - commands &= ~command; + commands &= ~command; } bool Tracker_PT::get_focal_length(float& ret) @@ -69,13 +69,13 @@ bool Tracker_PT::get_focal_length(float& ret) void Tracker_PT::run() { #ifdef PT_PERF_LOG - QFile log_file(QCoreApplication::applicationDirPath() + "/PointTrackerPerformance.txt"); - if (!log_file.open(QIODevice::WriteOnly | QIODevice::Text)) return; - QTextStream log_stream(&log_file); + QFile log_file(QCoreApplication::applicationDirPath() + "/PointTrackerPerformance.txt"); + if (!log_file.open(QIODevice::WriteOnly | QIODevice::Text)) return; + QTextStream log_stream(&log_file); #endif apply_settings(); - + while((commands & ABORT) == 0) { const double dt = time.elapsed() * 1e-9; @@ -97,20 +97,20 @@ void Tracker_PT::run() // blobs are sorted in order of circularity if (points.size() > PointModel::N_POINTS) points.resize(PointModel::N_POINTS); - + bool success = points.size() == PointModel::N_POINTS; - + ever_success |= success; float fx; if (!get_focal_length(fx)) continue; - + if (success) { point_tracker.track(points, PointModel(s), fx, s.dynamic_pose, s.init_phase_timeout); } - + { Affine X_CM = pose(); Affine X_MH(cv::Matx33f::eye(), cv::Vec3f(s.t_MH_x, s.t_MH_y, s.t_MH_z)); // just copy pasted these lines from below @@ -119,7 +119,7 @@ void Tracker_PT::run() cv::Vec2f p_(p[0] / p[2] * fx, p[1] / p[2] * fx); // projected to screen points.push_back(p_); } - + for (unsigned i = 0; i < points.size(); i++) { auto& p = points[i]; @@ -138,7 +138,7 @@ void Tracker_PT::run() color, 4); } - + video_widget->update_image(frame); } #ifdef PT_PERF_LOG @@ -181,26 +181,26 @@ void Tracker_PT::data(double *data) if (ever_success) { Affine X_CM = pose(); - + Affine X_MH(cv::Matx33f::eye(), cv::Vec3f(s.t_MH_x, s.t_MH_y, s.t_MH_z)); Affine X_GH = X_CM * X_MH; - + cv::Matx33f R = X_GH.R; cv::Vec3f t = X_GH.t; - + // translate rotation matrix from opengl (G) to roll-pitch-yaw (E) frame // -z -> x, y -> z, x -> -y cv::Matx33f R_EG(0, 0,-1, -1, 0, 0, 0, 1, 0); R = R_EG * R * R_EG.t(); - + // extract rotation angles float alpha, beta, gamma; beta = atan2( -R(2,0), sqrt(R(2,1)*R(2,1) + R(2,2)*R(2,2)) ); alpha = atan2( R(1,0), R(0,0)); gamma = atan2( R(2,1), R(2,2)); - + // extract rotation angles data[Yaw] = rad2deg * alpha; data[Pitch] = -rad2deg * beta; diff --git a/ftnoir_tracker_pt/point_tracker.cpp b/ftnoir_tracker_pt/point_tracker.cpp index 383061c52..cec107cf8 100644 --- a/ftnoir_tracker_pt/point_tracker.cpp +++ b/ftnoir_tracker_pt/point_tracker.cpp @@ -18,16 +18,16 @@ const float PI = 3.14159265358979323846f; // ---------------------------------------------------------------------------- static void get_row(const cv::Matx33f& m, int i, cv::Vec3f& v) { - v[0] = m(i,0); - v[1] = m(i,1); - v[2] = m(i,2); + v[0] = m(i,0); + v[1] = m(i,1); + v[2] = m(i,2); } static void set_row(cv::Matx33f& m, int i, const cv::Vec3f& v) { - m(i,0) = v[0]; - m(i,1) = v[1]; - m(i,2) = v[2]; + m(i,0) = v[0]; + m(i,1) = v[1]; + m(i,2) = v[2]; } static bool d_vals_sort(const std::pair a, const std::pair b) @@ -67,31 +67,31 @@ PointTracker::PointOrder PointTracker::find_correspondences_previous(const std:: // set correspondences by minimum distance to projected model point bool point_taken[PointModel::N_POINTS]; for (int i=0; i& points, const PointModel& { PointOrder order; - if (t.elapsed_ms() > init_phase_timeout) - { - t.start(); - init_phase = true; - } + if (t.elapsed_ms() > init_phase_timeout) + { + t.start(); + init_phase = true; + } if (!dynamic_pose || init_phase) order = find_correspondences(points, model); - else - order = find_correspondences_previous(points, model, f); + else + order = find_correspondences_previous(points, model, f); POSIT(model, order, f); - init_phase = false; + init_phase = false; t.start(); } -- cgit v1.2.3 From c89a1d04630cf7e334fa36b01c9240f0bc0b82c6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 18 Oct 2015 09:32:46 +0200 Subject: pt: use previous pose on NaN result from POSIT This will reset dynamic pose resolution if the error persists. --- ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 35 ++++++++++++++++++++++++++++++--- ftnoir_tracker_pt/point_tracker.h | 4 ++++ 2 files changed, 36 insertions(+), 3 deletions(-) (limited to 'ftnoir_tracker_pt') diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp index 11fe64cc3..29b32dad3 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -66,6 +66,11 @@ bool Tracker_PT::get_focal_length(float& ret) return false; } +static inline bool nanp(double value) +{ + return std::isnan(value) || std::isinf(value); +} + void Tracker_PT::run() { #ifdef PT_PERF_LOG @@ -100,19 +105,43 @@ void Tracker_PT::run() bool success = points.size() == PointModel::N_POINTS; - ever_success |= success; - float fx; if (!get_focal_length(fx)) continue; + Affine X_CM_ = pose(); + if (success) { point_tracker.track(points, PointModel(s), fx, s.dynamic_pose, s.init_phase_timeout); } + + Affine X_CM = pose(); + + { + int j = 0; + + for (int i = 0; i < 3; i++) + { + if (nanp(X_CM.t(i))) + goto nannan; + for (; j < 3; j++) + if (nanp(X_CM.R(i, j))) + { +nannan: success = false; + X_CM = X_CM_; + { + QMutexLocker lock(&mutex); + point_tracker.reset(X_CM_); + } + goto nannannan; + } + } + } + +nannannan: ever_success |= success; { - Affine X_CM = pose(); Affine X_MH(cv::Matx33f::eye(), cv::Vec3f(s.t_MH_x, s.t_MH_y, s.t_MH_z)); // just copy pasted these lines from below Affine X_GH = X_CM * X_MH; cv::Vec3f p = X_GH.t; // head (center?) position in global space diff --git a/ftnoir_tracker_pt/point_tracker.h b/ftnoir_tracker_pt/point_tracker.h index cdcf29982..fd0029489 100644 --- a/ftnoir_tracker_pt/point_tracker.h +++ b/ftnoir_tracker_pt/point_tracker.h @@ -118,6 +118,10 @@ public: void track(const std::vector& projected_points, const PointModel& model, float f, bool dynamic_pose, int init_phase_timeout); Affine pose() const { return X_CM; } cv::Vec2f project(const cv::Vec3f& v_M, float f); + void reset(const Affine& pose) + { + X_CM = pose; + } private: // the points in model order struct PointOrder -- cgit v1.2.3 From 6186f49000e6895b03661cd01c3f1c9c5950577a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 20 Oct 2015 03:23:57 +0200 Subject: all: comments only --- facetracknoir/main.cpp | 2 +- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp | 2 +- ftnoir_tracker_aruco/trans_calib.cpp | 1 - ftnoir_tracker_pt/point_tracker.cpp | 1 - opentrack-compat/shm.cpp | 5 ++++- opentrack-compat/sleep.hpp | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) (limited to 'ftnoir_tracker_pt') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 45483a684..a63fe54ac 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -42,7 +42,7 @@ int main(int argc, char** argv) // qt5 designer-made controls look like shit on 'doze -sh 20140921 // also our OSX look leaves a lot to be desired -sh 20150726 { - const QStringList preferred { "fusion", "windowsvista", "jazzbands'-marijuana", "macintosh", "windowsxp" }; + const QStringList preferred { "fusion", "windowsvista", "macintosh", "windowsxp" }; for (const auto& style_name : preferred) { QStyle* s = QStyleFactory::create(style_name); diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp index d77df027f..702a92d46 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp @@ -114,7 +114,7 @@ void FTNoIR_Protocol::pose(const double *headpose ) { // FSUIPC checks for already open connections and returns FSUIPC_ERR_OPEN in that case // the connection scope is global for the process. this is why above code doesn't // leak resources or have logic errors. see: http://www.purebasic.fr/english/viewtopic.php?t=31112 - FSUIPC_Close(); //timeout (1 second) so assume FS closed + FSUIPC_Close(); } } } diff --git a/ftnoir_tracker_aruco/trans_calib.cpp b/ftnoir_tracker_aruco/trans_calib.cpp index 176cf24c3..b5148efd6 100644 --- a/ftnoir_tracker_aruco/trans_calib.cpp +++ b/ftnoir_tracker_aruco/trans_calib.cpp @@ -7,7 +7,6 @@ #include "trans_calib.h" -//----------------------------------------------------------------------------- TranslationCalibrator::TranslationCalibrator() { reset(); diff --git a/ftnoir_tracker_pt/point_tracker.cpp b/ftnoir_tracker_pt/point_tracker.cpp index cec107cf8..924b75dea 100644 --- a/ftnoir_tracker_pt/point_tracker.cpp +++ b/ftnoir_tracker_pt/point_tracker.cpp @@ -15,7 +15,6 @@ const float PI = 3.14159265358979323846f; -// ---------------------------------------------------------------------------- static void get_row(const cv::Matx33f& m, int i, cv::Vec3f& v) { v[0] = m(i,0); diff --git a/opentrack-compat/shm.cpp b/opentrack-compat/shm.cpp index b18a9933d..029a4c95f 100644 --- a/opentrack-compat/shm.cpp +++ b/opentrack-compat/shm.cpp @@ -43,10 +43,13 @@ void PortableLockedShm::unlock() (void) ReleaseMutex(hMutex); } #else + +#include + #pragma GCC diagnostic ignored "-Wunused-result" PortableLockedShm::PortableLockedShm(const char *shmName, const char* /*mutexName*/, int mapSize) : size(mapSize) { - char filename[512] = {0}; + char filename[PATH_MAX+2] = {0}; strcpy(filename, "/"); strcat(filename, shmName); fd = shm_open(filename, O_RDWR | O_CREAT, 0600); diff --git a/opentrack-compat/sleep.hpp b/opentrack-compat/sleep.hpp index 279208428..e7c702852 100644 --- a/opentrack-compat/sleep.hpp +++ b/opentrack-compat/sleep.hpp @@ -3,7 +3,7 @@ namespace portable { #ifdef _WIN32 - #include +# include template void sleep(unsigned milliseconds) -- cgit v1.2.3 From d9746e7d4c4f7ed687c23b746914a9c5af8e9b49 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 20 Oct 2015 03:24:30 +0200 Subject: all: update copyright where appropriate --- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 26 ++++++++++++++----------- ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 1 + ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp | 1 + ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h | 1 + ftnoir_tracker_pt/point_extractor.cpp | 1 + ftnoir_tracker_pt/pt_video_widget.cpp | 1 + opentrack-compat/process-list.hpp | 7 +++++++ opentrack/shortcuts.cpp | 2 +- opentrack/win32-shortcuts.cpp | 8 ++++++++ qfunctionconfigurator/functionconfig.cpp | 8 ++++++++ qfunctionconfigurator/functionconfig.h | 2 +- qfunctionconfigurator/qfunctionconfigurator.cpp | 7 +++++++ qfunctionconfigurator/qfunctionconfigurator.h | 2 +- 13 files changed, 53 insertions(+), 14 deletions(-) (limited to 'ftnoir_tracker_pt') diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 5d7ab778a..0c6cb4868 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -1,9 +1,13 @@ -/* Copyright (c) 2015 Stanislaw Halik - * Copyright (c) 2015 Wim Vriend - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. +/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * + * * + * ISC License (ISC) * + * * + * Copyright (c) 2015, Wim Vriend + * Copyright (c) 2014, Stanislaw Halik + * * + * Permission to use, copy, modify, and/or distribute this software for any * + * purpose with or without fee is hereby granted, provided that the above * + * copyright notice and this permission notice appear in all copies. * */ #include "ftnoir_protocol_sc.h" #include "opentrack/plugin-api.hpp" @@ -80,7 +84,7 @@ public: # define PREFIX "" #else # define PREFIX "lib" -#endif +#endif QString path = QCoreApplication::applicationDirPath() + "/" PREFIX "opentrack-proto-simconnect.dll"; QByteArray name = QFile::encodeName(path); actx.lpSource = name.constData(); @@ -113,11 +117,11 @@ private: }; bool FTNoIR_Protocol::correct() -{ - if (!SCClientLib.isLoaded()) +{ + if (!SCClientLib.isLoaded()) { ActivationContext ctx(142 + static_cast(s.sxs_manifest)); - + if (ctx.is_ok()) { SCClientLib.setFileName("SimConnect.dll"); @@ -171,7 +175,7 @@ void FTNoIR_Protocol::handle() void CALLBACK FTNoIR_Protocol::processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD, void *self_) { FTNoIR_Protocol& self = *reinterpret_cast(self_); - + switch(pData->dwID) { default: diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp index 29b32dad3..2db5006c7 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -1,4 +1,5 @@ /* Copyright (c) 2012 Patrick Ruoff + * Copyright (c) 2014-2015 Stanislaw Halik * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp index da7a61134..b1ae2238b 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp @@ -1,4 +1,5 @@ /* Copyright (c) 2012 Patrick Ruoff + * Copyright (c) 2014-2015 Stanislaw Halik * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h index d7ddb6a90..85eec8f90 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h @@ -1,4 +1,5 @@ /* Copyright (c) 2012 Patrick Ruoff + * Copyright (c) 2014-2015 Stanislaw Halik * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above diff --git a/ftnoir_tracker_pt/point_extractor.cpp b/ftnoir_tracker_pt/point_extractor.cpp index a1e61f288..ec37dd004 100644 --- a/ftnoir_tracker_pt/point_extractor.cpp +++ b/ftnoir_tracker_pt/point_extractor.cpp @@ -1,4 +1,5 @@ /* Copyright (c) 2012 Patrick Ruoff + * Copyright (c) 2014-2015 Stanislaw Halik * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above diff --git a/ftnoir_tracker_pt/pt_video_widget.cpp b/ftnoir_tracker_pt/pt_video_widget.cpp index 9f2b90f69..cbb7c2687 100644 --- a/ftnoir_tracker_pt/pt_video_widget.cpp +++ b/ftnoir_tracker_pt/pt_video_widget.cpp @@ -1,4 +1,5 @@ /* Copyright (c) 2012 Patrick Ruoff + * Copyright (c) 2015 Stanislaw Halik * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above diff --git a/opentrack-compat/process-list.hpp b/opentrack-compat/process-list.hpp index 657357406..ef3b325fa 100644 --- a/opentrack-compat/process-list.hpp +++ b/opentrack-compat/process-list.hpp @@ -1,3 +1,10 @@ +/* Copyright (c) 2015 Stanislaw Halik + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + #pragma once #include diff --git a/opentrack/shortcuts.cpp b/opentrack/shortcuts.cpp index 3ad8e9bed..718dd778d 100644 --- a/opentrack/shortcuts.cpp +++ b/opentrack/shortcuts.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2014, Stanislaw Halik +/* Copyright (c) 2014-2015, Stanislaw Halik * Permission to use, copy, modify, and/or distribute this * software for any purpose with or without fee is hereby granted, diff --git a/opentrack/win32-shortcuts.cpp b/opentrack/win32-shortcuts.cpp index feaf60369..962326317 100644 --- a/opentrack/win32-shortcuts.cpp +++ b/opentrack/win32-shortcuts.cpp @@ -1,3 +1,11 @@ +/* Copyright (c) 2015, Stanislaw Halik + + * Permission to use, copy, modify, and/or distribute this + * software for any purpose with or without fee is hereby granted, + * provided that the above copyright notice and this permission + * notice appear in all copies. + */ + #if defined(_WIN32) # ifndef DIRECTINPUT_VERSION # define DIRECTINPUT_VERSION 0x800 diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 8c0bbc9f8..cac8121c5 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -1,3 +1,11 @@ +/* Copyright (c) 2012-2015, Stanislaw Halik + + * Permission to use, copy, modify, and/or distribute this + * software for any purpose with or without fee is hereby granted, + * provided that the above copyright notice and this permission + * notice appear in all copies. + */ + #include #include #include diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index 31aebdf63..6d76d0dec 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014, Stanislaw Halik +/* Copyright (c) 2012-2015, Stanislaw Halik * Permission to use, copy, modify, and/or distribute this * software for any purpose with or without fee is hereby granted, diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index e62049db2..bcb895ec9 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -1,3 +1,10 @@ +/* Copyright (c) 2012-2015 Stanislaw Halik + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + #include "opentrack/options.hpp" using namespace options; #include "qfunctionconfigurator/qfunctionconfigurator.h" diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index 8957c8988..667886cde 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2014 Stanislaw Halik +/* Copyright (c) 2012-2015 Stanislaw Halik * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above -- cgit v1.2.3