Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to use opencv2.4.4 flann

Hi,

I'm using opencv 2.4.4 flann.

and I refer to: http://docs.opencv.org/2.4.4/modules/flann/doc/flann_fast_approximate_nearest_neighbor_search.html

to do KNN.

I have a matrix(8000*32) flann_m. There are 8000 data and each with 32 features.

I wrote code like this:

    flann::Index flann_index(flann_m, flann::LinearIndexParams());
    flann_index.save("flann_index.fln");

    Mat resps(ROW,K,CV_32F);
    Mat nresps(ROW,K,CV_16S);
    Mat dist(ROW,K,CV_32F);

    flann_index.knnSearch(flann_m,nresps,dist,K,flann::SearchParams(64));

And I could get the KNN results in nresps and dist, with nresps the indexes of N neighbors, and dist the distances.

But I don't know how to set different distance algorithm (ChiSquare, Euclidean, etc.) in opencv flann. I checked flann.cpp, and it seems the set_distance() function is deperecated.

how to use opencv2.4.4 flann

Hi,

I'm using opencv 2.4.4 flann.

and I refer to: http://docs.opencv.org/2.4.4/modules/flann/doc/flann_fast_approximate_nearest_neighbor_search.html

to do KNN.

I have a matrix(8000*32) flann_m. There are 8000 data and each with 32 features.

I wrote code like this:

    flann::Index flann_index(flann_m, flann::LinearIndexParams());
    flann_index.save("flann_index.fln");

    Mat resps(ROW,K,CV_32F);
    Mat nresps(ROW,K,CV_16S);
    Mat dist(ROW,K,CV_32F);

    flann_index.knnSearch(flann_m,nresps,dist,K,flann::SearchParams(64));

And I could get the KNN results in nresps and dist, with nresps the indexes of N neighbors, and dist the distances.

But I don't know how to set different distance algorithm (ChiSquare, Euclidean, etc.) in opencv flann. I checked flann.cpp, and it seems the set_distance() function is deperecated.