diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-01-20 13:50:43 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-01-23 14:16:35 +0100 |
commit | 45e48310779c8adec67de7cf76328aa7bd034466 (patch) | |
tree | 40daded34f4c190e172964f1af47dc05566b2e5d | |
parent | 7b3af1e239b51e63a5956bc13e7528ad6e776689 (diff) |
tracker/nn: try fixing center on startup
-rw-r--r-- | tracker-neuralnet/ftnoir_tracker_neuralnet.cpp | 10 | ||||
-rw-r--r-- | tracker-neuralnet/ftnoir_tracker_neuralnet.h | 3 |
2 files changed, 9 insertions, 4 deletions
diff --git a/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp b/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp index e9a490fa..d8077326 100644 --- a/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp +++ b/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp @@ -353,7 +353,7 @@ bool NeuralNetTracker::detect() last_pose_affine_ = pose_affine; } - draw_gizmos(*face, last_pose_affine_); + draw_gizmos(*face, pose_affine); return true; } @@ -652,12 +652,16 @@ void NeuralNetTracker::update_fps(double dt) void NeuralNetTracker::data(double *data) { - Affine tmp = [&]() + auto tmp2 = [&]() { QMutexLocker lck(&mtx_); return last_pose_affine_; }(); + if (!tmp2) + return; + const auto& tmp = *tmp2; + const auto& mx = tmp.R.col(0); const auto& my = tmp.R.col(1); const auto& mz = -tmp.R.col(2); @@ -682,7 +686,7 @@ void NeuralNetTracker::data(double *data) Affine NeuralNetTracker::pose() { QMutexLocker lck(&mtx_); - return last_pose_affine_; + return last_pose_affine_ ? *last_pose_affine_ : Affine{}; } std::tuple<cv::Size,double, double> NeuralNetTracker::stats() const diff --git a/tracker-neuralnet/ftnoir_tracker_neuralnet.h b/tracker-neuralnet/ftnoir_tracker_neuralnet.h index 3548335e..df71a7a8 100644 --- a/tracker-neuralnet/ftnoir_tracker_neuralnet.h +++ b/tracker-neuralnet/ftnoir_tracker_neuralnet.h @@ -31,6 +31,7 @@ #include <memory> #include <cinttypes> #include <array> +#include <optional> #include <opencv2/core.hpp> #include <opencv2/imgproc.hpp> @@ -151,7 +152,7 @@ private: QMutex mtx_ = {}; // Protects the pose std::optional<QuatPose> last_pose_ = {}; - Affine last_pose_affine_ = {}; + std::optional<Affine> last_pose_affine_ = {}; Preview preview_; std::unique_ptr<cv_video_widget> video_widget_; |