Hello all, I made some batch scripts that should work for any camera that has a timelapse feature though I’ve only tested using the timelapse feature on the DJI Osmo Pocket 2. The Osmo series produces really smooth image sequences and they’re lightweight, so paired with a good-quality GPS trace they should be great for capturing street-level imagery sequences.
The tutorial uses Mapillary, but you should be able to upload the pictures to any of Panoramax, KartaView or Mapilio, or even just use them privately in JOSM or iD.
This DJI Help Center article gives an overview. You’ll need to set up your camera to take pictures on an interval, or use a timelapse video. The 30x timelapse on the Pocket 2 takes pictures every second, and puts them into an mp4 file. I made a couple of batch scripts that assume that the input is a timelapse video where each frame is a second apart, and that you start the GPX track at the same time as the video or sequence. You can also just use the second batch script to geotag an image sequence based on a GPS trace file.
Prerequisites
When you’re out recording, start the timelapse capture and the GPS trace at the same time. There are plenty of formats that can be used. I personally used FitoTrack and set it to the Walk mode, then exported the GPX and copied it to my computer. You may want to use an external GPS device for better accuracy, or set the trace capture frequency higher.
These batch files work on Windows, but each of the programs used are available on Linux and Mac as well, though you’ll need to modify the scripts so that they work there too, or just run the commands in sequence, modifying the inputs so that they work on your system.
You will need ffmpeg to convert the video into an PNG sequence, imagemagick to convert those to high-quality JPGs since the built-in ffmpeg JPG conversion is low-quality, and exiftool for re-timing the pictures and geotagging them. Make sure that the folders that contain those programs are in your PATH environment variable so that you can just call them directly from the command line. I think the installer for exiftool automatically adds it.
Convert the timelapse to a series of images
Only have the timelapse, GPX track, and the batch files in the folder.
Click and drag the video you want to convert to images onto this batch file, make sure to copy and paste the text into a file with the extension .bat first.
REM drag the file you want to convert to images onto this batch file. It will convert all frames, so if it’s not a timelapse it may be very large.
ffmpeg -i %1 -vsync passthrough %%05d.png
magick mogrify -format jpg *.png
Time and geotag the image sequence
Next, sort your Explorer window by size. This will make it easier to click and drag the GPX file onto the next script. (Or, you can just run the scripts from the command line).
This batch file takes the GPX file as input, then retimes the images and geotags them.
REM you will need to have exiftool installed for this to work.
REM this batch file assumes that the GPX file and the image series start at the same time and each image was taken a second apart (there may be an off-by-one error in the batch file though)
REM make sure to prepare a sequence of images first using the ffmpeg script. the only files in the folder should be the GPS track file, timelapse movie file, batch files and images you want to set the geotag and time on.
REM click and drag the GPS track file you want to use onto the batch file, or run the batch file inside the folder with it as the argument
set inputgpx=%1
REM this sets te file modified date to the first GPX track time.
exiftool “-FileModifyDate<GpxTrkTrksegTrkptTime” %inputgpx%
REM this sets the file modify date for all images to the gpx file modified date.
exiftool -TagsFromFile %inputgpx% -FileModifyDate “%cd%” -ext jpg
REM this increments all images by one second in sequence, so that each file will be one second away from the previous in the sequence. I think this produces files that are off-by-one from when they were actually taken. Not sure how to fix. It also only writes to jpg images.
exiftool “-FileModifyDate+<0:0:${filesequence;$_*=1}” “%cd%” -fileorder filename -overwrite_original -ext jpg
REM geotagging uses the date in DateTimeOriginal so we need to copy over from FileModifyDate.
exiftool “-DateTimeOriginal<FileModifyDate” “%cd%” -ext jpg -overwrite_original
REM this geotags the images using the input from the track file. It’s best if your track file has 1 second intervals, but it will still work for lower intervals.
exiftool -geotag=%inputgpx% “%cd%” -ext jpg -overwrite_original
Upload
Once the images are done, you can drag the folder containing them into the Mapillary desktop uploader, or you can use the Panoramax web uploader, etc. Check to make sure the images are in the correct location and you’re good to go! If you check the EXIF in the image viewer, the time will be UTC, but it will convert to the correct timezone once they’re uploaded.
Have fun capturing and stay hydrated!