Skip to content

Match samples to videos of the same name by their paths - #910

Merged
caglarpir merged 1 commit into
mapillary:mainfrom
caglarpir:match-samples-by-relative-path
Oct 24, 2026
Merged

caglarpir merged 1 commit into
mapillary:mainfrom
caglarpir:match-samples-by-relative-path

Conversation

@caglarpir

Copy link
Copy Markdown
Contributor

Stacked on #909; review the last commit.

sample_video writes the samples of a video in a folder named after it,
at the video's path relative to the folder of videos it samples: the
samples of VIDEOS/x/clip.mp4 go to OUT/x/clip.mp4/. The legacy
gopro_videos, blackvue_videos and camm sources, and exiftool_xml with a
pattern in video_process, matched samples to videos by the name of that
folder alone, so all the samples of videos of the same name in
different folders were taken for those of one of them. With two
BlackVue videos named clip.mp4 in the folders x and y, video_process VIDEOS OUT --geotag_source blackvue_videos placed the 13 samples of one
along the track of the other, up to 2.1 km off, and failed the 50
samples of the other, with exit 0; exiftool_xml did the same.

Match a sample to the video whose path, relative to the deepest folder
that holds all the videos, its folder ends with, the longest of them if
several do. A sample whose folder ends with none of them, which could
be of any of them, is failed with "Cannot tell which of the 2 videos
named clip.mp4 this is a frame of", rather than placed along one of
them: such as the samples of one of the videos sampled alone, and
geotagged by the folder of both. That is a geotagging error, which a
later source can still replace. With a single video of a name, its
samples are found wherever they are, as before.

On the two videos, the 63 samples are now geotagged by the legacy source
and by exiftool_xml as by the video's own GPS (0 m off), and as
exiftool_xml geotags the samples of each video alone. So are those of
two videos of the same name one above the other (VIDEOS/clip.mp4 and
VIDEOS/x/clip.mp4, and VIDEOS/a/clip.mp4 and VIDEOS/a/b/clip.mp4).
process of the frames of videos of different names, by their legacy
sources, of a single video by its file or folder, of a mixed folder and
an image sequence, and video_process with the default sources, the
legacy source and exif, do not change.

Unit and integration tests, doctests, mypy --python-version 3.9, ruff check, ruff format --check and usort diff are clean.

sample_video writes the samples of a video in a folder named after it,
at the video's path relative to the folder of videos it samples: the
samples of VIDEOS/x/clip.mp4 go to OUT/x/clip.mp4/. The legacy
gopro_videos, blackvue_videos and camm sources, and exiftool_xml with a
pattern in video_process, matched samples to videos by the name of that
folder alone, so all the samples of videos of the same name in
different folders were taken for those of one of them. With two
BlackVue videos named clip.mp4 in the folders x and y, `video_process
VIDEOS OUT --geotag_source blackvue_videos` placed the 13 samples of one
along the track of the other, up to 2.1 km off, and failed the 50
samples of the other, with exit 0; exiftool_xml did the same.

Match a sample to the video whose path, relative to the deepest folder
that holds all the videos, its folder ends with, the longest of them if
several do. A sample whose folder ends with none of them, which could
be of any of them, is failed with "Cannot tell which of the 2 videos
named clip.mp4 this is a frame of", rather than placed along one of
them: such as the samples of one of the videos sampled alone, and
geotagged by the folder of both. That is a geotagging error, which a
later source can still replace. With a single video of a name, its
samples are found wherever they are, as before.

A sample that two videos match equally well, such as videos of the same
name on different drives, which no path tells apart, is failed the same
way. Paths are made absolute before they are compared, also where they
do not exist: Path.resolve() leaves those relative on Windows with
Python 3.9 and 3.10.

On the two videos, the 63 samples are now geotagged by the legacy source
and by exiftool_xml as by the video's own GPS (0 m off), and as
exiftool_xml geotags the samples of each video alone. So are those of
two videos of the same name one above the other (VIDEOS/clip.mp4 and
VIDEOS/x/clip.mp4, and VIDEOS/a/clip.mp4 and VIDEOS/a/b/clip.mp4).
process of the frames of videos of different names, by their legacy
sources, of a single video by its file or folder, of a mixed folder and
an image sequence, and video_process with the default sources, the
legacy source and exif, do not change.
@caglarpir
caglarpir force-pushed the match-samples-by-relative-path branch from 6ed7492 to 8fc58cc Compare October 24, 2026 12:55
@caglarpir
caglarpir merged commit 55d99e6 into mapillary:main Oct 24, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant