Skip to content
Snippets Groups Projects
Commit 13fe5c8a authored by Angel Santamaria-Navarro's avatar Angel Santamaria-Navarro
Browse files

trying to make the active search grid work

parent 60fb7232
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -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;
}
......
......@@ -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;
}
/*
......
......@@ -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;
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment