@@ -39,7 +39,7 @@ features = Features(boolean_img)
39
39
features = Features(keypoints)
40
40
```
41
41
42
- Returns a `Vector{Feature}` of features generated from the `true` values in a boolean image or from a
42
+ Returns a `Vector{Feature}` of features generated from the `true` values in a boolean image or from a
43
43
list of keypoints.
44
44
"""
45
45
typealias Features Vector{Feature}
@@ -59,7 +59,7 @@ function Keypoints(img::AbstractArray)
59
59
map ((ri, ci) -> Keypoint (ri, ci), r, c)
60
60
end
61
61
62
- Keypoints (features:: Features ) = map (f -> f. keypoint, features)
62
+ Keypoints (features:: Features ) = map (f -> f. keypoint, features)
63
63
64
64
typealias OrientationPair Tuple{Int16, Int16}
65
65
typealias OrientationWeights Tuple{Float16, Float16}
@@ -87,7 +87,7 @@ function match_keypoints(keypoints_1::Keypoints, keypoints_2::Keypoints, desc_1,
87
87
s_key = keypoints_1
88
88
l_key = keypoints_2
89
89
order = false
90
- if length (desc_1) > length (desc_2)
90
+ if length (desc_1) > length (desc_2)
91
91
smaller = desc_2
92
92
larger = desc_1
93
93
s_key = keypoints_2
@@ -106,6 +106,55 @@ function match_keypoints(keypoints_1::Keypoints, keypoints_2::Keypoints, desc_1,
106
106
matches
107
107
end
108
108
109
+ """
110
+ ```
111
+ matches = match_keypoints_flann(keypoints_1, keypoints_2, desc_1, desc_2, threshold = 0.1)
112
+ ```
113
+
114
+ Finds matched keypoints with hamming distance value less than `threshold` using FLANN.
115
+ """
116
+ function match_keypoints_flann (keypoints_1:: Keypoints , keypoints_2:: Keypoints , desc_1, desc_2, threshold:: Float64 = 0.1 )
117
+ smaller = desc_1
118
+ larger = desc_2
119
+ s_key = keypoints_1
120
+ l_key = keypoints_2
121
+ order = false
122
+ if length (desc_1) > length (desc_2)
123
+ smaller = desc_2:: Array{BitArray{1},1}
124
+ larger = desc_1
125
+ s_key = keypoints_2
126
+ l_key = keypoints_1
127
+ order = true
128
+ end
129
+
130
+ ndims= length (larger[1 ])
131
+ nplarge= length (larger)
132
+ npsmall= length (smaller)
133
+
134
+ data= Matrix {Float64} (ndims, nplarge);
135
+ for i in 1 : ndims
136
+ for j in 1 : nplarge
137
+ data[i,j]= larger[j][i]?1 : 0
138
+ end
139
+ end
140
+
141
+ f= flann (data, FLANNParameters (), Cityblock ())
142
+
143
+ matches = Keypoints[]
144
+ test= Vector {Float64} (ndims);
145
+ for i in 1 : npsmall
146
+ for j in 1 : ndims
147
+ test[j]= smaller[i][j]?1.0 : 0.0
148
+ end
149
+ idx, dist = nearest (f, test, 1 )
150
+ if dist[1 ]/ ndims < threshold
151
+ id_min = idx[1 ]
152
+ push! (matches, order ? [l_key[id_min], s_key[i]] : [s_key[i], l_key[id_min]])
153
+ end
154
+ end
155
+ matches
156
+ end
157
+
109
158
"""
110
159
```
111
160
grade = grade_matches(keypoints_1, keypoints_2, limit, difference_method)
0 commit comments