# General question about nearest neighbor

**URL:** <https://forum.opencv.org/t/general-question-about-nearest-neighbor/8680>\
**Category:** C++\
**Tags:** flann\
**Created:** [May 7, 2022, 11:34am UTC](https://forum.opencv.org/t/general-question-about-nearest-neighbor/8680 "2022-05-07T11:34:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![L\_D](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/l_d/32/3920_2.png) [@L\_D](https://forum.opencv.org/u/L_D)\
**Post date:** [May 7, 2022, 11:34am UTC](https://forum.opencv.org/t/general-question-about-nearest-neighbor/8680/1 "2022-05-07T11:34:15Z")

</div>

I want to improve the speed of my feature matching algorithm. The matching is based on comparing feature A with circularly shifted feature B. The shifting is performed N times (for orientation invariance). The distance between A and B is the minimal value of the distance between A and the shifted B.

Considering this distance, I cannot use a KD tree or the FLANN library.

What kind of solutions could be applied in my case in order to speed up the NN search? Is there any c++ library that I can use?

Thanks
