summaryrefslogtreecommitdiffhomepage
path: root/tracker-aruco
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-12-03 22:58:58 +0100
committerStanislaw Halik <sthalik@misaki.pl>2015-12-03 22:58:58 +0100
commite98880adc20988fadacc72f2a520bf0a674f135e (patch)
treed887e4b0a75f1aac37695ebeee05cb4b69e37b00 /tracker-aruco
parent3ac3eb2b4874782bac4aeac14cc39e63c1188acd (diff)
aruco: use only Otsu thresholding, never adaptive
Detection rate stays as good, likely better as before. @mursey reports in #274 that non-Otsu case eats way more CPU.
Diffstat (limited to 'tracker-aruco')
-rw-r--r--tracker-aruco/ftnoir_tracker_aruco.cpp29
1 files changed, 11 insertions, 18 deletions
diff --git a/tracker-aruco/ftnoir_tracker_aruco.cpp b/tracker-aruco/ftnoir_tracker_aruco.cpp
index 2d364a86..32c81694 100644
--- a/tracker-aruco/ftnoir_tracker_aruco.cpp
+++ b/tracker-aruco/ftnoir_tracker_aruco.cpp
@@ -121,6 +121,7 @@ void Tracker::run()
aruco::MarkerDetector detector;
detector.setDesiredSpeed(3);
+ detector._thresMethod = aruco::MarkerDetector::FIXED_THRES;
cv::Rect last_roi(65535, 65535, 0, 0);
@@ -128,14 +129,13 @@ void Tracker::run()
auto freq = cv::getTickFrequency();
auto last_time = cv::getTickCount();
double cur_fps = 0;
- std::vector<int> box_sizes { 5, 7, 9, 11 };
+ std::vector<int> box_sizes { 5, 9, 13 };
int box_idx = 0;
- double failed_otsu = 0;
- const double max_failed_otsu = .35;
+ double failed = 0;
+ const double max_failed = .8;
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);
- bool otsu = false;
while (!stop)
{
@@ -181,7 +181,6 @@ void Tracker::run()
if (last_roi.width > 0 && last_roi.height)
{
- detector.setThresholdParams(box_sizes[box_idx], thres_param2);
detector.setMinMaxSize(std::max(0.01, size_min * grayscale.cols / last_roi.width),
std::min(1.0, size_max * grayscale.cols / last_roi.width));
@@ -189,7 +188,7 @@ void Tracker::run()
if (detector.detect(grayscale_, markers, cv::Mat(), cv::Mat(), -1, false),
markers.size() == 1 && markers[0].size() == 4)
{
- failed_otsu = std::max(0., failed_otsu - dt*.2);
+ failed = std::max(0., failed - dt*.25);
auto& m = markers.at(0);
for (int i = 0; i < 4; i++)
{
@@ -203,19 +202,13 @@ void Tracker::run()
if (!roi_valid)
{
- detector._thresMethod = otsu ? aruco::MarkerDetector::FIXED_THRES : aruco::MarkerDetector::ADPT_THRES;
- failed_otsu += dt;
- if (failed_otsu > max_failed_otsu)
+ failed += dt;
+ if (failed > max_failed)
{
- 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;
+ box_idx++;
+ box_idx %= box_sizes.size();
+ qDebug() << "aruco: box size now" << box_sizes[box_idx];
+ failed = 0;
}
detector.setThresholdParams(box_sizes[box_idx], thres_param2);
detector.setMinMaxSize(size_min, size_max);