-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfeature_descriptors.py
More file actions
97 lines (84 loc) · 2.66 KB
/
feature_descriptors.py
File metadata and controls
97 lines (84 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import ctypes
from arrayfire_wrapper.defines import AFArray
from arrayfire_wrapper.lib._utility import call_from_clib
from arrayfire_wrapper.lib.features import AFFeatures
def gloh(
arr: AFArray,
n_layers: int,
contrast_threshold: float,
edge_threshold: float,
init_sigma: float,
double_input: bool,
intensity_scale: float,
feature_ratio: float,
/,
) -> tuple[AFFeatures, AFArray]:
"""
source: https://arrayfire.org/docs/group__cv__func__sift.htm#ga963dd3ecc8c17ff286a6caaee498b49c
"""
out_features = AFFeatures.create_null_pointer()
out_descriptors = AFArray.create_null_pointer()
call_from_clib(
gloh.__name__,
ctypes.pointer(out_features),
ctypes.pointer(out_descriptors),
arr,
ctypes.c_uint(n_layers),
ctypes.c_float(contrast_threshold),
ctypes.c_float(edge_threshold),
ctypes.c_float(init_sigma),
double_input,
ctypes.c_float(intensity_scale),
ctypes.c_float(feature_ratio),
)
return (out_features, out_descriptors)
def orb(
arr: AFArray, fast_threshold: float, max_features: int, scale_factor: float, levels: int, blut_image: bool, /
) -> tuple[AFFeatures, AFArray]:
"""
source: https://arrayfire.org/docs/group__cv__func__orb.htm#ga3b80df1c1f7d95ed1a52b73ba21d4d07
"""
out_features = AFFeatures.create_null_pointer()
out_descriptors = AFArray.create_null_pointer()
call_from_clib(
orb.__name__,
ctypes.pointer(out_features),
ctypes.pointer(out_descriptors),
arr,
ctypes.c_float(fast_threshold),
ctypes.c_uint(max_features),
ctypes.c_float(scale_factor),
ctypes.c_uint(levels),
blut_image,
)
return (out_features, out_descriptors)
def sift(
arr: AFArray,
n_layers: int,
contrast_threshold: float,
edge_threshold: float,
init_sigma: float,
double_input: bool,
intensity_scale: float,
feature_ratio: float,
/,
) -> tuple[AFFeatures, AFArray]:
"""
source: https://arrayfire.org/docs/group__cv__func__sift.htm#ga8bae580e5cd79b8adab7346146a5824f
"""
out_features = AFFeatures.create_null_pointer()
out_descriptors = AFArray.create_null_pointer()
call_from_clib(
sift.__name__,
ctypes.pointer(out_features),
ctypes.pointer(out_descriptors),
arr,
ctypes.c_uint(n_layers),
ctypes.c_float(contrast_threshold),
ctypes.c_float(edge_threshold),
ctypes.c_float(init_sigma),
double_input,
ctypes.c_float(intensity_scale),
ctypes.c_float(feature_ratio),
)
return (out_features, out_descriptors)