1 | initial version |
you can try like this:
Mat trainData = ... // concatenated features, one per row
cv::Ptr<cv::flann::Index> index;
if (trainData.type() == CV_8U) // ORB
index = makePtr<cv::flann::Index>(trainData,
cv::flann::LinearIndexParams(), cvflann::FLANN_DIST_HAMMING);
else // SIFT
index = makePtr<cv::flann::Index>(trainData,
cv::flann::LinearIndexParams(), cvflann::FLANN_DIST_L2);
// later...
int K=5;
cv::flann::SearchParams params;
cv::Mat dists;
cv::Mat indices;
index->knnSearch(testFeature, indices, dists, K, params);