Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You should use one channel cv::Mat (see docs here: http://docs.opencv.org/modules/flann/doc/flann_fast_approximate_nearest_neighbor_search.html#flann-index)

When you use cv::Mat(pts) you get two channels matrix Kx1 with type CV_32FC2, so you should call reshape to get matrix K*2x1 with type CV_32FC.

std::vector<cv::Point2f> pts(K);
cv::flann::Index tree= cv::flann::Index(cv::Mat(pts).reshape(1),cv::flann::KDTreeIndexParams(1));