Hloc KeyError
Hello i get the following error:
File "/home/user/Hierarchical-Localization/hloc/reconstruction.py", line 118, in main import_matches(image_ids, database, pairs, matches, File "/home/user/Hierarchical-Localization/hloc/triangulation.py", line 87, in import_matches id0, id1 = image_ids[name0], image_ids[name1] KeyError: 'frame_00026.jpg'
I assume that hloc does this because not for all images poses have been found. How can i prevent this error? thx
This means that correspondences that are in your pair file are not in the match h5 file. Can you share code or commands?
For help, I used the ns-process-data command in nerfstudio and the sfm-tool to select hloc to process my personal data. However, this error also occurred. How can I resolve it? This is the error code:
(ns) root@DESKTOP-545OEBJ:~# ns-process-data images --data /home/test0717 --output-dir /home/test0717 --sfm-tool hloc --feature-type sift --matcher-type NN
[16:56:10] 🎉 Done copying images. process_data_utils.py:239
[16:56:28] 🎉 Done downscaling images. process_data_utils.py:362
[2023/07/17 16:56:28 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'dog'},
'output': 'feats-sift',
'preprocessing': {'grayscale': True, 'resize_max': 1600}}
51%|█████████████████████████████████████████████████▉ | 86/167 [00:28<00:24, 3.27it/s]libpng warning: iCCP: known incorrect sRGB profile
100%|████████████████████████████████████████████████████████████████████████████████████████████████| 167/167 [00:52<00:00, 3.18it/s]
[2023/07/17 16:57:21 hloc INFO] Finished exporting features.
[2023/07/17 16:57:21 hloc INFO] Extracting local features with configuration:
{'model': {'name': 'netvlad'},
'output': 'global-feats-netvlad',
'preprocessing': {'resize_max': 1024}}
[2023/07/17 16:57:21 hloc INFO] Found 167 images in root /home/test0717/images.
75%|████████████████████████████████████████████████████████████████████████▍ | 126/167 [00:11<00:02, 14.85it/s]libpng warning: iCCP: known incorrect sRGB profile
100%|████████████████████████████████████████████████████████████████████████████████████████████████| 167/167 [00:13<00:00, 12.04it/s]
[2023/07/17 16:57:39 hloc INFO] Finished exporting features.
[2023/07/17 16:57:39 hloc INFO] Extracting image pairs from a retrieval database.
[2023/07/17 16:57:39 hloc INFO] Found 8350 pairs.
[2023/07/17 16:57:39 hloc INFO] Matching local features with configuration:
{'model': {'do_mutual_check': True, 'name': 'nearest_neighbor'},
'output': 'matches-NN-mutual'}
100%|██████████████████████████████████████████████████████████████████████████████████████████████| 4966/4966 [01:07<00:00, 73.43it/s]
[2023/07/17 16:58:47 hloc INFO] Finished exporting matches.
[2023/07/17 16:58:47 hloc INFO] Creating an empty database...
[2023/07/17 16:58:47 hloc INFO] Importing images into the database...
[2023/07/17 16:58:51 hloc INFO] Importing features into the database...
100%|██████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 1053.05it/s]
[2023/07/17 16:58:51 hloc INFO] Importing matches into the database...
0%| | 0/8350 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/root/miniconda3/envs/ns/bin/ns-process-data", line 8, in
I suppose this is due to the different camera parameters of the original images. Nerfstudio forces hloc to use a single camera model for the reconstruction (it happens after keypoints are extracted and matched) https://github.com/nerfstudio-project/nerfstudio/blob/main/nerfstudio/process_data/hloc_utils.py#L129
If you use hloc directly, you won't encounter such an error because it doesn't assume a single camera type in the data. (https://github.com/cvg/Hierarchical-Localization/blob/master/hloc/reconstruction.py#L98)
As a result, colmap fails to import some of the images into the database
At least this was my case, I hope that helps!
Good catch. I have no idea why Nerfstudio does this, switching to CameraMode.AUTO should handle most configurations.