GIS/MEA 584:
Mapping and Analysis Using UAS

Processing of UAS imagery in OpenDroneMap

Outline:
  • Setup VCL with Web OpenDroneMap (WebODM)
  • Explore results from WebODM
  • Run ODM from command line (optional)
Data:

Tools:

Preparing Docker and data

We will use VCL with Ubuntu OS, select Agisoft Photoscan & GRASS GIS - Ubuntu (Ubuntu 16.04 LTS). Alternatively, use OSGeo Live, or Ubuntu 16.04 LTS but they provide less computing resources. You can request it for 1 day or more if you plan to go back to the assignment later. You will need a remote desktop software to run the VCL, it won't run in your browser.
  1. Once you start Ubuntu, it will ask about keyring, click Cancel, then it asks about panel, say Use default. Go to Applications - Terminal Emulator, from this terminal window we will first install Docker from packages:
    sudo apt-get install -y docker.io git python-setuptools python-pip
    
    We also need docker-compose:
    sudo curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose
    
    To properly setup Docker in terms of user permissions, run:
    sudo groupadd docker
    sudo usermod -aG docker $USER
    
    To make sure the permission changes take place, you need to log out (Applications - Log out) and then log in back. Then start the terminal again.
  2. Get your data ready: On your computer (not VCL), download the photos and log for the class. Unzip them.
  3. Finally, we will used prepared GCP file, which is in your folder with images. WebODM has an graphical interface for creating this file as well. The format of the GCP file is:
    WGS84 UTM 17N
    708477.2014791 3956143.22167367 111.888 1341 722 dsc01547.jpg
    ...
    
    where the numbers represent GCP X, GCP Y, GCP altitude, image column, image row, image name.

Running WebODM

On VCL, in terminal, download WebODM code using Git:
cd ~
git clone https://github.com/OpenDroneMap/WebODM --config core.autocrlf=input
Go to the code directory:
cd WebODM
Start WebODM (be patient):
./webodm.sh start &

Further steps:

  1. On your host computer (not VCL) go to the IP address of the VCL (you get that number when you click Connect when you access your VCL reservation) and add ":8000", so it will be something like 152.7.86.219:8000
  2. You will be prompted to create an administrator account. Create it. It will be the only account we will need for the exercise.
  3. Alternatively, in the browser window on your VCL, go to http://localhost:8000.
  4. Upload images to the task which is already there or create a new one. Include gcp_list.txt file.
  5. In Resize images, change the size of images to 1000 to speed up the upload and computation (this reduces the quality of the images and the whole reconstruction).
  6. Once your WebODM is finished, you can explore data within WebODM (in VCL or outside), specifically the orthopohoto, point cloud, mesh and DSM. You can also download them, for next steps download the DSM (tiff), orthophoto, and mesh.

Using the results from WebODM

If the processing is still running and you can't wait, download precomputed results — odm.zip and unzip in your home folder.

View point cloud

Look first at the point cloud (odm_georeferenced_model.laz) in plas.io.

View mesh

To view and edit the mesh stored as OBJ we can use MeshLab. MeshLab can also import the point cloud stored as PLY file. In VCL terminal run to install:
sudo apt-get install -y meshlab
You can then find it in Applications - Graphics. Import mesh odm_textured_model.obj.

View DSM

Start GRASS GIS (Applications - Education), create GRASS GIS database directory grassdata in your home folder. Create new Location (New button on the left) based on the DSM. Type projection name and then select 'Read projection and datum terms from a georeferenced data file' and browse to dsm.tif.

Start GRASS GIS in PERMANENT and set your working directory (Settings - GRASS working environment) where you have your odm folder. Import generated orthophoto:

r.import input=odm_orthophoto.tif output=odm_ortho
g.region raster=odm_ortho.1
r.mask raster=odm_ortho.4 maskcats=255
r.composite red=odm_ortho.1 green=odm_ortho.2 blue=odm_ortho.3 output=ortho
r.mask -r
Now import DSM file:
r.import input=dsm.tif output=odm_dsm
Compare the DSM with lidar. Import the lidar DSM, browse to the file using GUI or you have to have it in your current working directory.
r.import input=mid_pines_lidar2013_dsm.tif
r.mapcalc "diff = odm_dsm - mid_pines_lidar2013_dsm"
r.colors map=diff color=differences


Example resulting shaded DSM created in GRASS GIS based on a point cloud obtained by the above process.


Example resulting shaded DSM created in GRASS GIS based on a point cloud obtained by the above process.

Running OpenDroneMap in command line (optional)

We will run OpenDroneMap in a command line using Docker to simplify setup (the internally used operating system is Ubuntu). To setup ODM:
  1. We will download a pre-built image of OpenDroneMap:
    docker pull opendronemap/opendronemap
    
  2. Either in file manager or in command line create a directory called odm. Put it somewhere with enough disk space (home folder). Inside the odm directory create directories images, orthophoto, georeferencing, and texturing. On unix-like systems, creating the directories would look something like this:
    cd
    mkdir odm
    cd odm
    mkdir images
    mkdir orthophoto
    mkdir georeferencing
    mkdir texturing
    
  3. Get your data ready: Open browser (Applications - Internet - Firefox). Download the photos and log for the class. Unzip them. Move the images and all the other files to the images directory (no subdirectories). On unix-like systems, moving of the files would look something like this:
    mv unzipped-dir/* images/
    
    You should see a lot of .jpg and couple other files listed when you run:
    ls ~/odm/images
    
We will use default parameters. To review parameters run:
docker run -it --rm opendronemap/opendronemap --help
Check if your previous computation in WebODM is still running. If yes, please wait until it's done, because you wouldn't have sufficient resources for both reconstructions. Once it's finished, you can start processing, it should take roughly 30 mins.

We will keep default values, but we need to specify the path to file with GCPs. Some explanation of the docker run command:

  • -v links our directory images to a directory inside Docker container
  • The string $(pwd) in the commands stands for the current working directory which should be the odm directory we created earlier.
cd ~/odm
docker run -it --rm -v $(pwd)/images:/code/images -v $(pwd)/orthophoto:/code/odm_orthophoto -v $(pwd)/georeferencing:/code/odm_georeferencing -v $(pwd)/texturing:/code/odm_texturing $(pwd)/dem:/code/odm_dem opendronemap/opendronemap --mesh-size 100000 --resize-to 1000 --dsm --gcp /code/images/gcp_list.txt --force-ccd 23.4
OpenDroneMap will do the processing in parallel. However, each process requires certain amount of memory (RAM) based on the size of input images. If you want to limit the memory usage, you need to limit the number of processes using the --opensfm-processes command line option.

Open System Monitor (Applications - System - System Monitor), go to tab Resources. You can observe here how ODM uses parallel processing for different parts of the computation.

Once computed, all results are stored in the odm directory, specifically in orthophoto, georeferencing, texturing, and dem subdirectories.