VWDictionary: use multi-core FLANN kNN search (#1760)

* VWDictionary: use multi-core FLANN kNN search

* Add parameter with default 1 thread

* Kp/FlannTreads plumbing  to UI. Also added to performance tests for comparison.

* fixing ci error

* dump debug data for windows ci

* Adding  more dll debugging report windows ci

* install vc2012 runtime explicitly

* updated comment

---------

Co-authored-by: matlabbe <[email protected]>
This commit is contained in:
Torjus Iveland
2026-09-10 23:22:00 -07:00
committed by GitHub
co-authored by matlabbe
parent fb457255b7
commit 2fbbe19d70
10 changed files with 283 additions and 32 deletions
+6 -3
View File
@@ -201,6 +201,7 @@ public:
* structures ignoring it
* @param eps Search for eps-approximate neighbors
* @param sorted Give the neighbors back by increasing distance
* @param cores Threads for the batch search (0 = all available)
*/
void knnSearch(
const cv::Mat & query,
@@ -209,8 +210,8 @@ public:
int knn,
int checks = 32,
float eps = 0.0,
bool sorted = true) const;
bool sorted = true,
int cores = 1) const;
/**
* @brief Search the neighbors of each query within a radius
* @param query One feature per row, of the type and dimension the index was
@@ -225,6 +226,7 @@ public:
* structures ignoring it
* @param eps Search for eps-approximate neighbors
* @param sorted Give the neighbors back by increasing distance
* @param cores Threads for the batch search (0 = all available)
*/
void radiusSearch(
const cv::Mat & query,
@@ -234,7 +236,8 @@ public:
int maxNeighbors = 0,
int checks = 32,
float eps = 0.0,
bool sorted = true) const;
bool sorted = true,
int cores = 1) const;
private:
void * index_; // rtflann backend
@@ -256,6 +256,7 @@ class RTABMAP_CORE_EXPORT Parameters
RTABMAP_PARAM(Kp, IncrementalDictionary, bool, true, "");
RTABMAP_PARAM(Kp, IncrementalFlann, bool, true, uFormat("When using FLANN based strategy, add/remove points to its index without always rebuilding the index (the index is only rebuilt when too many of its features have been removed, see \"%s\").", kKpFlannRebalancingFactor().c_str()));
RTABMAP_PARAM(Kp, FlannRebalancingFactor, float, 2.0, uFormat("Rebuild the incremental FLANN index (see \"%s\") once the ratio (factor-1)/factor of its features has been removed, e.g. half of them for a factor of 2. Rebuilding frees the memory of the removed features and speeds up the searches. Features are mostly removed when memory management is enabled (\"%s\" or \"%s\"). Set to 1 to never rebuild, which also uses less memory as the features don't have to be referenced one by one.", kKpIncrementalFlann().c_str(), kRtabmapTimeThr().c_str(), kRtabmapMemoryThr().c_str()));
RTABMAP_PARAM(Kp, FlannThreads, int, 1, "Number of threads used for FLANN kNN search (batched queries). Set to 0 for all available.");
RTABMAP_PARAM(Kp, ByteToFloat, bool, false, uFormat("For %s=1, binary descriptors are converted to float by converting each byte to float instead of converting each bit to float. When converting bytes instead of bits, less memory is used and search is faster at the cost of slightly less accurate matching.", kKpNNStrategy().c_str()));
RTABMAP_PARAM(Kp, MaxDepth, float, 0, "Filter extracted keypoints by depth (0=inf).");
RTABMAP_PARAM(Kp, MinDepth, float, 0, "Filter extracted keypoints by depth.");
@@ -495,6 +495,11 @@ private:
*/
float _rebalancingFactor;
/**
* @brief Threads for FLANN batched kNN search (0 = all available)
*/
int _flannThreads;
/**
* @brief Whether to convert descriptors from byte to float format
*/