diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-12-31 06:16:07 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-12-31 07:52:52 +0100 |
commit | b0d9aef7b6e9c3c06450cc11ee107abbf6af1d32 (patch) | |
tree | 23987a184ff32f61e588de74682c5619ce2f2bf9 | |
parent | f33fc78dc4bdb977bb358bf7e905ef2d4e093b3d (diff) |
tracker/aruco: implement asymmetric marker skew support
It may allow for full pitch range support. We're testing it in #517.
-rw-r--r-- | tracker-aruco/ftnoir_tracker_aruco.cpp | 35 | ||||
-rw-r--r-- | tracker-aruco/ftnoir_tracker_aruco.h | 11 |
2 files changed, 41 insertions, 5 deletions
diff --git a/tracker-aruco/ftnoir_tracker_aruco.cpp b/tracker-aruco/ftnoir_tracker_aruco.cpp index f89b1e7d..15955692 100644 --- a/tracker-aruco/ftnoir_tracker_aruco.cpp +++ b/tracker-aruco/ftnoir_tracker_aruco.cpp @@ -217,6 +217,22 @@ void aruco_tracker::clamp_last_roi() last_roi &= cv::Rect(0, 0, color.cols, color.rows); } +cv::Point3f aruco_tracker::rotate_model(float x, float y, settings::rot mode) +{ + cv::Point3f pt(x, y, 0); + + if (mode) + { + using std::cos; + using std::sin; + + const float theta = int(mode) * 90/4. * M_PI/180; + pt.x = x * cos(theta) - y * sin(theta); + pt.y = y * cos(theta) + x * sin(theta); + } + return pt; +} + void aruco_tracker::set_points() { using f = float; @@ -226,10 +242,15 @@ void aruco_tracker::set_points() const int x1=1, x2=2, x3=3, x4=0; - obj_points[x1] = cv::Point3f(-size + hx, -size + hy, 0 + hz); - obj_points[x2] = cv::Point3f(size + hx, -size + hy, 0 + hz); - obj_points[x3] = cv::Point3f(size + hx, size + hy, 0 + hz); - obj_points[x4] = cv::Point3f(-size + hx, size + hy, 0 + hz); + settings::rot mode = s.model_rotation; + + obj_points[x1] = rotate_model(-size, -size, mode); + obj_points[x2] = rotate_model(size, -size, mode); + obj_points[x3] = rotate_model(size, size, mode); + obj_points[x4] = rotate_model(-size, size, mode); + + for (unsigned i = 0; i < 4; i++) + obj_points[i] += cv::Point3f(hx, hy, hz); } void aruco_tracker::draw_centroid() @@ -386,6 +407,12 @@ aruco_dialog::aruco_dialog() tie_setting(s.headpos_x, ui.cx); tie_setting(s.headpos_y, ui.cy); tie_setting(s.headpos_z, ui.cz); + + ui.model_rotation->addItem("0", int(settings::rot_zero)); + ui.model_rotation->addItem("+22.5", int(settings::rot_plus)); + ui.model_rotation->addItem("-22.5", int(settings::rot_neg)); + tie_setting(s.model_rotation, ui.model_rotation); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); connect(ui.btn_calibrate, SIGNAL(clicked()), this, SLOT(toggleCalibrate())); diff --git a/tracker-aruco/ftnoir_tracker_aruco.h b/tracker-aruco/ftnoir_tracker_aruco.h index cdea1e42..aa3c59f7 100644 --- a/tracker-aruco/ftnoir_tracker_aruco.h +++ b/tracker-aruco/ftnoir_tracker_aruco.h @@ -31,10 +31,18 @@ using namespace options; struct settings : opts { + enum rot + { + rot_zero = 0, + rot_neg = -1, + rot_plus = +1, + }; + value<int> fov; value<double> headpos_x, headpos_y, headpos_z; value<QString> camera_name; value<int> force_fps, resolution; + value<rot> model_rotation; settings() : opts("aruco-tracker"), fov(b, "field-of-view", 56), @@ -43,7 +51,8 @@ struct settings : opts { headpos_z(b, "headpos-z", 0), camera_name(b, "camera-name", ""), force_fps(b, "force-fps", 0), - resolution(b, "force-resolution", 0) + resolution(b, "force-resolution", 0), + model_rotation(b, "model-rotation", rot_zero) {} }; |