diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-11-29 18:42:28 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-11-29 18:42:28 +0100 |
commit | e1ae4a738c011fbbe44e5203cc304dacb6489768 (patch) | |
tree | a60fe324e8b229cfcdfc74b3d85418cd91237763 | |
parent | a07eed2a0de09224adb1381d7744a2f98857836e (diff) |
aruco: rework timeout logicopentrack-2.3-rc21p2
- cycle otsu twice before selecting new box size
don't cycle otsu each frame.
- slower backoff from timeout value before new box size
on occasional detections need at least 5 successes for each failure
to not exceed.
- select more sensible timeout per box size of .35 seconds. this is
enough also with 30 Hz webcams, but too little for 15 Hz modes.
-rw-r--r-- | tracker-aruco/ftnoir_tracker_aruco.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/tracker-aruco/ftnoir_tracker_aruco.cpp b/tracker-aruco/ftnoir_tracker_aruco.cpp index 570c2e0d..2d364a86 100644 --- a/tracker-aruco/ftnoir_tracker_aruco.cpp +++ b/tracker-aruco/ftnoir_tracker_aruco.cpp @@ -124,13 +124,14 @@ void Tracker::run() cv::Rect last_roi(65535, 65535, 0, 0); + // XXX change to timer.hpp auto freq = cv::getTickFrequency(); auto last_time = cv::getTickCount(); double cur_fps = 0; std::vector<int> box_sizes { 5, 7, 9, 11 }; int box_idx = 0; - double failed = 0; - const double max_failed = 1.25; + double failed_otsu = 0; + const double max_failed_otsu = .35; cv::Vec3d rvec, tvec; cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); cv::Mat dist_coeffs = cv::Mat::zeros(5, 1, CV_32FC1); @@ -188,7 +189,7 @@ void Tracker::run() if (detector.detect(grayscale_, markers, cv::Mat(), cv::Mat(), -1, false), markers.size() == 1 && markers[0].size() == 4) { - failed = std::max(0., failed - dt); + failed_otsu = std::max(0., failed_otsu - dt*.2); auto& m = markers.at(0); for (int i = 0; i < 4; i++) { @@ -202,15 +203,19 @@ void Tracker::run() if (!roi_valid) { - otsu = !otsu; detector._thresMethod = otsu ? aruco::MarkerDetector::FIXED_THRES : aruco::MarkerDetector::ADPT_THRES; - failed += dt; - if (failed > max_failed) + failed_otsu += dt; + if (failed_otsu > max_failed_otsu) { - box_idx++; - box_idx %= box_sizes.size(); - qDebug() << "aruco: box size now" << box_sizes[box_idx]; - failed = 0; + if (otsu == true) + { + box_idx++; + box_idx %= box_sizes.size(); + qDebug() << "aruco: box size now" << box_sizes[box_idx]; + } + qDebug() << "aruco: otsu now" << !otsu; + failed_otsu = 0; + otsu = !otsu; } detector.setThresholdParams(box_sizes[box_idx], thres_param2); detector.setMinMaxSize(size_min, size_max); |