From 5b3d825f1eace207502371427e15d8b54a237f83 Mon Sep 17 00:00:00 2001 From: Stéphane Lenclud Date: Sun, 28 Apr 2019 18:45:08 +0200 Subject: Easy Tracker: Auto center configurable from settings. --- tracker-easy/lang/nl_NL.ts | 20 ++++++ tracker-easy/lang/ru_RU.ts | 20 ++++++ tracker-easy/lang/stub.ts | 20 ++++++ tracker-easy/lang/zh_CN.ts | 20 ++++++ tracker-easy/settings.h | 2 + tracker-easy/tracker-easy-dialog.cpp | 3 + tracker-easy/tracker-easy-settings.ui | 129 ++++++++++++++++++++++++++-------- tracker-easy/tracker-easy.cpp | 58 +++++++-------- 8 files changed, 213 insertions(+), 59 deletions(-) diff --git a/tracker-easy/lang/nl_NL.ts b/tracker-easy/lang/nl_NL.ts index fe73b271..9c4e1843 100644 --- a/tracker-easy/lang/nl_NL.ts +++ b/tracker-easy/lang/nl_NL.ts @@ -206,5 +206,25 @@ <html><head/><body><p><span style=" font-weight:600;">Easy Tracker<br/>Version 1.0</span></p><p><span style=" font-weight:600;">by Stéphane Lenclud</span></p><p>See <a href="https://github.com/opentrack/opentrack/wiki/Easy-Tracker"><span style=" font-weight:600; text-decoration: underline; color:#9999aa;">documentation on GitHub</span></a></p></body></html> + + Auto center + + + + <html><head/><body><p>Use P3P or AP3P for three and four points setup. Use EPNP or ITERATIVE for five points setup. Inconsistent configuration will result in undefined behavior.</p></body></html> + + + + Auto center timeout + + + + If no valid pose can be determined after that much time the center pose will be used. + + + + ms + + diff --git a/tracker-easy/lang/ru_RU.ts b/tracker-easy/lang/ru_RU.ts index 022acd68..6499415f 100644 --- a/tracker-easy/lang/ru_RU.ts +++ b/tracker-easy/lang/ru_RU.ts @@ -206,5 +206,25 @@ <html><head/><body><p><span style=" font-weight:600;">Easy Tracker<br/>Version 1.0</span></p><p><span style=" font-weight:600;">by Stéphane Lenclud</span></p><p>See <a href="https://github.com/opentrack/opentrack/wiki/Easy-Tracker"><span style=" font-weight:600; text-decoration: underline; color:#9999aa;">documentation on GitHub</span></a></p></body></html> + + Auto center + + + + <html><head/><body><p>Use P3P or AP3P for three and four points setup. Use EPNP or ITERATIVE for five points setup. Inconsistent configuration will result in undefined behavior.</p></body></html> + + + + Auto center timeout + + + + If no valid pose can be determined after that much time the center pose will be used. + + + + ms + + diff --git a/tracker-easy/lang/stub.ts b/tracker-easy/lang/stub.ts index 60c84d35..7b6facec 100644 --- a/tracker-easy/lang/stub.ts +++ b/tracker-easy/lang/stub.ts @@ -206,5 +206,25 @@ <html><head/><body><p><span style=" font-weight:600;">Easy Tracker<br/>Version 1.0</span></p><p><span style=" font-weight:600;">by Stéphane Lenclud</span></p><p>See <a href="https://github.com/opentrack/opentrack/wiki/Easy-Tracker"><span style=" font-weight:600; text-decoration: underline; color:#9999aa;">documentation on GitHub</span></a></p></body></html> + + Auto center + + + + <html><head/><body><p>Use P3P or AP3P for three and four points setup. Use EPNP or ITERATIVE for five points setup. Inconsistent configuration will result in undefined behavior.</p></body></html> + + + + Auto center timeout + + + + If no valid pose can be determined after that much time the center pose will be used. + + + + ms + + diff --git a/tracker-easy/lang/zh_CN.ts b/tracker-easy/lang/zh_CN.ts index ee89b5b6..bbd8aff1 100644 --- a/tracker-easy/lang/zh_CN.ts +++ b/tracker-easy/lang/zh_CN.ts @@ -206,5 +206,25 @@ <html><head/><body><p><span style=" font-weight:600;">Easy Tracker<br/>Version 1.0</span></p><p><span style=" font-weight:600;">by Stéphane Lenclud</span></p><p>See <a href="https://github.com/opentrack/opentrack/wiki/Easy-Tracker"><span style=" font-weight:600; text-decoration: underline; color:#9999aa;">documentation on GitHub</span></a></p></body></html> + + Auto center + + + + <html><head/><body><p>Use P3P or AP3P for three and four points setup. Use EPNP or ITERATIVE for five points setup. Inconsistent configuration will result in undefined behavior.</p></body></html> + + + + Auto center timeout + + + + If no valid pose can be determined after that much time the center pose will be used. + + + + ms + + diff --git a/tracker-easy/settings.h b/tracker-easy/settings.h index 5a4dff84..b0f14417 100644 --- a/tracker-easy/settings.h +++ b/tracker-easy/settings.h @@ -44,6 +44,8 @@ namespace EasyTracker { value fov{ b, "camera-fov", 56 }; value debug{ b, "debug", false }; + value iAutoCenter{ b, "iAutoCenter", true }; + value iAutoCenterTimeout{ b, "iAutoCenterTimeout", 1000 }; value PnpSolver{ b, "pnp-solver", cv::SOLVEPNP_P3P }; diff --git a/tracker-easy/tracker-easy-dialog.cpp b/tracker-easy/tracker-easy-dialog.cpp index d1aafee1..8c8356d1 100644 --- a/tracker-easy/tracker-easy-dialog.cpp +++ b/tracker-easy/tracker-easy-dialog.cpp @@ -72,6 +72,9 @@ namespace EasyTracker tie_setting(s.debug, ui.debug); + tie_setting(s.iAutoCenter, ui.iCheckBoxAutoCenter); + tie_setting(s.iAutoCenterTimeout, ui.iSpinBoxAutoCenterTimeout); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); diff --git a/tracker-easy/tracker-easy-settings.ui b/tracker-easy/tracker-easy-settings.ui index c6c3fbd7..451b3e54 100644 --- a/tracker-easy/tracker-easy-settings.ui +++ b/tracker-easy/tracker-easy-settings.ui @@ -61,7 +61,7 @@ - 2 + 0 @@ -289,8 +289,21 @@ Settings - - + + + + + + 0 + 0 + + + + Debug (full size preview) + + + + @@ -306,24 +319,24 @@ - - + + 0 0 - - Deadzone + + Minimum point diameter - - maxdiam_spin + + px - - + + 0 @@ -331,12 +344,25 @@ - Max size + - - + + + + + 0 + 0 + + + + + + + + + 0 @@ -344,12 +370,12 @@ - Debug (full size preview) + Auto center - - + + 0 @@ -357,11 +383,27 @@ - + Max size - + + + + + 0 + 0 + + + + Size in pixels of half the edge defining deadzone squares around tracked points + + + px + + + + @@ -369,12 +411,15 @@ 0 + + <html><head/><body><p>Use P3P or AP3P for three and four points setup. Use EPNP or ITERATIVE for five points setup. Inconsistent configuration will result in undefined behavior.</p></body></html> + Perspective-N-Point solver - + @@ -420,23 +465,23 @@ - - + + 0 0 - - Size in pixels of half the edge defining deadzone squares around tracked points + + Deadzone - - px + + maxdiam_spin - + @@ -452,8 +497,24 @@ - - + + + + + 0 + 0 + + + + Auto center timeout + + + mindiam_spin + + + + + 0 @@ -461,10 +522,16 @@ - Minimum point diameter + If no valid pose can be determined after that much time the center pose will be used. - px + ms + + + 3600000 + + + 500 diff --git a/tracker-easy/tracker-easy.cpp b/tracker-easy/tracker-easy.cpp index 1bb6b5e1..e13bdf37 100644 --- a/tracker-easy/tracker-easy.cpp +++ b/tracker-easy/tracker-easy.cpp @@ -117,33 +117,6 @@ namespace EasyTracker eulerAngles); } - /// - /// Create our model from settings specifications - /// - void Tracker::UpdateModel() - { - infout << "Update model"; - - QMutexLocker lock(&iProcessLock); - // Construct the points defining the object we want to detect based on settings. - // We are converting them from millimeters to centimeters. - // TODO: Need to support clip too. That's cap only for now. - iModel.clear(); - iModel.push_back(cv::Point3f(iSettings.iVertexTopX / 10.0, iSettings.iVertexTopY / 10.0, iSettings.iVertexTopZ / 10.0)); // Top - iModel.push_back(cv::Point3f(iSettings.iVertexRightX / 10.0, iSettings.iVertexRightY / 10.0, iSettings.iVertexRightZ / 10.0)); // Right - iModel.push_back(cv::Point3f(iSettings.iVertexLeftX / 10.0, iSettings.iVertexLeftY / 10.0, iSettings.iVertexLeftZ / 10.0)); // Left - - if (iSettings.iCustomModelFour) - { - iModel.push_back(cv::Point3f(iSettings.iVertexCenterX / 10.0, iSettings.iVertexCenterY / 10.0, iSettings.iVertexCenterZ / 10.0)); // Center - } - else if (iSettings.iCustomModelFive) - { - iModel.push_back(cv::Point3f(iSettings.iVertexTopRightX / 10.0, iSettings.iVertexTopRightY / 10.0, iSettings.iVertexTopRightZ / 10.0)); // Top Right - iModel.push_back(cv::Point3f(iSettings.iVertexTopLeftX / 10.0, iSettings.iVertexTopLeftY / 10.0, iSettings.iVertexTopLeftZ / 10.0)); // Top Left - } - } - /// void Tracker::CreateCameraIntrinsicsMatrices() { @@ -700,6 +673,34 @@ namespace EasyTracker iKf.Init(18, 6, 0, dt); } + + /// + /// Create our model from settings specifications + /// + void Tracker::UpdateModel() + { + infout << "Update model"; + + QMutexLocker lock(&iProcessLock); + // Construct the points defining the object we want to detect based on settings. + // We are converting them from millimeters to centimeters. + // TODO: Need to support clip too. That's cap only for now. + iModel.clear(); + iModel.push_back(cv::Point3f(iSettings.iVertexTopX / 10.0, iSettings.iVertexTopY / 10.0, iSettings.iVertexTopZ / 10.0)); // Top + iModel.push_back(cv::Point3f(iSettings.iVertexRightX / 10.0, iSettings.iVertexRightY / 10.0, iSettings.iVertexRightZ / 10.0)); // Right + iModel.push_back(cv::Point3f(iSettings.iVertexLeftX / 10.0, iSettings.iVertexLeftY / 10.0, iSettings.iVertexLeftZ / 10.0)); // Left + + if (iSettings.iCustomModelFour) + { + iModel.push_back(cv::Point3f(iSettings.iVertexCenterX / 10.0, iSettings.iVertexCenterY / 10.0, iSettings.iVertexCenterZ / 10.0)); // Center + } + else if (iSettings.iCustomModelFive) + { + iModel.push_back(cv::Point3f(iSettings.iVertexTopRightX / 10.0, iSettings.iVertexTopRightY / 10.0, iSettings.iVertexTopRightZ / 10.0)); // Top Right + iModel.push_back(cv::Point3f(iSettings.iVertexTopLeftX / 10.0, iSettings.iVertexTopLeftY / 10.0, iSettings.iVertexTopLeftZ / 10.0)); // Top Left + } + } + /// /// Take a copy of the settings needed by our thread to avoid deadlocks /// @@ -715,6 +716,7 @@ namespace EasyTracker iDebug = iSettings.debug; } + /// module_status Tracker::start_tracker(QFrame* video_frame) { // Check that we support that solver @@ -773,7 +775,7 @@ namespace EasyTracker QMutexLocker l(&iDataLock); // If there was no new data recently then we provide center data. // Basically, if our user remove her hat, we will go back to center position until she puts it back on. - if (iBestTime.elapsed_seconds() > 1) + if (iSettings.iAutoCenter && iBestTime.elapsed_ms() > iSettings.iAutoCenterTimeout) { // Reset to center until we get new data FeedData(aData, iCenterAngles, iCenterTranslation); -- cgit v1.2.3