private void KdSearch(int incLevelNumber, LevelImage levelImage, int startInd, int endInd, List <FragmentsMapping> mapping, int[] fragmentLevelsIndexes)
        {
            var fragments = levelImage.Fragments;
            var indsDists = AnnWrapper.AnnKdSearch(levelImage.FragmentYCompsToDoubleArray(startInd, endInd), (endInd - startInd), levelImage.Fragments[0].Size);

            for (int i = 0; i < indsDists.Count; i++)
            {
                var fragmentMapping = new FragmentsMapping
                {
                    LevelIndex = FindLevelIndex(indsDists[i].Item1, fragmentLevelsIndexes),
                    OrigIndex  = startInd + i,
                    Distance   = indsDists[i].Item2
                };
                fragmentMapping.DecIndex = indsDists[i].Item1 - fragmentLevelsIndexes[fragmentMapping.LevelIndex];
                mapping.Add(fragmentMapping);
            }

            if (FragmentFounded != null)
            {
                FragmentFounded(this, new FragmentEventArgs(incLevelNumber, IncLevelsCount, endInd, fragments.Count));
            }
        }
 private void KdSearch(List<LevelImageFragment> fragments, int ind, List<FragmentsMapping> mapping, int[] fragmentLevelsIndexes)
 {
     var indDist = AnnWrapper.AnnKdSearch(fragments[ind].YComponents.Select(y => (double)y).ToArray());
     lock (mapping)
     {
         var fragmentMapping = new FragmentsMapping
         {
             LevelIndex = FindLevelIndex(indDist.Item1, fragmentLevelsIndexes),
             OrigIndex = ind,
             Distance = indDist.Item2
         };
         fragmentMapping.DecIndex = indDist.Item1 - fragmentLevelsIndexes[fragmentMapping.LevelIndex];
         mapping.Add(fragmentMapping);
     }
 }