After searching through the web and going through the FLANN api I could not find a decent example that showcases the K nearest neighbor search capability. I found that OpenCV also has a wrapper written around flann so checked if there exists a simple example. To my dismay I could not find one. So, I spent couple of hours and put together the following code. Hope someone looking to use flann with opencv will find this example useful!
The example generates data randomly centered around a mean and a variance of arbitrary dimensions(provided by user, default is 1) and generates query data with similar properties and invokes the single query and batch knnSearch function calls and prints out. Just to let you know its not a class, its just a simple example to help people use knnSearch function in openCV. Enjoy!
code: cvKnn.cpp
Command to compile the code: g++ cvKnn.cpp -L /usr/lib -lopencv_core -lopencv_flann -o cvKnn
The example generates data randomly centered around a mean and a variance of arbitrary dimensions(provided by user, default is 1) and generates query data with similar properties and invokes the single query and batch knnSearch function calls and prints out. Just to let you know its not a class, its just a simple example to help people use knnSearch function in openCV. Enjoy!
code: cvKnn.cpp
Command to compile the code: g++ cvKnn.cpp -L /usr/lib -lopencv_core -lopencv_flann -o cvKnn