Modify

Opened 3 years ago

Closed 3 years ago

Last modified 2 years ago

#22982 closed defect (invalid)

[Possible PATCH] Image sequence sort order is based on file creation time, not time taken.

Reported by: cyton Owned by: team
Priority: normal Milestone:
Component: Core Version:
Keywords: Cc:

Description

When injecting exif data into an image sequence based on a separate gpx file, the resulting image is shown at the correct gps coordinates, but in wrong order, the time shown is today (now), not when the datetimeoriginal.

The sequence is shown in order of file creation, which "appears random" when looking at it and going to next image. The EXIF time: shown in the top right is not datetimeoriginal, but the time the file was created.

Attachments (2)

GS015642_NA_003576.jpg (2.5 MB ) - added by cyton 3 years ago.
gopro max 360 image with custom gps and custom date taken from gpx file
GS015642_NA_003577.jpg (2.6 MB ) - added by cyton 3 years ago.

Change History (6)

by cyton, 3 years ago

Attachment: GS015642_NA_003576.jpg added

gopro max 360 image with custom gps and custom date taken from gpx file

by cyton, 3 years ago

Attachment: GS015642_NA_003577.jpg added

comment:1 by cyton, 3 years ago

Resolution: invalid
Status: newclosed

comment:2 by taylor.smock, 3 years ago

Summary: Image sequence sort order is based on file creation time, not time taken.[Possible PATCH] Image sequence sort order is based on file creation time, not time taken.

To clarify, you do the following:

  1. Take images on the 360 without GPS (or you do, and then use the GPS date/time to correlate with a higher precision track)
  2. Correlate images to external GPS track (probably from something with a higher precision and accuracy than the built-in GPS)
  3. The program doing the image correlation modifies the file creation time to be when it wrote the new GPS information
  4. JOSM loads the files in order based off of the file creation date

If that is the case, then whatever program is doing the image correlation should be setting the file creation time to when the image was taken.

Regardless, we could probably fix this with

  • src/org/openstreetmap/josm/gui/layer/geoimage/ImagesLoader.java

    diff --git a/src/org/openstreetmap/josm/gui/layer/geoimage/ImagesLoader.java b/src/org/openstreetmap/josm/gui/layer/geoimage/ImagesLoader.java
    a b  
    55
    66import java.io.File;
    77import java.io.IOException;
     8import java.time.Instant;
    89import java.util.ArrayList;
    910import java.util.Arrays;
    1011import java.util.Collection;
     12import java.util.Comparator;
    1113import java.util.HashSet;
    1214import java.util.LinkedHashSet;
    1315import java.util.List;
    1416import java.util.Map;
     17import java.util.Optional;
    1518import java.util.Set;
    1619import java.util.TreeMap;
    1720import java.util.stream.Collectors;
     
    9497            File parentFile = f.getParentFile();
    9598            entries.computeIfAbsent(parentFile != null ? parentFile.getName() : "", x -> new ArrayList<>()).add(e);
    9699        }
     100        // Sort the images based off of GPS time, if available
     101        entries.values().forEach(list -> list.sort(Comparator.comparing(image -> Optional.ofNullable(Utils.firstNonNull(
     102                image.getExifGpsInstant(),
     103                image.getExifInstant(),
     104                image.getGpsInstant(),
     105                Optional.ofNullable(image.getFile()).map(File::lastModified).map(Instant::ofEpochMilli).orElse(Instant.EPOCH)
     106        )).orElse(Instant.EPOCH))));
    97107        if (Boolean.TRUE.equals(PROP_ONE_LAYER_PER_FOLDER.get())) {
    98108            entries.entrySet().stream().map(e -> new GeoImageLayer(e.getValue(), gpxLayer, e.getKey())).forEach(layers::add);
    99109        } else {

comment:3 by cyton, 2 years ago

See my german diary entry on how i did this; https://www.openstreetmap.org/user/cyton/diary/401670

But I think I closed this issue as invalid because my script did something wrong or set the wrong thing or not enough of the metadata, in hindsight i should have said here why i closed it. I fixed my script and then closed this.

But sorting by gps time is not a bad idea.
I noticed for images taken with my gopro hero8 black that the time written in the exif metadata is wrong, even the gps time, which sometimes led to one image being out of sequence, as if swapped with the next.
For that i noticed that the time does not follow [0.2. 0.7, 1.2, 1.7...] but instead there somehow is a zero inserted: [0.02, 0.07, 1.02, 1.07...].
That is a problem with the firmware of the gopro.
Nowadays when i do take images its with the max because i much prefer the 360 imagery.

comment:4 by cyton, 2 years ago

I used josm to set the gps offset, and the addon to write the new position to file, but only after i got my script to write the correct time.
Here is said script;
https://gist.github.com/joshinils/2ca6dd75ac6c1093b4d4fd2d60c68145

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.