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
10 comments:
Thanks, this saved me a lot of time searching!!
Thanks a lot!
Thanks a lot. Very useful.
Thanks a lot! THe OpenCV docs are useless here. This is exactly what I was looking for ;)
Goodmorning. I would also like to download the code, but when I click over the link it appears the following message: "Internal Server Error". I was wondering if you could, please, be able to check it? or could you e-mail me the code (r.gonzalez.valenzuela@gmail.com)?
Thank you very much!
Thanks Manohar!!!!
Thanks a lot.
Thanks for the code. I couldn't find a similar example in python. Does OpenCV exposes its flann API in python?
Hi, the link is broken!!
Many thanks
thank you, that's super helpful!
Post a Comment