1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge pull request #26382 from kaingwade:annoy_build_parallel

Build Annoy index in parallel #26382

#26287 raised the C++ standard, and Annoy's multi-threaded index building can be enabled now.
This commit is contained in:
WU Jia
2025-10-21 17:37:13 +08:00
committed by GitHub
parent 0fb49827c1
commit 90a73210fc
2 changed files with 86 additions and 10 deletions
+4 -2
View File
@@ -2,6 +2,8 @@
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html
#define ANNOYLIB_MULTITHREADED_BUILD
#include "precomp.hpp"
#include "../3rdparty/annoy/annoylib.h"
#include <opencv2/core/utils/logger.hpp>
@@ -48,7 +50,7 @@ class ANNIndexImpl : public ANNIndex
public:
ANNIndexImpl(int dimension) : dim(dimension)
{
index = makePtr<::cvannoy::AnnoyIndex<int, DataType, DistanceType, Random, ::cvannoy::AnnoyIndexSingleThreadedBuildPolicy>>(dimension);
index = makePtr<::cvannoy::AnnoyIndex<int, DataType, DistanceType, Random, ::cvannoy::AnnoyIndexMultiThreadedBuildPolicy>>(dimension);
}
void addItems(InputArray _dataset) CV_OVERRIDE
@@ -234,7 +236,7 @@ public:
private:
int dim;
Ptr<::cvannoy::AnnoyIndex<int, DataType, DistanceType, Random, ::cvannoy::AnnoyIndexSingleThreadedBuildPolicy>> index;
Ptr<::cvannoy::AnnoyIndex<int, DataType, DistanceType, Random, ::cvannoy::AnnoyIndexMultiThreadedBuildPolicy>> index;
};
Ptr<ANNIndex> ANNIndex::create(int dim, ANNIndex::Distance distType)