OpenStreetMap logo OpenStreetMap

I have a few passions in life. Two of them overlap in an interesting fashion…

A number of years ago, I decided to look at how engineering (and specifically full-lifecycle analysis) could support improvements in road safety. While many road safety issues are primarily behavioural (speeding, awareness, road rage, etc), I strongly believe that infrastructure should guide road users to making better decisions over time through feedback, reinforcement of good behaviours, etc. Anyway… I decided to buy a dashcam and figure out if there was a way to collect data in a way that would provide strong arguments for change at both a local and national / international level. Due to other commitments and a lack of interest from the general public I haven’t made much progress. :(

My other rationale for getting a dashcam was to allow imagery capture to support mine and others’ OpenStreetMap activities. I drive quite a bit on my way to climb mountains and explore the south coast of Ireland (sometimes to play MMORPG Ingress). Capturing imagery and contributing it to the global community seemed like a good way to get additional “mileage” out of my travels!

But dashcams aren’t setup for sending data to Mapillary I here you say… True… but I never give up!

The OpenStreetMap Ireland community recently decided to capture imagery and authoritatively map the #WildAtlanticWay, a 2500+ km route along the west coast of Ireland. While there is some existing imagery of the route, there are some notable gaps and we wanted to fix that.

Being one of the primary contributors in Cork (Ireland’s largest county by land area), I was motivated to try and contribute more imagery in Co. Cork and Co. Kerry. So I started digging into the tools available for processing and uploading data again (to see what improvements had been made since I last tried).

Processing dashcam videos so they are usable my mapillary

I quickly came across this discussion on https://forum.mapillary.com/ which indicated some folk had make progress extracting imagery from a Viofo A119 dashcam. I had a slightly newer model (the A129) so I was hopeful that the code would work. I updated my dashcam firmware and captured some new video. When I got home, I tried processing it but got timestamp decoding issues (the data offsets for the A129 were different (see here)). Fortunately, one of the project contributors was able to decipher the offsets and provide a patch that would work for the A129. Wohooo… I tried it with some more video I had captured and my first set of JPGs were created! \o/

Uploading to Mapillary (part 1)

Next up, it was time to upload the imagery to Mapillary. The acquisition of Mapillary by Facebook has been well documented and the team have not been slow at pushing forward with their plans. This has impacted imagery contributors and the OpenStreetMap community considerably in the past couple of months as Mapillary update their API and rollout out some new processing pipelines and features. Unfortunately, this also meant that most of the opensource ecosystem was broken too. Ahhhh!

Fortunately, I found the mapillary/mapillary_tools repository (official tools maintained by Mapillary). But I was running into issues. My password needed to be changed because of the recent acquisition and after that I couldn’t log in using the python tools on linux. Was there lag with the password change replicated to auth servers? Was my account broken?

I could not determine the cause so I filed an issue.

Again, I got a response fairly quickly (not bad for a friday evening PST time!!). It wasn’t me ( \o/ )… it was a bug. API v4.0 was rolling out and the tools didn’t support it (yet). A quick commit by the developers and a new release (v 0.7.0) and authentication was working for me. Wohoo…

Uploading to Mapillary (part 2)

The moment of truth had arrived. My images were ready. My Mapillary authentication was working. It was time to upload imagery…

$ mapillary_tools process_and_upload --import_path "../random-mapillary-stuff/output" --user_name "donal"
Running user_process for 415 images, skipping 0 images.
Sub process ended                                                                                                                                                        
Running import_meta_data_process for 0 images, skipping 415 images.
No images to run import meta data process
If the images have already been processed and not yet uploaded, they can be processed again, by passing the argument --rerun
Sub process ended                                     
Running geotag_process for 0 images, skipping 415 images.
No images to run geotag process
If the images have already been processed and not yet uploaded, they can be processed again, by passing the argument --rerun
Sub process ended                                      
Running sequence_process for 0 images, skipping 415 images.
Sub process ended
Running upload_params_process for 415 images, skipping 0 images.
Sub process ended                                                                                                                                                        
Running mapillary_image_description for 415 images, skipping 0 images.
Sub process ended                                                                                                                                                        
Process done.
Uploading 415 images with valid mapillary tags (Skipping 0)
Compressing 415 image files to /home/dhunt/src/random-mapillary-stuff/output/sequence_b0645290-3b0a-41bc-903b-961b8b95699f.zip
Writing /home/dhunt/src/random-mapillary-stuff/output/2021_0610_194450_037F.MP4_000000.jpg to /home/dhunt/src/random-mapillary-stuff/output/sequence_b0645290-3b0a-41bc-903b-961b8b95699f.zip/2021_0610_194450_037F.MP4_000000.jpg captured at 2021_06_10_20_44_50_000
Writing /home/dhunt/src/random-mapillary-stuff/output/2021_0610_194450_037F.MP4_000001.jpg to /home/dhunt/src/random-mapillary-stuff/output/sequence_b0645290-3b0a-41bc-903b-961b8b95699f.zip/2021_0610_194450_037F.MP4_000001.jpg captured at 2021_06_10_20_44_50_333
Writing /home/dhunt/src/random-mapillary-stuff/output/2021_0610_194450_037F.MP4_000002.jpg to /home/dhunt/src/random-mapillary-stuff/output/sequence_b0645290-3b0a-41bc-903b-961b8b95699f.zip/2021_0610_194450_037F.MP4_000002.jpg captured at 2021_06_10_20_44_50_666

=== snip ===

Uploading /home/dhunt/src/random-mapillary-stuff/output/sequence_b0645290-3b0a-41bc-903b-961b8b95699f.zip (187423362 bytes) ...
Finishing uploading /home/dhunt/src/random-mapillary-stuff/output/sequence_b0645290-3b0a-41bc-903b-961b8b95699f.zip with file handle 

=== snip ===

Cluster 2880127168972143 created
Deleting /home/dhunt/src/random-mapillary-stuff/output/sequence_b0645290-3b0a-41bc-903b-961b8b95699f.zip...
Done uploading 415 images.
No post processing action specified.

and now we wait for the imagery to be processed by Mapillary… =)

