Skip to content

Commit 75df166

Browse files
authored
Add scalar detection uncertainty (#158)
1 parent 7ec570c commit 75df166

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

hloc/extract_features.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ def main(conf: Dict,
241241
size = np.array(data['image'].shape[-2:][::-1])
242242
scales = (original_size / size).astype(np.float32)
243243
pred['keypoints'] = (pred['keypoints'] + .5) * scales[None] - .5
244+
# add keypoint uncertainties scaled to the original resolution
245+
uncertainty = getattr(model, 'detection_noise', 1) * scales.mean()
244246

245247
if as_half:
246248
for k in pred:
@@ -255,6 +257,8 @@ def main(conf: Dict,
255257
grp = fd.create_group(name)
256258
for k, v in pred.items():
257259
grp.create_dataset(k, data=v)
260+
if 'keypoints' in pred:
261+
grp['keypoints'].attrs['uncertainty'] = uncertainty
258262
except OSError as error:
259263
if 'No space left on device' in error.args[0]:
260264
logger.error(

hloc/extractors/sift.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class SIFT(BaseModel):
2929
'max_keypoints': -1
3030
}
3131
required_inputs = ['image']
32+
detection_noise = 1.0
3233

3334
def _init(self, conf):
3435
self.root = conf['root']

hloc/extractors/superpoint.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class SuperPoint(BaseModel):
5353
'fix_sampling': False,
5454
}
5555
required_inputs = ['image']
56+
detection_noise = 2.0
5657

5758
def _init(self, conf):
5859
if conf['fix_sampling']:

0 commit comments

Comments
 (0)