Skip to content

Commit a9031fb

Browse files
tomerdmntpavanky
authored andcommitted
vision.py fixes
* fix af_sift call * fix vision.gloh call * fix vision.orb call * call af_release_features on features __del__
1 parent 98e39b3 commit a9031fb

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

arrayfire/features.py

+8
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ def __init__(self, num=0):
3232
assert(isinstance(num, numbers.Number))
3333
safe_call(backend.get().af_create_features(c_pointer(self.feat), c_dim_t(num)))
3434

35+
def __del__(self):
36+
"""
37+
Release features' memory
38+
"""
39+
if self.feat:
40+
backend.get().af_release_features(self.feat)
41+
self.feat = None
42+
3543
def num_features(self):
3644
"""
3745
Returns the number of features detected.

arrayfire/vision.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def orb(image, threshold=20.0, max_features=400, scale = 1.5, num_levels = 4, bl
131131
"""
132132
feat = Features()
133133
desc = Array()
134-
safe_call(backend.get().af_orb(c_pointer(feat.feat), c_pointer(desc.arr),
134+
safe_call(backend.get().af_orb(c_pointer(feat.feat), c_pointer(desc.arr), image.arr,
135135
c_float_t(threshold), c_uint_t(max_features),
136136
c_float_t(scale), c_uint_t(num_levels), blur_image))
137137
return feat, desc
@@ -391,9 +391,11 @@ def gloh(image, num_layers=3, contrast_threshold=0.04, edge_threshold=10.0, init
391391

392392
feat = Features()
393393
desc = Array()
394-
safe_call(af_gloh(c_pointer(feat), c_pointer(desc),
395-
image.arr, num_layers, contrast_threshold, edge_threshold,
396-
initial_sigma, double_input, intensity_scale, feature_ratio))
394+
safe_call(backend.get().af_gloh(c_pointer(feat.feat), c_pointer(desc.arr),
395+
image.arr, num_layers, c_float_t(contrast_threshold),
396+
c_float_t(edge_threshold), c_float_t(initial_sigma),
397+
double_input, c_float_t(intensity_scale),
398+
c_float_t(feature_ratio)))
397399

398400
return (feat, desc)
399401

0 commit comments

Comments
 (0)