Mapillary/Action cameras processing

From OpenStreetMap Wiki
Jump to navigation Jump to search

Action cameras imagery processing for Mapillary

Action cameras is different by content of metadata. Imagery for upload to Mapillary should have datetime, coordinates and direction stored in EXIF tags in JPG files. In most cases you need to convert or generate this data.

Run these commands in docker container is most easy solution, due to dependencies of Mapillary_tools/ffmpeg.

  • If video or photo files did not have datetime in exif (seen an cheap SJCAM cameras): write python script for extract datetime from filenames.
  • For GoPro timewarp mode: you can get speed ratio from files using exiftool command
exiftool -Rate  -q -q  -csv  $DIR/*.MP4
  • Run mapillary_tools, it command generate frames from videos, and write datetime to them
DIR="/data/20210109"

USERNAME="username"
ANGLE=0
INTERVAL=0.1 
RATIO=15 

time mapillary_tools video_process  --video_import_path "$DIR" \
--user_name $USERNAME --advanced --video_duration_ratio $RATIO --device_make GoPro --device_model "HERO8 Black" \
--video_sample_interval $INTERVAL --geotag_source "gopro_videos" --geotag_source_path "$DIR" \
 --use_gps_start_time --interpolate_directions --offset_angle $ANGLE 

For non-timelapse video, set video_duration_ratio to 1 and video_sample_interval to 1 for 1 frame per second

  • Cameras may have time drift while timelapse capture, so you should calculate some points on gpx track and datetime of images captured in this points. This operation mandratory for SJCAM videos, SJCAM photos, GOPRO timewarp videos. Open in JOSM gpx track, convert it to data layer, and you can click on points and watch time stored in gpx file
  • Generate and run exiftool command for georefrence
time exiftool  -overwrite_original -progress -geotag  $DIR/osmand.gpx \
-geosync="2021:01:09 10:55:46@13:50:00" \
-geosync="2021:01:09 11:04:16@13:58:02" \
-geosync="2021:01:09 11:18:23@14:09:47" \
-geosync="2021:01:09 11:20:22@14:11:33" \
-geosync="2021:01:09 11:27:32@14:17:54" \
-geosync="2021:01:09 11:36:08@14:25:47" \
$DIR/mapillary_sampled_video_frames/$FN/*.jpg

Left datetime - point in gpx track, right time - value stored in jpeg file. This command will interpolate and save gps location in jpeg files. Note that timezone will broken, images captured in UTC+3, so there 3 hour difference beetwen time in photos and time in gpx track.

  • Run mapillary_tools with interpolate_directions
path="/data/mapillary.sh/feeder"
mapillary_tools process_and_upload --advanced --import_path "$path/0" --user_name username  --interpolate_directions --offset_angle 0  --overwrite_EXIF_direction_tag --keep_duplicates
mapillary_tools process_and_upload --advanced --import_path "$path/45" --user_name username  --interpolate_directions --offset_angle 45  --overwrite_EXIF_direction_tag  --keep_duplicates
mapillary_tools process_and_upload --advanced --import_path "$path/90" --user_name username  --interpolate_directions --offset_angle 90  --overwrite_EXIF_direction_tag  --keep_duplicates
mapillary_tools process_and_upload --advanced --import_path "$path/180" --user_name username  --interpolate_directions --offset_angle 180  --overwrite_EXIF_direction_tag --keep_duplicates
mapillary_tools process_and_upload --advanced --import_path "$path/270" --user_name username  --interpolate_directions --offset_angle 270  --overwrite_EXIF_direction_tag  --keep_duplicates

mapillary_tools process_and_upload --advanced --import_path "$path/keep_direction" --user_name username   --keep_duplicates