2023-01-20 03:55:18 +01:00
# mapillary_download
2023-09-20 22:14:40 +02:00
Simple code to download images in one or several mapillary sequences. The images will be geotagged and oriented.
2023-01-20 04:19:37 +01:00
## How to use
2024-07-24 19:13:42 +02:00
### Setup env variables
2024-10-22 23:05:29 +02:00
copy the secret variables files to setup your mapillary dev token, and your panoramax OpenStreetMap token.
2024-07-24 19:13:42 +02:00
```Shell
2024-10-22 23:05:29 +02:00
cp secrets_variables_example.sh secrets_variables.sh
2024-07-24 19:13:42 +02:00
editor secrets_variables.sh
```
### Get ALL the sequences of SEVERAL users
To avoid to download everything at once, this is a 2 steps process:
- 1/ We set a list of users for which we want to get the list of sequences to download, and get a bash script for each user.
Change the list of users in the batch file `batch_get_username.sh` .
```bash
usernames=( "someone_having_nice_pictures" "someone_else" "oh_look_a_these_usernames" ) # use real accounts, it might work better
```
2024-10-22 23:05:29 +02:00
then, execute:
```bash
./batch_get_username.sh
```
2024-07-24 19:13:42 +02:00
This will give you a few files that the other scripts will use to generate a script to download all sequences of each user. One user, one bash script generated.
- 2/ We can launch the download of all the sequences of a user for every user specified in the batch script.
```bash
bash script_bash_get_sequences_for_user_SOMEONE.sh
```
**Or all of the generated batch scripts at once.**
2024-10-22 23:05:29 +02:00
2024-07-24 19:13:42 +02:00
```bash
bash script_bash_get_sequences_for_user_*
```
Don't worry if you rerun the same user `script_bash_get_sequences_for_user_someone.sh` twice, the pictures will not be downloaded twice. Every run of mapillary_download.py checks that pictures are not existing before willing to download them.
### Get only one sequence with its ID
To find a sequence id you can use the batch script, or click on a sequence on the Mapillary website, click on a picture, click on advanced data, and copy the sequence ID.
2023-01-20 04:19:37 +01:00
```Shell
2023-09-21 21:43:58 +02:00
python mapillary_download.py "MLY|xxxx|xxxxxxx" --sequence_ids xxxxxxxxxxx xxxxxxxxxxx
2023-09-20 12:21:14 +02:00
```
2024-07-24 19:13:42 +02:00
### Available arguments
2023-09-20 12:21:14 +02:00
```Shell
2023-09-21 21:43:58 +02:00
python mapillary_download.py -h
usage: mapillary_download.py [-h] [--sequence_ids [SEQUENCE_IDS ...]] [--image_ids [IMAGE_IDS ...]] [--destination DESTINATION]
2023-09-20 12:21:14 +02:00
[--image_limit IMAGE_LIMIT] [--overwrite]
access_token
positional arguments:
access_token Your mapillary access token
optional arguments:
-h, --help show this help message and exit
--sequence_ids [SEQUENCE_IDS ...]
The mapillary sequence id(s) to download
--image_ids [IMAGE_IDS ...]
The mapillary image id(s) to get their sequence id(s)
--destination DESTINATION
Path destination for the images
--image_limit IMAGE_LIMIT
How many images you want to download
--overwrite overwrite existing images
2023-09-21 21:43:58 +02:00
-v, --version show program's version number and exit
2023-01-20 04:19:37 +01:00
```
2024-07-24 19:13:42 +02:00
## Sort pictures depending of a bounding box in their Exif GPS Data in a separate folder
This is used to restrict zones for national instances of Panoramax to upload to reuse the sequences of multi national users.
Edit the bounding boxes in `find_france_photos_and_move.py` and change the destination folder.
2024-10-20 13:32:22 +02:00
Running the script will check in the /data folder for every user sequences and move the files being in the bouding boxes in the `destination` folder path of the script.
2023-09-20 22:10:06 +02:00
2024-07-24 19:13:42 +02:00
For this script to read the exif of pictures, you will need the python package `exifread`
It was tested with pictures taken with the App Open Camera.
## How to get my Mapillary access token
2023-09-20 22:10:06 +02:00
- Go to https://www.mapillary.com/dashboard/developers
- Click on "Registrer Application", enter the needed informations, enable the application to "Read" data, then click on register :
![register application ](./doc/snapshot_mapillary_register_application.jpg )
- When this registration is done, click on "view" in the token column. This is you access token :
2023-09-20 22:12:45 +02:00
2023-09-20 22:10:06 +02:00
![token ](./doc/snapshot_mapillary_token.jpg )
2023-09-20 22:12:45 +02:00
## How to get my sequence id (or sequence key)
2023-09-20 22:10:06 +02:00
- Go to https://mapillary.com/app
- Click on one of the picture of the sequence you want to download
- Click on the "image option" button (right panel)
2023-09-20 22:12:45 +02:00
- Click on "advanced" then click on the sequence key to copy it in the clipboard
2023-09-20 22:10:06 +02:00
2023-09-21 21:43:58 +02:00
![snapshot ](./doc/snapshot_mapillary_sequence.jpg )
## How to install the script with a virtual environnement
```Shell
cd ~
git clone https://github.com/Stefal/mapillary_download.git
cd mapillary_download
python3 -m venv mly_venv
source mly_venv/bin/activate
2024-10-24 00:01:05 +02:00
source secrets_variables.sh
2023-09-21 21:43:58 +02:00
python -m pip install -r requirements.txt
```
2024-10-24 00:01:05 +02:00
Then you can run `python mapillary_download.py $MAPILLARY_DEV_TOKEN --sequence_ids xxxxxxxxxxx`
2023-09-21 21:43:58 +02:00
When you're done with the script, simply run `deactivate` to exit the virtual environnement.
2024-07-24 19:13:42 +02:00
On windows you can create a virtual environnement too, or use the prebuilt `mapillary_download.exe` available on the release page.
## How to batch the upload to panoramax
After having downloaded the sequences of a user you will find them in the folder `data` .
go in your `data` folder, and to the user subfolder, and assuming you have already sent pictures with geovisio_cli, you can run this command to send all the sequences of the current folder you're in:
```Shell
2024-10-24 00:01:05 +02:00
source mly_venv/bin/activate
source secrets_variables.sh
2024-07-24 19:13:42 +02:00
cd data/some_user
2024-10-24 00:01:05 +02:00
for dir in */; do dir=${dir%?} ; panoramax_cli upload --api-url https://panoramax.openstreetmap.fr "$dir" --token=$PANORAMAX_DEV_TOKEN ; done
2024-07-24 19:13:42 +02:00
```
Have fun!