flann RadiusSearch

asked 2012-11-01 07:53:58 -0600

mrgloom gravatar image

updated 2012-11-01 07:55:45 -0600

I'm trying to test how radiusSearch work.I put 1 points as argument and expecting that in id vector it will be first, but it doesn't and sometimes it'snt even present in id vector, maybe this happens because of flann give approximate solution, but I use LinearIndexParams. And another question is how can I know how many points RadiusSearch return?

vector<cv::Point2f> scheme_pts;
//cv::flann::Index tree= cv::flann::Index(cv::Mat(scheme_pts).reshape(1),cv::flann::KDTreeIndexParams(1));
cv::flann::Index tree= cv::flann::Index(cv::Mat(scheme_pts).reshape(1),cv::flann::LinearIndexParams());
//cv::flann::Index tree= cv::flann::Index(cv::Mat(scheme_pts).reshape(1),cv::flann::AutotunedIndexParams(1,0,0,1));

vector<float> vec_f(2);
vector<int> id(scheme_pts.size()); //size?
vector<float> dists(scheme_pts.size());//size?
cv::flann::SearchParams params; //32 //precision? what if use LinearIndexParams?
float radius=10;//metric?
for(int i=0;i<scheme_pts.size();++i)
{
  vec_f[0]= scheme_pts[i].x;
  vec_f[1]= scheme_pts[i].y;
  tree.radiusSearch(vec_f,id,dists,radius,params);
}
edit retag flag offensive close merge delete

Comments

Check the shape of the cv::Mat you are passing into the tree constructor. I recently had the issue where the matrix after reshape was a single row. In your case I would have needed to use cv::Mat(scheme_pts).reshape(1,scheme_pts.size())

dtmoodie gravatar imagedtmoodie ( 2014-11-03 08:57:24 -0600 )edit