87
87
88
88
def to_cpts (kpts , ps ):
89
89
if ps > 0.0 :
90
- cpts = np .round (np .round ((kpts + 0.5 ) / ps ) * ps - 0.5 , 2 )
91
- return [tuple (cpt ) for cpt in cpts ]
90
+ kpts = np .round (np .round ((kpts + 0.5 ) / ps ) * ps - 0.5 , 2 )
91
+ return [tuple (cpt ) for cpt in kpts ]
92
92
93
93
94
94
def assign_keypoints (kpts : np .ndarray ,
@@ -106,7 +106,7 @@ def assign_keypoints(kpts: np.ndarray,
106
106
return kpt_ids
107
107
else :
108
108
ps = cell_size if cell_size is not None else max_error
109
- ps = max (cell_size , max_error )
109
+ ps = max (ps , max_error )
110
110
# With update we quantize and bin (optionally)
111
111
assert isinstance (other_cpts , list )
112
112
kpt_ids = []
@@ -270,13 +270,15 @@ def match_dense(conf: Dict,
270
270
image0 , image1 = image0 .to (device ), image1 .to (device )
271
271
272
272
# match semi-dense
273
- if name1 in existing_refs :
274
- # flip to enable refinement in query image
273
+ # for consistency with pairs_from_*: refine kpts of image0
274
+ if name0 in existing_refs :
275
+ # special case: flip to enable refinement in query image
275
276
pred = model ({'image0' : image1 , 'image1' : image0 })
276
277
pred = {** pred ,
277
278
'keypoints0' : pred ['keypoints1' ],
278
279
'keypoints1' : pred ['keypoints0' ]}
279
280
else :
281
+ # usual case
280
282
pred = model ({'image0' : image0 , 'image1' : image1 })
281
283
282
284
# Rescale keypoints and move to cpu
@@ -376,16 +378,18 @@ def aggregate_matches(
376
378
update1 = name1 in required_queries
377
379
378
380
# in localization we do not want to bin the query kp
379
- if update1 and not update0 and max_kps is None :
380
- max_error1 = 0.0
381
+ # assumes that the query is name0!
382
+ if update0 and not update1 and max_kps is None :
383
+ max_error0 = cell_size0 = 0.0
381
384
else :
382
- max_error1 = conf ['max_error' ]
385
+ max_error0 = conf ['max_error' ]
386
+ cell_size0 = conf ['cell_size' ]
383
387
384
388
# Get match ids and extend query keypoints (cpdict)
385
- mkp_ids0 = assign_keypoints (kpts0 , cpdict [name0 ], conf [ 'max_error' ] ,
389
+ mkp_ids0 = assign_keypoints (kpts0 , cpdict [name0 ], max_error0 ,
386
390
update0 , bindict [name0 ], scores ,
387
- conf [ 'cell_size' ] )
388
- mkp_ids1 = assign_keypoints (kpts1 , cpdict [name1 ], max_error1 ,
391
+ cell_size0 )
392
+ mkp_ids1 = assign_keypoints (kpts1 , cpdict [name1 ], conf [ 'max_error' ] ,
389
393
update1 , bindict [name1 ], scores ,
390
394
conf ['cell_size' ])
391
395
0 commit comments