Skip to content

Commit 80f3cf0

Browse files
committed
Updated Index interface
1 parent 766e921 commit 80f3cf0

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/cpp/flann/flann.hpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,24 @@ class Index
8080
typedef typename Distance::ResultType DistanceType;
8181
typedef NNIndex<Distance> IndexType;
8282

83+
Index(const IndexParams& params, Distance distance = Distance() )
84+
: index_params_(params)
85+
{
86+
flann_algorithm_t index_type = get_param<flann_algorithm_t>(params,"algorithm");
87+
loaded_ = false;
88+
89+
Matrix<ElementType> features;
90+
if (index_type == FLANN_INDEX_SAVED) {
91+
nnIndex_ = load_saved_index(features, get_param<std::string>(params,"filename"), distance);
92+
loaded_ = true;
93+
}
94+
else {
95+
flann_algorithm_t index_type = get_param<flann_algorithm_t>(params, "algorithm");
96+
nnIndex_ = create_index_by_type<Distance>(index_type, features, params, distance);
97+
}
98+
}
99+
100+
83101
Index(const Matrix<ElementType>& features, const IndexParams& params, Distance distance = Distance() )
84102
: index_params_(params)
85103
{
@@ -137,9 +155,9 @@ class Index
137155
* Remove point from the index
138156
* @param index Index of point to be removed
139157
*/
140-
void removePoint(size_t index)
158+
void removePoint(size_t point_id)
141159
{
142-
nnIndex_->removePoint(index);
160+
nnIndex_->removePoint(point_id);
143161
}
144162

145163

0 commit comments

Comments
 (0)