naver / kapture-localization

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

Bug: FileNotFoundError: [WinError 206] The filename or extension is too long #15

Closed szeliski closed 3 years ago

szeliski commented 3 years ago

When running the sample code in https://github.com/naver/kapture-localization/blob/main/doc/tutorial.adoc#1-mapping, i.e., running kapture_pipeline_mapping.py on the samples/virtual_gallery_tutorial, I get the following error:

FileNotFoundError: [WinError 206] The filename or extension is too long: 'colmap-sfm/r2d2_500/AP-GeM-LM18_top5/kapture_inputs/proxy_mapping/reconstruction/matches/r2d2_500/training/gallery_light1_loop1/frames/rgb/camera_0/rgb_00223.jpg.overlapping/training'

This is triggered inside

kapture_compute_matches.py", line 133, in compute_matches_from_loaded_data
image_matches_to_file(matches_path, matches)

(full traceback below).

It appears that the concatenation of directories for different variants in kapture is causing the default 260 character filename limit on Windows to be exceeded.

I can work around this by using RegEdit to set the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem variable LongPathsEnabled to 1.

Is this the preferred solution? If so, it might be helpful to mention this in your documentation. (You already mention that the scripts need to be run in Administrator mode to correctly follow symlinks on Windows.)

I noticed that there's a symlink in this long path (the second r2d2_500 I believe), so if the code resolved these, the resulting pathname would be shorter, but I'm not sure this is doable or worth the bother.

Thanks.

Full stack trace:

Traceback (most recent call last): File "C:\Temp\kapture-localization-main\tools\kapture_compute_matches.py", line 187, in compute_matches_command_line() File "C:\Temp\kapture-localization-main\tools\kapture_compute_matches.py", line 180, in compute_matches_command_line compute_matches(args.input, File "C:\Temp\kapture-localization-main\tools\kapture_compute_matches.py", line 72, in compute_matches compute_matches_from_loaded_data(input_path, File "C:\Temp\kapture-localization-main\tools\kapture_compute_matches.py", line 133, in compute_matches_from_loaded_data image_matches_to_file(matches_path, matches) File "C:\Users\szeli\AppData\Local\Programs\Python\Python39\lib\site-packages\kapture\io\features.py", line 464, in image_matches_to_file array_to_file(filepath, image_matches) File "C:\Users\szeli\AppData\Local\Programs\Python\Python39\lib\site-packages\kapture\io\binary.py", line 49, in array_to_file os.makedirs(path.dirname(filepath), exist_ok=True) File "C:\Users\szeli\AppData\Local\Programs\Python\Python39\lib\os.py", line 215, in makedirs makedirs(head, exist_ok=exist_ok) File "C:\Users\szeli\AppData\Local\Programs\Python\Python39\lib\os.py", line 215, in makedirs makedirs(head, exist_ok=exist_ok) File "C:\Users\szeli\AppData\Local\Programs\Python\Python39\lib\os.py", line 215, in makedirs makedirs(head, exist_ok=exist_ok) [Previous line repeated 1 more time] File "C:\Users\szeli\AppData\Local\Programs\Python\Python39\lib\os.py", line 225, in makedirs mkdir(name, mode) FileNotFoundError: [WinError 206] The filename or extension is too long: 'colmap-sfm/r2d2_500/AP-GeM-LM18_top5/kapture_inputs/proxy_mapping/reconstruction/matches/r2d2_500/training/gallery_light1_loop1/frames/rgb/camera_0/rgb_00223.jpg.overlapping/training'

yocabon commented 3 years ago

Hi, thanks for the issue; on my machine I do in fact have LongPathEnabled set to 1 and had forgotten all about it. I updated the documentation to mention it (https://github.com/naver/kapture-localization/commit/877f6618fbd45a4e7cbcfde4d5992d6c937ffaff), I hope it's enough.

szeliski commented 3 years ago

Thanks. I think the updating the documentation is fine.