diff options
author | Stéphane Lenclud <github@lenclud.com> | 2019-04-21 13:15:57 +0200 |
---|---|---|
committer | Stéphane Lenclud <github@lenclud.com> | 2019-04-24 18:46:12 +0200 |
commit | a24e7bdd9745918f7d5fdc852ce65233b41363f9 (patch) | |
tree | 1ac100b2b0a835166c2d59e41b0c280f7c791add /tracker-easy/tracker-easy.cpp | |
parent | 028f2faa5f48e4beb77427ddd708f0372e0de97f (diff) |
Easy Tracker: PNP solver now a settings option.
Diffstat (limited to 'tracker-easy/tracker-easy.cpp')
-rw-r--r-- | tracker-easy/tracker-easy.cpp | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/tracker-easy/tracker-easy.cpp b/tracker-easy/tracker-easy.cpp index 199bf95a..ebc6e128 100644 --- a/tracker-easy/tracker-easy.cpp +++ b/tracker-easy/tracker-easy.cpp @@ -50,10 +50,13 @@ namespace EasyTracker // Make sure deadzones are updated whenever the settings are changed connect(&iSettings.DeadzoneRectHalfEdgeSize, value_::value_changed<int>(), this, &Tracker::UpdateDeadzones, Qt::DirectConnection); + UpdateDeadzones(iSettings.DeadzoneRectHalfEdgeSize); - CreateModelFromSettings(); + // Make sure solver is updated whenever the settings are changed + connect(&iSettings.PnpSolver, value_::value_changed<int>(), this, &Tracker::UpdateSolver, Qt::DirectConnection); + UpdateSolver(iSettings.PnpSolver); - UpdateDeadzones(iSettings.DeadzoneRectHalfEdgeSize); + CreateModelFromSettings(); } Tracker::~Tracker() @@ -62,9 +65,12 @@ namespace EasyTracker iThread.exit(); iThread.wait(); - - QMutexLocker l(&camera_mtx); - camera->stop(); + + if (camera) + { + QMutexLocker l(&camera_mtx); + camera->stop(); + } } @@ -156,8 +162,6 @@ namespace EasyTracker { ever_success.store(true, std::memory_order_relaxed); - // Solve P3P problem with OpenCV - //Bitmap origin is top left iTrackedPoints.clear(); // Tracked points must match the order of the object model points. @@ -233,15 +237,13 @@ namespace EasyTracker } } - dbgout << "Object: " << iModel << "\n"; dbgout << "Points: " << iTrackedPoints << "\n"; - - // TODO: try SOLVEPNP_AP3P too, make it a settings option? iAngles.clear(); iBestSolutionIndex = -1; - int solutionCount = cv::solveP3P(iModel, iTrackedPoints, iCameraMatrix, iDistCoeffsMatrix, iRotations, iTranslations, cv::SOLVEPNP_P3P); + // Solve P3P problem with OpenCV + int solutionCount = cv::solveP3P(iModel, iTrackedPoints, iCameraMatrix, iDistCoeffsMatrix, iRotations, iTranslations, iSolver); if (solutionCount > 0) { @@ -449,10 +451,23 @@ namespace EasyTracker } + void Tracker::UpdateSolver(int aSolver) + { + QMutexLocker l(¢er_lock); + iSolver = aSolver; + } + + + module_status Tracker::start_tracker(QFrame* video_frame) { - //video_frame->setAttribute(Qt::WA_NativeWindow); + // Check that we support that solver + if (iSolver!=cv::SOLVEPNP_P3P && iSolver != cv::SOLVEPNP_AP3P) + { + return module_status("Error: Solver not supported use either P3P or AP3P."); + } + //video_frame->setAttribute(Qt::WA_NativeWindow); widget = std::make_unique<video_widget>(video_frame); layout = std::make_unique<QHBoxLayout>(video_frame); layout->setContentsMargins(0, 0, 0, 0); |