Bug: tools/kapture_print.py crashes
szeliski opened this issue · comments
I'm following along the instructions in https://github.com/naver/kapture/blob/main/doc/installation.adoc#4-test-your-installation and when I run the following:
cd kapture # use path of your cloned repository
cd tools
python ./kapture_print.py -i ../samples/Aachen-Day-Night/kapture/training
I get the following output:
nb sensors : 3
nb trajectories : 3
nb records_camera : 3
nb types keypoints : 1
└─ nb images sift : 3
Traceback (most recent call last):
File "C:\Temp\kapture\kapture-main\tools\kapture_print.py", line 381, in <module> print_command_line()
File "C:\Temp\kapture\kapture-main\tools\kapture_print.py", line 340, in print_command_line
do_print(kapture_data, args.input, args.output, args.detail, args.all,
File "C:\Temp\kapture\kapture-main\tools\kapture_print.py", line 376, in do_print
print_matches(kapture_data, output_stream, show_detail, show_all)
File "C:\Temp\kapture\kapture-main\tools\kapture_print.py", line 261, in print_matches
for kpt_type, matches in kapture_data.matches.items():
AttributeError: 'NoneType' object has no attribute 'items'
The output differs from the one in the documentation at the "nb images sift" line, and then the code crashes, I'm guessing because the matches.txt file is missing and this case isn't handled properly in this code path:
def print_matches(kapture_data, output_stream, show_detail, show_all) -> None:
...
nb_kpts_types = None if kapture_data.matches is None else len(list(kapture_data.matches.keys()))
if not show_detail:
print_key_value('nb types ', nb_kpts_types, output_stream, show_all)
for kpt_type, matches in kapture_data.matches.items():
BTW: thanks for producing such clean and extremely well documented code!
Thank you for point this bug.
It should be fixed with commit 88bee36.
It should now produces :
nb sensors : 3
nb trajectories : 3
nb records_camera : 3
nb types keypoints : 1
└─ nb images sift : 3
nb points 3-D : 5
nb observed 3-D points : 27
nb observation 2-D points: 27
Thanks for the quick fix.