From b68cf0b79cf112d919ee0f224bc205f57c7cac92 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 7 Aug 2015 05:50:42 +0200 Subject: aruco: try otsu for one frame if regular fails --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 6 +++++- ftnoir_tracker_aruco/include/markerdetector.h | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) mode change 100644 => 100755 ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp mode change 100644 => 100755 ftnoir_tracker_aruco/include/markerdetector.h diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp old mode 100644 new mode 100755 index a6889f82..84f20a61 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -134,6 +134,7 @@ void Tracker::run() 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) { @@ -182,7 +183,8 @@ void Tracker::run() detector.setMinMaxSize(std::max(0.01, size_min * grayscale.cols / last_roi.width), std::min(1.0, size_max * grayscale.cols / last_roi.width)); - if (detector.detect(grayscale(last_roi), markers, cv::Mat(), cv::Mat(), -1, false), + cv::Mat grayscale_ = grayscale(last_roi).clone(); + if (detector.detect(grayscale_, markers, cv::Mat(), cv::Mat(), -1, false), markers.size() == 1 && markers[0].size() == 4) { failed = std::max(0., failed - dt); @@ -199,6 +201,8 @@ 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) { diff --git a/ftnoir_tracker_aruco/include/markerdetector.h b/ftnoir_tracker_aruco/include/markerdetector.h old mode 100644 new mode 100755 index ac120b18..8a7e75ca --- a/ftnoir_tracker_aruco/include/markerdetector.h +++ b/ftnoir_tracker_aruco/include/markerdetector.h @@ -277,6 +277,7 @@ private: * This function returns in candidates all the rectangles found in a thresolded image */ void detectRectangles(const cv::Mat &thresImg,vector & candidates); +public: //Current threshold method ThresholdMethods _thresMethod; //Threshold parameters @@ -297,7 +298,7 @@ private: cv::Mat grey,thres,thres2,reduced; //pointer to the function that analizes a rectangular region so as to detect its internal marker int (* markerIdDetector_ptrfunc)(const cv::Mat &in,int &nRotations); - +private: /** */ bool isInto(cv::Mat &contour,std::vector &b); -- cgit v1.2.3