diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 494a9a5ccbca3a3ea5f6571cf3bafbeccde118a3..c34e4546455e35c833f3e825e1b03798fb23c027 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -118,6 +118,7 @@ SET(headers algorithms/opticalflowpyrlk/alg_opticalflowpyrlk.h algorithms/activesearch/alg_activesearch.h) + # locate the necessary dependencies FIND_PACKAGE(Eigen3 REQUIRED) FIND_PACKAGE(OpenCV REQUIRED) diff --git a/src/detectors/detector_base.cpp b/src/detectors/detector_base.cpp index 2b32d1e0529cc58a08974cd8bd8b1f3c3c318cbe..33d24157793d0ff4f509eb4a63a56ed212e26732 100644 --- a/src/detectors/detector_base.cpp +++ b/src/detectors/detector_base.cpp @@ -30,30 +30,25 @@ KeyPointVector DetectorBase::detect(const cv::Mat& _image, cv::Rect& _roi) { // FIX this KeyPointVector kpts; - if (!_image.empty() && _roi.height > 2*pattern_radius_ && _roi.width > 2*pattern_radius_) + if (!_image.empty()) { cv::Mat _image_roi; - //adaptRoi(getPatternRadius(), _image, _roi, _image_roi); - - std::cout << "radii: " << getPatternRadius() << " ROI: " << _roi.x << " " << _roi.y << " " << _roi.width << " " << _roi.height << std::endl; - - - adaptRoi(100, _image, _roi, _image_roi); - -std::cout << "radii: " << getPatternRadius() << " ROI: " << _roi.x << " " << _roi.y << " " << _roi.width << " " << _roi.height << std::endl; - -//cv::imshow("ACTIVESEARCH algorithm", _image_roi); -//cv::waitKey(1); -// -// sleep(2); - - kpts = detect(_image_roi); - - for (int ii = 0; ii < kpts.size(); ++ii) - { - kpts[ii].pt.x = kpts[ii].pt.x + _roi.x; - kpts[ii].pt.y = kpts[ii].pt.y + _roi.y; - } + adaptRoi(getPatternRadius(), _image, _roi, _image_roi); + + try + { + kpts = detect(_image_roi); + + for (int ii = 0; ii < kpts.size(); ++ii) + { + kpts[ii].pt.x = kpts[ii].pt.x + _roi.x; + kpts[ii].pt.y = kpts[ii].pt.y + _roi.y; + } + } + catch( cv::Exception& e ) + { + std::cerr << "exception caught: " << e.what() << std::endl; + } } return kpts; } diff --git a/src/detectors/orb/detector_orb.h b/src/detectors/orb/detector_orb.h index 94b90901b4986ff4b0be8747d83948c468d3f291..062e1496caf2870503505a86471916450c151845 100644 --- a/src/detectors/orb/detector_orb.h +++ b/src/detectors/orb/detector_orb.h @@ -63,7 +63,7 @@ inline void DetectorORB::defineDetector(const ParamsBasePtr _params) params_ptr->scoreType, params_ptr->patchSize); - pattern_radius_ = params_ptr->edgeThreshold; + pattern_radius_ = params_ptr->patchSize; } /* diff --git a/src/examples/test_algorithm_activesearch.cpp b/src/examples/test_algorithm_activesearch.cpp index 95035db113356ef0f49f13e5890fe4edf7b9dded..43e2d10693532bb62e81e912fd3cf000259ba8ea 100644 --- a/src/examples/test_algorithm_activesearch.cpp +++ b/src/examples/test_algorithm_activesearch.cpp @@ -45,7 +45,7 @@ #include "../algorithms/activesearch/alg_activesearch.h" // TODO: set as user parameters -#define MAX_NEW_FEATURES 100 +#define MAX_NEW_FEATURES 500 #define MIN_FEATURES_TO_TRACK 10 #define MIN_RESPONSE_NEW_FEATURES 80 #define MATCHER_MIN_NORMALIZED_SCORE 0.85 @@ -109,13 +109,13 @@ void detectNewFeatures(cv::Mat& _frame, _active_search_grid_ptr->hitCell(new_keypoints[0]); // Debug - // drawRoi(_frame,roi,_active_search_grid_ptr->getName(),cv::Scalar(50,255,0), 1, 0.1); + drawRoi(_frame,roi,_active_search_grid_ptr->getName(),cv::Scalar(50,255,0), 1, 0.1); } } else { _active_search_grid_ptr->blockCell(roi); - // drawRoi(_frame,roi,_active_search_grid_ptr->getName(),cv::Scalar(255,0,0), 1, 0.1); + drawRoi(_frame,roi,_active_search_grid_ptr->getName(),cv::Scalar(255,0,0), 1, 0.1); } // Debug @@ -367,8 +367,8 @@ int main(void) active_search_grid_ptr->setParams(params_ptr); // Set main ROI areas depending on ACTIVE SEARCH GRID sizes - roi_h_ = params_ptr->img_size_v/params_ptr->n_cells_v; - roi_w_ = params_ptr->img_size_h/params_ptr->n_cells_h; + roi_h_ = params_ptr->img_size_v/(params_ptr->n_cells_v); + roi_w_ = params_ptr->img_size_h/(params_ptr->n_cells_h); std::vector<feature> features_last_frame_vec; @@ -382,16 +382,16 @@ int main(void) // Process std::vector<feature> features_tracked_vec; -// if (features_last_frame_vec.size() < MIN_FEATURES_TO_TRACK) -// { + if (features_last_frame_vec.size() < MIN_FEATURES_TO_TRACK) + { // TODO: When to renew? active_search_grid_ptr->renew(); detectNewFeatures(frame_cur, det_ptr, des_ptr, active_search_grid_ptr, features_tracked_vec); -// } -// else -// { -// trackFeatures(frame_cur, det_ptr, des_ptr, mat_ptr, active_search_grid_ptr, features_last_frame_vec,features_tracked_vec); -// } + } + else + { + trackFeatures(frame_cur, det_ptr, des_ptr, mat_ptr, active_search_grid_ptr, features_last_frame_vec,features_tracked_vec); + } features_last_frame_vec.clear(); features_last_frame_vec = features_tracked_vec; diff --git a/src/examples/yaml/ACTIVESEARCH.yaml b/src/examples/yaml/ACTIVESEARCH.yaml index 8b5804e39f21ab1f87dc0ea6330889917bae1bc4..49de7161e1d494b2de72fc7d965064594fb9686b 100644 --- a/src/examples/yaml/ACTIVESEARCH.yaml +++ b/src/examples/yaml/ACTIVESEARCH.yaml @@ -8,18 +8,18 @@ detector: nfeatures: 100 scale factor: 2 nlevels: 8 - edge threshold: 8 # 16 + edge threshold: 16 # 16 first level: 0 WTA_K: 2 # See: http://docs.opencv.org/trunk/db/d95/classcv_1_1ORB.html#a180ae17d3300cf2c619aa240d9b607e5 score type: 1 #enum { kBytes = 32, HARRIS_SCORE=0, FAST_SCORE=1 }; - patch size: 15 # 31 + patch size: 31 # 31 descriptor: type: "ORB" nfeatures: 100 scale factor: 2 nlevels: 8 - edge threshold: 8 # 16 + edge threshold: 16 # 16 first level: 0 WTA_K: 2 # See: http://docs.opencv.org/trunk/db/d95/classcv_1_1ORB.html#a180ae17d3300cf2c619aa240d9b607e5 score type: 1 #enum { kBytes = 32, HARRIS_SCORE=0, FAST_SCORE=1 }; @@ -33,7 +33,7 @@ algorithm: type: "ACTIVESEARCH" img size h: 640 img size v: 480 - grid height: 8 - grid width: 12 + grid height: 10 + grid width: 10 margin: 0 separation: 10 \ No newline at end of file