p.s. Next goal is to process the rear camera such that Mapillary knows they are pointing the opposite direction to travel. Wish me luck!

Lessons learnt

  1. Try new things… Even if they didn’t work before, maybe the ecosystem has matured and your odds are better.
  2. Don’t give up… Ask for help… File issues.
  3. Document your findings. Inspire others. Guide others in the right direction.
  4. Be grateful for those that help you. Give back in some way.

References

If you are having auth problems with the mapillary_tools toolchain, the following command is helpful for doing a complete recent.

$ mapillary_tools --advanced authenticate --force_overwrite --user_name "<username>" --user_email "<email>" --user_password "<password>"

Tech specs

  • Vehicle: Volkswagen Passat B6 2010
  • Dashcam: Viofo A129 Duo Dual Lens Dash Cam Full HD 1080P 140° Wide Angle Front and Rear Dashboard Camera w/GPS WiFi, Parking Mode, Supercapacitor, Low Light Vision G-Sensor
  • Laptop: Lenovo Thinkpad Carbon X1
Location: 51.899, -8.472

Discussion

Comment from n76 on 11 June 2021 at 20:53

Congratulations! It sound like you found a workable solution.

I backed out of Mapillary when they were acquired but understand the need and desire for the functionality they provide.

In the meantime, I find my older Viofo 119s v2 dash cam to be a valuable mapping tool even if I don’t upload the images for others to use. I documented my setup on my blog.

I didn’t read through all the details on your tool chain, but for the script I use for my 119s V2 it would be fairly easy to rotate the direction information on the images by 180°.

Comment from DeBigC on 11 June 2021 at 23:01

Dónal this is a brilliant post and well done, well written and thanks for specifying lessons.

My main take-away from this are that I have heard in the established mapping community from contributors who have dashcams and don’t have the time to hack at them to make them mapillary friendly. This should be read by all them, and you could make a video about how you did it step by step.

On the Wild Atlantic Way there are still gaps at Kinsale, where the way officially ends/begins depending on whether you are a clockwise revolutionary, or a member of the chartered royal society of anti-clockwisers.

Comment from StephaneP on 20 June 2021 at 14:49

Hi! For the rear camera, you will have to add these parameters: --interpolate_directions --offset_angle 180

I’ve uploaded some WildAtlanticWay images a long time ago, 2015 I think. :-)

Comment from Fnordson on 20 June 2021 at 17:17

Now we just need Mapillary to set up a noob-friendly way based upon your findings ;)

Comment from ibanez on 20 June 2021 at 17:42

Thanks for the nice post. I use the mapillary-tools as well, but inside a docker container. It may be valueable to use a docker container as system changes/updates will never harm your running setup. And the mapillary-tools can never mess up your systems data.

I’ve built an Dockerfile out of what’s on github and added installation of Piexif

RUN pip install –upgrade git+https://github.com/mapillary/Piexif

The MP4 vids from my Gopro are laying in a home-subfolder /home/user/gopro/ and will be bound to the docker container at startup (1736 are the first 4 digits of the docker image). The videos are then available in /goprov inside the container image: sudo docker run -it –mount type=bind,source=/home/user/gopro,target=/goprov 1736 /bin/bash

The videos will be processed into single pictures under /home/usr/gopro/processed with the following call.

mapillary_tools video_process –advanced –import_path /goprov/processed –video_import_path /goprov –geotag_source “gopro_videos” –geotag_source_path /goprov –interpolate_directions –video_sample_interval 0.5 –overwrite_EXIF_gps_tag –use_gps_start_time –user_name MY_MAPILLARY_NAME

After checking the results I’ve upload the images: mapillary_tools upload –import_path /goprov/processed

but you can do it in a single command with: mapillary_tools video_process_and_upload

Log in to leave a comment