Ask Your Question

mengfei's profile - activity

2020-03-20 13:16:21 -0600 received badge  Famous Question (source)
2015-07-18 17:30:06 -0600 received badge  Notable Question (source)
2014-08-19 05:19:13 -0600 received badge  Popular Question (source)
2013-04-12 01:16:47 -0600 commented answer how to use opencv2.4.4 flann

Hi, I tried the original FLANN, and to solve namespace conflict is painful. But I don't know how to link the compiled package to my Visual Studio C++ project, and how to use this FLANN. Could you give me a sample?

By the way, I also tried cvflann namespace, but knnSearch didn't work (abort() has been called)

Matrix<float> samplesMatrix((float*)flann_m.data, flann_m.rows, flann_m.cols); Index<cvflann::ChiSquareDistance<float>> flann_index(samplesMatrix, cvflann::LinearIndexParams()); Matrix<int> nresps; Matrix<float>dist; flann_index.knnSearch(samplesMatrix,nresps,dist,K,SearchParams(64));

2013-04-12 00:55:17 -0600 received badge  Supporter (source)
2013-04-08 10:20:49 -0600 commented answer how to use opencv2.4.4 flann

Thanks a lot. I will give it a try.

2013-04-06 23:28:09 -0600 received badge  Editor (source)
2013-04-06 23:27:29 -0600 asked a question 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.