From 58989d52c2c0650611d26ab223ccd43f4891bb41 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 29 Nov 2013 10:07:56 +0100 Subject: Implement Aruco pitch change --- ftnoir_tracker_aruco/aruco-trackercontrols.ui | 28 ++++++++++++++++++++++++- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 30 ++++++++++++++++++++++----- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 2 +- 3 files changed, 53 insertions(+), 7 deletions(-) (limited to 'ftnoir_tracker_aruco') diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index 76d750af..8cf28057 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -10,7 +10,7 @@ 0 0 704 - 273 + 308 @@ -294,6 +294,32 @@ + + + + Pitch + + + + + + + ° + + + 2 + + + -60.000000000000000 + + + 60.000000000000000 + + + 0.000000000000000 + + + diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 41bf0edd..ddbdadb0 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -128,6 +128,8 @@ void Tracker::load_settings() { headpos[i] = iniFile.value(QString("headpos-%1").arg(i), 0).toDouble(); } + headpitch = iniFile.value("pitch", 0).toDouble(); + iniFile.endGroup(); } @@ -328,17 +330,27 @@ void Tracker::run() cv::Rodrigues(rvec, rotation_matrix); - cv::Vec3d foo = cv::RQDecomp3x3(rotation_matrix, junk1, junk2); - { + const double beta = headpitch * M_PI / 180; + double pitch[] = { + 1, 0, 0, + 0, cos(beta), -sin(beta), + 0, sin(beta), cos(beta) + }; + cv::Mat rot(3, 3, CV_64F, pitch); + tvec = rot * tvec; + rotation_matrix = rot * rotation_matrix; + + cv::Vec3d euler = cv::RQDecomp3x3(rotation_matrix, junk1, junk2); + QMutexLocker lck(&mtx); for (int i = 0; i < 3; i++) pose[i] = tvec.at(i); - pose[Yaw] = foo[1]; - pose[Pitch] = -foo[0]; - pose[Roll] = foo[2]; + pose[Yaw] = euler[1]; + pose[Pitch] = -euler[0]; + pose[Roll] = euler[2]; } std::vector repr2; @@ -346,6 +358,11 @@ void Tracker::run() centroid.push_back(cv::Point3f(0, 0, 0)); cv::projectPoints(centroid, rvec, tvec, intrinsics, dist_coeffs, repr2); + { + auto s = cv::Scalar(255, 0, 255); + cv::circle(frame, repr2.at(0), 4, s, -1); + } + last_centroid = repr2[0]; } else @@ -527,6 +544,8 @@ void TrackerControls::loadSettings() headpos[i]->setValue(iniFile.value(QString("headpos-%1").arg(i)).toDouble()); } + ui.pitch_deg->setValue(iniFile.value("pitch", 0).toDouble()); + iniFile.endGroup(); settingsDirty = false; } @@ -565,6 +584,7 @@ void TrackerControls::save() iniFile.setValue("enable-ty", ui.ty->checkState() != Qt::Unchecked ? true : false); iniFile.setValue("enable-tz", ui.tz->checkState() != Qt::Unchecked ? true : false); iniFile.setValue("resolution", ui.resolution->currentIndex()); + iniFile.setValue("pitch", ui.pitch_deg->value()); QDoubleSpinBox* headpos[] = { ui.cx, diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 3a2ebeea..1518ba4d 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -40,7 +40,7 @@ private: int force_fps, force_width, force_height; double pose[6]; cv::Mat frame; - double headpos[3]; + double headpos[3], headpitch; cv::VideoCapture camera; }; -- cgit v1.2.3