naver / kapture-localization

Provide mapping and localization pipelines based on kapture format
BSD 3-Clause "New" or "Revised" License
268 stars 42 forks source link

errors in running #12

Closed ljylijianyu closed 3 years ago

ljylijianyu commented 3 years ago

When I use the scripts alone , for example kapture_compute_image_pairs.py, it always makes mistakes , Do you have any ideas about this ? By the way, as a new one of visual-based location, do you have any recommended books in coding?

/home/ljy/kapture/kapture-localization/tools/kapture_compute_image_pairs.py -v info --mapping /home/ljy/kapture/kapture-localization/samples/virtual_gallery_tutorial/mapping --query /home/ljy/kapture/kapture-localization/samples/virtual_gallery_tutorial/query -o /home/ljy/kapture/kapture-localization/samples/virtual_gallery_tutorial/colmap-localization/r2d2_500/AP-GeM-LM18_top5/AP-GeM-LM18_top5/ --topk 5 INFO ::compute_image_pairs: compute_image_pairs. loading mapping: /home/ljy/kapture/kapture-localization/samples/virtual_gallery_tutorial/mapping Traceback (most recent call last): File "/home/ljy/kapture/kapture-localization/tools/kapture_compute_image_pairs.py", line 158, in compute_image_pairs_command_line() File "/home/ljy/kapture/kapture-localization/tools/kapture_compute_image_pairs.py", line 154, in compute_image_pairs_command_line compute_image_pairs(args.mapping, args.query, args.output, args.global_features_type, args.topk) File "/home/ljy/kapture/kapture-localization/tools/kapture_compute_image_pairs.py", line 53, in compute_image_pairs assert kdata_mapping.global_features is not None AssertionError

Process finished with exit code 1

yocabon commented 3 years ago

Hi, The issue you're running into is that virtual_gallery_tutorial/mapping and virtual_gallery_tutorial/query only contains the sensor information (not the features - compute_image_pairs.py requires global features for both the mapping and the query inputs).

The features are provided in different folders - we call them orphan features. The file structure used is described here, https://github.com/naver/kapture-localization/blob/main/doc/tutorial.adoc#recommended-dataset-structure. In kapture-localization, we chose to store the binary data in such a way so that it'd be very easy to reuse as much as possible between many experiments (mostly matches).

In any case, the individual scripts assumes that the input that strictly follows the kapture format while the pipeline scripts take a kapture with only sensors data and the oprhan features as input.

If you check the pipeline scripts, you can see that it start by building (with symlinks) what we call "proxy" kapture, here for example The "sensors" folder is taking from the kapture data, and every orphan features are symlinked to their correct location inside "reconstruction".

I just pushed an executable script that does the same here.

for compute_image_pairs.py to work, your inputs should look like this: sensors\ reconstruction\global_features\AP-GeM-LM18\

it could be achieved with

kapture_create_kapture_proxy.py -i ../samples/virtual_gallery_tutorial/mapping -o ../samples/virtual_gallery_tutorial/mapping_proxy -gfeat ../samples/virtual_gallery_tutorial/global_features/AP-GeM-LM18/global_features
kapture_create_kapture_proxy.py -i ../samples/virtual_gallery_tutorial/query -o ../samples/virtual_gallery_tutorial/query_proxy -gfeat ../samples/virtual_gallery_tutorial/global_features/AP-GeM-LM18/global_features

and then using mapping_proxy ; query_proxy as inputs to compute_image_pairs.py

ljylijianyu commented 3 years ago

Thanks for your kind reply,and it really works for me. However, when I use this tool running localization tutorial. My python makes some errors. sudo kapture_pipeline_mapping.py -v info
-i ./mapping
-kpt ./local_features/r2d2_500/keypoints
-desc ./local_features/r2d2_500/descriptors
-gfeat ./global_features/AP-GeM-LM18/global_features
-matches ./local_features/r2d2_500/NN_no_gv/matches
-matches-gv ./local_features/r2d2_500/NN_colmap_gv/matches
--colmap-map ./colmap-sfm/r2d2_500/AP-GeM-LM18_top5
--topk 5

It returns File "/usr/lib/python3.6/argparse.py", line 1361, in add_argument return self._add_action(action) File "/usr/lib/python3.6/argparse.py", line 1585, in _add_action action = self._container._add_action(action) File "/usr/lib/python3.6/argparse.py", line 1724, in _add_action self._optionals._add_action(action) File "/usr/lib/python3.6/argparse.py", line 1565, in _add_action action = super(_ArgumentGroup, self)._add_action(action) File "/usr/lib/python3.6/argparse.py", line 1375, in _add_action self._check_conflict(action) File "/usr/lib/python3.6/argparse.py", line 1514, in _check_conflict conflict_handler(action, confl_optionals) File "/usr/lib/python3.6/argparse.py", line 1523, in _handle_conflict_error raise ArgumentError(action, message % conflict_string) argparse.ArgumentError: argument -gfeat/--global-features-path: conflicting option strings: -gfeat, --global-features-path

In fact, I just run scripts,it also makes errors. When I using the mapping tutorial, I have not met this problem, it makes me confused. image

As you can see, image The confl_optionnals is not [] , do you have any idea to solve this?

After commenting out the line, it can work. image

Looking forward to your reply!

yocabon commented 3 years ago

Hi, there was indeed a problem with kapture_pipeline_localize.py (a regression I introduced last month, when I added the possibility of using pairsfile instead of global features). I pushed the fix