Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to extract AltitudeRef, but then crashes with "IndexError: list index out of range" #555

Closed
blaueente opened this issue Oct 3, 2022 · 2 comments · Fixed by #557
Closed

Comments

@blaueente
Copy link

Apparently some photos that have an altitude tag ["GPS GPSAltitude", "EXIF GPS GPSAltitude"]
somehow the altitude ref tag fails being extracted ["GPS GPSAltitudeRef", "EXIF GPS GPSAltitudeRef"]

This makes the script crash.

Basic information

Steps to reproduce behavior

Start file upload Upload.

Expected behavior

finish upload, no error

Actual behavior

during the first scan, the following error is output:

$ mapillary_tools --verbose --verbose process_and_upload .
2022-10-03 12:50:24,784 - DEBUG - CLI param: verbose: True
2022-10-03 12:50:24,784 - DEBUG - CLI param: import_path: [PosixPath('.')]
2022-10-03 12:50:24,785 - DEBUG - CLI param: skip_subfolders: False
2022-10-03 12:50:24,785 - DEBUG - CLI param: skip_process_errors: False
2022-10-03 12:50:24,785 - DEBUG - CLI param: overwrite_all_EXIF_tags: False
2022-10-03 12:50:24,785 - DEBUG - CLI param: overwrite_EXIF_time_tag: False
2022-10-03 12:50:24,785 - DEBUG - CLI param: overwrite_EXIF_gps_tag: False
2022-10-03 12:50:24,785 - DEBUG - CLI param: overwrite_EXIF_direction_tag: False
2022-10-03 12:50:24,785 - DEBUG - CLI param: overwrite_EXIF_orientation_tag: False
2022-10-03 12:50:24,785 - DEBUG - CLI param: add_file_name: False
2022-10-03 12:50:24,785 - DEBUG - CLI param: add_import_date: False
2022-10-03 12:50:24,785 - DEBUG - CLI param: geotag_source: exif
2022-10-03 12:50:24,785 - DEBUG - CLI param: interpolation_use_gpx_start_time: False
2022-10-03 12:50:24,785 - DEBUG - CLI param: interpolation_offset_time: 0.0
2022-10-03 12:50:24,785 - DEBUG - CLI param: offset_angle: 0.0
2022-10-03 12:50:24,785 - DEBUG - CLI param: offset_time: 0.0
2022-10-03 12:50:24,785 - DEBUG - CLI param: cutoff_distance: 600.0
2022-10-03 12:50:24,785 - DEBUG - CLI param: cutoff_time: 60.0
2022-10-03 12:50:24,785 - DEBUG - CLI param: interpolate_directions: False
2022-10-03 12:50:24,785 - DEBUG - CLI param: duplicate_distance: 0.1
2022-10-03 12:50:24,785 - DEBUG - CLI param: duplicate_angle: 5.0
2022-10-03 12:50:24,785 - DEBUG - CLI param: file_types: {<FileType.IMAGE: 'image'>}
2022-10-03 12:50:24,785 - DEBUG - CLI param: dry_run: False
2022-10-03 12:50:25,123 - DEBUG - Found 8585 images in total
Traceback (most recent call last):
File "/home/user/.local/bin/mapillary_tools", line 8, in
sys.exit(main())
File "/home/user/.local/lib/python3.10/site-packages/mapillary_tools/commands/main.py", line 141, in main
args.func(argvars)
File "/home/user/.local/lib/python3.10/site-packages/mapillary_tools/commands/process_and_upload.py", line 18, in run
ProcessCommand().run(args)
File "/home/user/.local/lib/python3.10/site-packages/mapillary_tools/commands/process.py", line 242, in run
descs = process_geotag_properties(
File "/home/user/.local/lib/python3.10/site-packages/mapillary_tools/process_geotag_properties.py", line 181, in process_geotag_properties
return list(types.map_descs(_validate_and_fail_desc, geotag.to_description()))
File "/home/user/.local/lib/python3.10/site-packages/mapillary_tools/geotag/geotag_from_exif.py", line 72, in to_description
altitude = exif.extract_altitude()
File "/home/user/.local/lib/python3.10/site-packages/mapillary_tools/exif_read.py", line 126, in extract_altitude
ref, _ = self._extract_alternative_fields(fields, default=0, field_type=int)
File "/home/user/.local/lib/python3.10/site-packages/mapillary_tools/exif_read.py", line 110, in _extract_alternative_fields
return int(self.tags[field].values[0]), field
IndexError: list index out of range

Corresponding data

Additional information

This happened with 0.9.0 at about 90% of initial scanning, then I updated to 0.9.2 using
python3 -m pip install --upgrade git+https://github.com/mapillary/mapillary_tools
And now it happens much earlier in the process.

Unfortunately, the offending file is not shown, so I cannot attach an example of such a file.
adding --verbose once or even twice does not help

Suggestion: before starting to process a specific image, write the image filename to the debug log.

@blaueente
Copy link
Author

Update: I added some debug logging and found that this happens exclusively on panoramas from gcam. I have attached one.
PXL_20220926_101847668 PANO

@ptpt
Copy link
Member

ptpt commented Oct 3, 2022

Thanks for providing the example image. It should be fixed in #557. Here is the output of processing:

Note that since the altitude ref EXIF value is invalid, so it defaults to positive (above sea level):

python3 -m mapillary_tools.commands process TEST.jpg
Processing: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 195.61images/s]
Test EXIF writing: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 61.05images/s]
2022-10-03 12:53:58,185 - WARNING - Writing image descriptions to STDOUT, because the import path "TEST.jpg" is a file
[
    {
        "MAPLatitude": 35.365566666666666,
        "MAPLongitude": 24.262627777777777,
        "MAPCaptureTime": "2022_09_26_13_18_57_672",
        "filename": "TEST.jpg",
        "MAPAltitude": 27.5,
        "MAPOrientation": 1,
        "MAPDeviceMake": "Google",
        "MAPDeviceModel": "Pixel 6 Pro",
        "MAPMetaTags": {
            "strings": [
                {
                    "key": "mapillary_tools_version",
                    "value": "0.9.2"
                }
            ]
        },
        "MAPSequenceUUID": "4fbc031c-1225-4554-ac61-f4030caac38f",
        "MAPCompassHeading": {
            "TrueHeading": 0.0,
            "MagneticHeading": 0.0
        }
    }
]
2022-10-03 12:53:58,185 - INFO    - Check the image description file for details: -
2022-10-03 12:53:58,185 - INFO    -        1 images read in total
2022-10-03 12:53:58,185 - INFO    -        1 images processed and ready to be uploaded

@ptpt ptpt closed this as completed in #557 Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants