summaryrefslogtreecommitdiffhomepage
path: root/tracker-aruco
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-11-29 18:42:28 +0100
committerStanislaw Halik <sthalik@misaki.pl>2015-11-29 18:42:28 +0100
commite1ae4a738c011fbbe44e5203cc304dacb6489768 (patch)
treea60fe324e8b229cfcdfc74b3d85418cd91237763 /tracker-aruco
parenta07eed2a0de09224adb1381d7744a2f98857836e (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.
Diffstat (limited to 'tracker-aruco')
-rw-r--r--tracker-aruco/ftnoir_tracker_aruco.cpp25
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);