From 74d9f5e31428ef362033a63c10b781d943c5e5a5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 13 May 2016 13:19:31 +0200 Subject: many: remove unneeded implicit type conversion double <-> float --- tracker-aruco/ftnoir_tracker_aruco.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'tracker-aruco') diff --git a/tracker-aruco/ftnoir_tracker_aruco.cpp b/tracker-aruco/ftnoir_tracker_aruco.cpp index 316c7e13..294552ea 100644 --- a/tracker-aruco/ftnoir_tracker_aruco.cpp +++ b/tracker-aruco/ftnoir_tracker_aruco.cpp @@ -216,27 +216,29 @@ void Tracker::run() ::sprintf(buf, "Hz: %d", (int)cur_fps); cv::putText(frame, buf, cv::Point(10, 32), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(0, 255, 0), scale*2); + const float hx = s.headpos_x, hy = s.headpos_y, hz = s.headpos_z; + if (markers.size() == 1 && markers[0].size() == 4) { const auto& m = markers.at(0); - const float size = 40; + constexpr float size = 40; cv::Mat obj_points(4,3,CV_32FC1); const int x1=1, x2=2, x3=3, x4=0; - obj_points.at(x1,0)=-size + s.headpos_x; - obj_points.at(x1,1)=-size + s.headpos_y; - obj_points.at(x1,2)= 0 + s.headpos_z; + obj_points.at(x1,0)=-size + hx; + obj_points.at(x1,1)=-size + hy; + obj_points.at(x1,2)= 0 + hz; - obj_points.at(x2,0)=size + s.headpos_x; - obj_points.at(x2,1)=-size + s.headpos_y; - obj_points.at(x2,2)= 0 + s.headpos_z; + obj_points.at(x2,0)=size + hx; + obj_points.at(x2,1)=-size + hy; + obj_points.at(x2,2)= 0 + hz; - obj_points.at(x3,0)=size + s.headpos_x; - obj_points.at(x3,1)=size + s.headpos_y; - obj_points.at(x3,2)= 0 + s.headpos_z; + obj_points.at(x3,0)=size + hx; + obj_points.at(x3,1)=size + hy; + obj_points.at(x3,2)= 0 + hz; - obj_points.at(x4,0)= -size + s.headpos_x; - obj_points.at(x4,1)= size + s.headpos_y; - obj_points.at(x4,2)= 0 + s.headpos_z; + obj_points.at(x4,0)= -size + hx; + obj_points.at(x4,1)= size + hy; + obj_points.at(x4,2)= 0 + hz; std::vector img_points = m; if (!cv::solvePnP(obj_points, img_points, intrinsics, dist_coeffs, rvec, tvec, false, cv::SOLVEPNP_ITERATIVE)) @@ -256,9 +258,9 @@ void Tracker::run() for (int i = 0; i < 4; i++) { - obj_points.at(i, 0) -= s.headpos_x; - obj_points.at(i, 1) -= s.headpos_y; - obj_points.at(i, 2) -= s.headpos_z; + obj_points.at(i, 0) -= hx; + obj_points.at(i, 1) -= hy; + obj_points.at(i, 2) -= hz; } cv::Mat rvec_, tvec_; -- cgit v1.2.3