answered Aug 21 '12
Use the flann module. knnSearch function allows you to find k nearest matches. See docs:
http://docs.opencv.org/modules/flann/doc/flann_fast_approximate_nearest_neighbor_search.html