@@ -173,27 +173,6 @@ test('patch with one keypoint, centroidPatchDiameter=15', () => {
173
173
] ) ;
174
174
} ) ;
175
175
176
- test ( 'check we handle edge cases properly' , ( ) => {
177
- const image = testUtils
178
- . load ( 'featureMatching/crop1.png' )
179
- . convertColor ( ImageColorModel . GREY ) ;
180
-
181
- const keypoints = getOrientedFastKeypoints ( image ) ;
182
-
183
- expect ( keypoints . length ) . toBe ( 403 ) ;
184
- } ) ;
185
-
186
- test ( 'angle should never be NaN' , ( ) => {
187
- const image = testUtils
188
- . load ( 'featureMatching/crop1.png' )
189
- . convertColor ( ImageColorModel . GREY ) ;
190
-
191
- const keypoints = getOrientedFastKeypoints ( image ) ;
192
- for ( let keypoint of keypoints ) {
193
- expect ( isNaN ( keypoint . angle ) ) . toBe ( false ) ;
194
- }
195
- } ) ;
196
-
197
176
test . each ( [
198
177
{
199
178
message : 'betterScaleneTriangle' ,
@@ -203,20 +182,94 @@ test.each([
203
182
message : 'betterScaleneTriangle90' ,
204
183
image : 'betterScaleneTriangle90' ,
205
184
} ,
206
- ] ) ( 'orientation should look correct ($message)' , ( data ) => {
207
- const markerSize = 7 ;
185
+ ] ) ( 'patchDiameter = 31 ($message)' , ( data ) => {
186
+ const centroidPatchDiameter = 31 ;
208
187
209
188
const image = testUtils
210
189
. load ( `featureMatching/polygons/${ data . image } .png` as TestImagePath )
211
190
. convertColor ( ImageColorModel . GREY )
212
191
. invert ( ) ;
213
- const keypoints = getOrientedFastKeypoints ( image ) ;
192
+
193
+ const keypoints = getOrientedFastKeypoints ( image , { centroidPatchDiameter } ) ;
214
194
215
195
expect (
216
- drawKeypoints ( image , keypoints , { markerSize, showOrientation : true } ) ,
196
+ drawKeypoints ( image , keypoints , {
197
+ markerSize : centroidPatchDiameter ,
198
+ showOrientation : true ,
199
+ } ) ,
217
200
) . toMatchImageSnapshot ( ) ;
218
201
} ) ;
219
202
203
+ test ( 'verify single keypoint orientation' , ( ) => {
204
+ const origin = { row : 332 , column : 253 } ;
205
+ const size = 51 ;
206
+ const radius = ( size - 1 ) / 2 ;
207
+
208
+ const cropOrigin = {
209
+ row : origin . row - radius ,
210
+ column : origin . column - radius ,
211
+ } ;
212
+
213
+ const centroidPatchDiameter = 31 ;
214
+
215
+ const origialImage = testUtils
216
+ . load ( 'featureMatching/polygons/betterScaleneTriangle.png' )
217
+ . convertColor ( ImageColorModel . GREY )
218
+ . invert ( ) ;
219
+
220
+ const image = origialImage . crop ( {
221
+ origin : cropOrigin ,
222
+ width : size ,
223
+ height : size ,
224
+ } ) ;
225
+
226
+ const keypoints = getOrientedFastKeypoints ( image , { centroidPatchDiameter } ) ;
227
+ expect ( keypoints . length ) . toBe ( 1 ) ;
228
+
229
+ const result = drawKeypoints ( image , keypoints , {
230
+ markerSize : centroidPatchDiameter ,
231
+ showOrientation : true ,
232
+ } ) ;
233
+
234
+ expect ( result ) . toMatchImageSnapshot ( ) ;
235
+ } ) ;
236
+
237
+ test ( 'small patchsize and large marker' , ( ) => {
238
+ // this test shows that the orientation is not good when the centroidPatchDiameter is too small
239
+ // ideally we should use the same patch size for orientation and descriptors (getKeypointPatch)
240
+ const origin = { row : 730 , column : 291 } ;
241
+ const size = 51 ;
242
+ const radius = ( size - 1 ) / 2 ;
243
+
244
+ const cropOrigin = {
245
+ row : origin . row - radius ,
246
+ column : origin . column - radius ,
247
+ } ;
248
+
249
+ const centroidPatchDiameter = 7 ;
250
+
251
+ const origialImage = testUtils
252
+ . load ( 'featureMatching/polygons/betterScaleneTriangle90.png' )
253
+ . convertColor ( ImageColorModel . GREY )
254
+ . invert ( ) ;
255
+
256
+ const image = origialImage . crop ( {
257
+ origin : cropOrigin ,
258
+ width : size ,
259
+ height : size ,
260
+ } ) ;
261
+
262
+ const keypoints = getOrientedFastKeypoints ( image , { centroidPatchDiameter } ) ;
263
+ expect ( keypoints . length ) . toBe ( 1 ) ;
264
+
265
+ const result = drawKeypoints ( image , keypoints , {
266
+ markerSize : 31 ,
267
+ showOrientation : true ,
268
+ } ) ;
269
+
270
+ expect ( result ) . toMatchImageSnapshot ( ) ;
271
+ } ) ;
272
+
220
273
test ( 'check angle for different windowSize' , ( ) => {
221
274
const image = testUtils
222
275
. load ( 'featureMatching/polygons/scaleneTriangle10.png' )
0 commit comments