summaryrefslogtreecommitdiffhomepage
path: root/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tracker-neuralnet/ftnoir_tracker_neuralnet.cpp')
-rw-r--r--tracker-neuralnet/ftnoir_tracker_neuralnet.cpp43
1 files changed, 27 insertions, 16 deletions
diff --git a/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp b/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp
index a919bb81..c55ddf0c 100644
--- a/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp
+++ b/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp
@@ -66,13 +66,26 @@ QDir get_default_model_directory()
int enum_to_fps(int value)
{
+ int fps = 0;
+
switch (value)
{
- case fps_30: return 30;
- case fps_60: return 60;
- default: [[fallthrough]];
- case fps_default: return 0;
+ default: eval_once(qDebug() << "neuralnet tracker: invalid fps enum value");
+ [[fallthrough]];
+ case fps_default: fps = 0; break;
+ case fps_30: fps = 30; break;
+ case fps_60: fps = 60; break;
+ case fps_75: fps = 75; break;
+ case fps_125: fps = 125; break;
+ case fps_200: fps = 200; break;
+ case fps_50: fps = 50; break;
+ case fps_100: fps = 100; break;
+ case fps_120: fps = 120; break;
+ case fps_300: fps = 300; break;
+ case fps_250: fps = 250; break;
}
+
+ return fps;
}
@@ -414,7 +427,7 @@ QuatPose NeuralNetTracker::transform_to_world_pose(const cv::Quatf &face_rotatio
QuatPose NeuralNetTracker::compute_filtered_pose(const PoseEstimator::Face &face)
{
- if (fps_ > 0.01 && last_pose_ && poseestimator_->has_uncertainty())
+ if (fps_ > 0.001 && last_pose_ && poseestimator_->has_uncertainty())
{
auto image2world = [this](const cv::Quatf &face_rotation, const cv::Point2f& face_xy, const float face_size) {
return this->transform_to_world_pose(face_rotation, face_xy, face_size); };
@@ -667,14 +680,20 @@ void NeuralNetTracker::data(double *data)
const auto& my = tmp.R.col(1);
const auto& mz = tmp.R.col(2);
+ // For reference: https://en.wikipedia.org/wiki/Euler_angles. Section "Rotation matrix". The relevant matrix is
+ // under "Tait-Bryan angles", row with "Y_alpha Z_beta X_gamma = ...".
+ // Because for the NN tracker x is forward, and y is up. We can see that the x axis is independent of roll. Thus it
+ // is relatively easy to figure out the yaw and pitch angles (alpha and beta).
const float yaw = std::atan2(mx(2), mx(0));
const float pitch = -std::atan2(-mx(1), std::sqrt(mx(2)*mx(2)+mx(0)*mx(0)));
- const float roll = std::atan2(-my(2), mz(2));
+ // For the roll angle we recognize that the matrix entries in the second row contain cos(pitch)*cos(roll), and
+ // cos(pitch)*sin(roll). Using atan2 eliminates the common pitch factor and we obtain the roll angle.
+ const float roll = std::atan2(-mz(1), my(1));
{
constexpr double rad2deg = 180/M_PI;
data[Yaw] = rad2deg * yaw;
data[Pitch] = rad2deg * pitch;
- data[Roll] = rad2deg * roll;
+ data[Roll] = -rad2deg * roll;
// convert to cm
data[TX] = -tmp.t[2] * 0.1;
@@ -707,14 +726,6 @@ QString NeuralNetTracker::get_posenet_filename() const
}
-
-
-
-
-
-
-
-
void NeuralNetDialog::make_fps_combobox()
{
for (int k = 0; k < fps_MAX; k++)
@@ -855,7 +866,7 @@ void NeuralNetDialog::status_poll()
else
{
auto [ res, fps, inference_time ] = tracker_->stats();
- status = tr("%1x%2 @ %3 FPS / Inference: %4 ms").arg(res.width).arg(res.height).arg(int(fps)).arg(int(inference_time));
+ status = tr("%1x%2 @ %3 FPS / Inference: %4 ms").arg(res.width).arg(res.height).arg(int(fps)).arg(inference_time, 0, 'f', 1);
}
ui_.resolution_display->setText(status);
}