未验证 提交 852b8cd1 编写于 作者: M Marius Muja 提交者: GitHub

Merge pull request #371 from jannikboll/master

Minor fix to add/remove-point in python wrapper
......@@ -256,6 +256,15 @@ flannlib.flann_load_index_%(C)s.argtypes = [
flann.load_index[%(numpy)s] = flannlib.flann_load_index_%(C)s
""")
flann.used_memory = {}
define_functions(r"""
flannlib.flann_used_memory_%(C)s.restype = c_int
flannlib.flann_used_memory_%(C)s.argtypes = [
FLANN_INDEX, # index_id
]
flann.used_memory[%(numpy)s] = flannlib.flann_used_memory_%(C)s
""")
flann.add_points = {}
define_functions(r"""
flannlib.flann_add_points_%(C)s.restype = None
......
......@@ -212,6 +212,13 @@ class FLANN(object):
self.__curindex_data = pts
self.__curindex_type = pts.dtype.type
def used_memory(self):
"""
Returns the number of bytes consumed by the index.
"""
return flann.used_memory[self.__curindex_type](self.__curindex)
def add_points(self, pts, rebuild_threshold=2.0):
"""
Adds points to pre-built index.
......@@ -228,12 +235,14 @@ class FLANN(object):
pts = ensure_2d_array(pts,default_flags)
npts, dim = pts.shape
flann.add_points[self.__curindex_type](self.__curindex, pts, npts, dim, rebuild_threshold)
self.__curindex_data = np.row_stack((self.__curindex_data,pts))
def remove_point(self, idx):
"""
Removes a point from a pre-built index.
"""
flann.remove_point[self.__curindex_type](self.__curindex, idx)
self.__curindex_data = np.delete(self.__curindex_data,idx,axis=0)
def nn_index(self, qpts, num_neighbors=1, **kwargs):
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册