Category: ODM

SELF CALIBRATION OF CAMERAS FROM DRONE FLIGHTS (PART 3)

 

BACKGROUND

(Reposted from https://smathermather.com/2019/12/02/self-calibration-of-cameras-from-drone-flights-part-3/)

I have been giving a lot of thought to sustainable ways to handle self calibration of cameras without undue additional time added to flights. For many projects, I have the luxury of spending a little more time to collect more data, but for larger projects, this isn’t a sustainable model. In a couple of previous posts (this one and this one), we started to address this question, pulling from the newly updated OpenDroneMap docs to highlight the recommendations there.

As I have been thinking about these recommendations, there are other more efficient ways to accomplish the same goal. Enter the calibration flight: the idea is that with some cadence, we have dedicated flights at the same height and flight speed as the larger flight in order to estimate lens distortion.

INITIAL TEST

For this testing, I chose a relatively flat but slightly undulating area in Ohio in the USA: the Oak Openings region, which is a lake bottom clay lens overlayed with sand dunes from glacial lakes. It has enough topography to be interesting, but is flat enough to be sensitive to poor elevation models.

Shaded elevation model in green and purple
Shaded elevation model of the Oak Openings region in Northwest Ohio, USA. Purple is lower elevations, green higher elevations, typically vestigial dunes. Elevation model from Ohio Statewide Imagery Program.

The test area flown is ~80 acres of residences, woodlots, and farmland.

80 acre aerial image
80 acre aerial image

Flown with a DJI Mavic Pro which has an uncalibrated lens with movable focus, the first question I wanted to address is how much distortion do we get in our resultant elevation models if we just allow for self calibration? It turns out, we get a lot:

Image showing bulls-eye pattern of lens distortion in digital terrain model with self calibrated approach
Bulls-eye pattern of lens distortion in digital terrain model with self calibrated approach

We have seen this in other datasets, but this forms a good baseline for our subsequent work to remove this.

Next step, we fly a calibration pattern. In this case, I plotted an area large enough to capture two passes of data, plus an orbit around the exterior of the area with the camera angled at 45° for a total of 3 minutes and 20 seconds.

Figure showing layout of calibration flight pattern
Layout of calibration flight pattern

When we process this data in OpenDroneMap, we can extract the cameras.json file (either in the processing directory or we can download from WebODM) and use that in another model. We can do this using the cameras parameter on the command line or in WebODM through uploading the json file from our calibration dataset.

Cameras option in WebODM for importing camera parameters
Cameras option in WebODM for importing camera parameters

But, before we do that, let’s do a review of our calibration data — process it and take a look at what kind of output we get. First, we process it using defaults and evaluate the elevation model to look for artifacts that might indicated whether the calibration pattern wasn’t successful.

Our terrain model from the Ohio Statewide Imagery Program elevation model looks like this for our calibration area:

Shaded elevation model from Ohio Statewide Imagery program for calibration area
Shaded elevation model from Ohio Statewide Imagery program for calibration area

Note that this is mostly a moderately flat farm field with a road and small ditches running North/South in the west of the image and a deep Northeast Ohio Classic ditch in the east.

How does our data from our calibration flight look?

Image showing elevation model from calibration flight
Elevation model from calibration flight

It’s not bad. We can see the basic structure of the landscape — from the road in the west to the gentle drop in elevation in the east.

Our default camera model is a perspective camera. How does this look with the Brown–Conrady camera model that Mapillary recently introduced into OpenSfM?

Image showing elevation model from calibration flight with Brown camera model
Elevation model from calibration flight with Brown–Conrady camera model

With the Brown–Conrady camera model, we see additional definition of the road bed, ditches alongside the road, and even furroughs that have been ploughed into the field. For this small area, it appears the Brown–Conrady camera model is really improving our overall rendering of the digital terrain model, likely as a result of an improved structure from motion product. We even see the small rise in the field at the southern central part of the study area, and as with the default (perspective) model, the slope down toward the ditch on the east of the study area.

RESULTS

With running these both with perspective and Brown–Conrady cameras, we can apply those camera models as fixed parameters for our larger area and see what kind of results we get.

Figure of larger elevation model as processed with perspective camera parameters as compared with reference model
Larger elevation model as processed with perspective camera parameters as compared with reference model

Our absolute values aren’t correct (which we expect), but the relative shape is — the dataset is now appropriately relatively flat with clear delineation of some of the sand features. This is the goal, and we have achieved it with some of the most challenging data.

How does our Brown–Conrady calibration model turn out? It did so well on the small scale, will we see similar results over the larger area?

Figure of larger elevation model as processed with brown camera parameters showing bulls-eye pattern
Larger elevation model as processed with Brown–Conrady camera parameters

In this case, no: the Brown–Conrady model over compensates for our distortion parameters. More tests need to be done in order to understand why. For now, I recommend using the perspective model for corrections on large datasets, and Brown–Conrady camera model on smaller datasets where the details matter, but the distortion isn’t discernible.

Self Calibration of Cameras from Drone Flights

 

(Modified excerpt from the OpenDroneMap docs)

Calibrating the Camera

Camera calibration is a special challenge with commodity cameras. Temperature changes, vibrations, focus, and other factors can affect the derived parameters with substantial effects on resulting data. Automatic or self calibration is possible and desirable with drone flights, but depending on the flight pattern, automatic calibration may not remove all distortion from the resulting products. James and Robson (2014) in their paper Mitigating systematic error in topographic models derived from UAV and ground‐based image networks address how to minimize the distortion from self-calibration.

image of lens distortion effect on bowling of data

Bowling effect on point cloud over 13,000+ image dataset collected by World Bank Tanzania over the flood prone Msimbasi Basin, Dar es Salaam, Tanzania.

To mitigate this effect, there are a few options but the simplest to flight plan are as follows: fly two patterns separated by 20°, and rather than having a nadir (straight down pointing) camera, use one that tilts forward by 5°.

animation showing optimum

As this approach to flying can be take longer than typical flights, a pilot or team can fly a small area using the above approach. OpenDroneMap will generate a calibration file called cameras.json that then can be imported to be used to calibrate another flight that is more efficiently but, from a self calibration perspective, less accurately.

Vertically separated flight lines with the above interleaved 20° flight pattern also improve accuracy, but less so than a camera that is forward facing by 5°.

figure showing effect of vertically separated flight lines and forward facing cameras on improving self calibration

From James and Robson (2014), CC BY 4.0

Kole Wetland Canal Mapping with ClusterODM

 

Our friends and collegues at International Center for Free and Open Source Software in Kerala, India have done a pretty interesting and massive mapping initiative over Thrissur Kole Wetlands. The wetlands are a massive 30,000+ acre area that are both important to wildlife and provide rice production.

Suman Rajan, Asish Abraham, and Deepthi Patric (left to right in image below) mapped 9000 acres of it.

thumbnail_image3.jpg

Given the massive scale of the project, they ran it across multiple nodes using a cluster of computers coordinated by ClusterODM.

image1.jpeg
thumbnail_image2.jpg

What a beautiful cluster, and an important and interesting project.

Toward ODM 1.0 and Beyond

 

During this past summer, the OpenDroneMap team has been active on a number of fronts.

Split-Merge Improvements

While this feature has been announced months ago, we’ve been working on a number of improvements to make it more stable and fast. The distributed split-merge workflow in particular is non-trivial and has required a number of fixes to improve its reliability over time. The LocalRemoteExecutor (LRE) module is perhaps one of the most interesting modules in the codebase, allowing submodels to be processed with a mix of local and remote processing, working in sync with ClusterODM (which is now more fault tolerant).

Ground Control Points

GCPs kept confusing our users with respect to supported coordinate reference systems (CRS). The system only handled well UTM CRSes, but the software happily accepted others, some which worked, some which didn’t.

If you are a frequent user on our forum you might have noticed a significant decrease (disappearance?) of questions related to GCPs. That’s because without fanfare, we’ve improved significantly GCP support in July (see PR #997). You can now use whatever CRS you please and ODM will handle the rest.

Major Speed Improvements

Our friends at Mapillary have also been working throughout the summer and brought some really neat new features to OpenSfM. Among some of these, there’s Bag of Words (BoW) matching, which significantly boosts reconstructions lacking georeferencing information. Datasets captured with a handheld camera are now much faster to process. You will also notice speed-ups for processing normal drone datasets (unrelated to BoW matching).

Camera Calibration Transfer and Models

Up until recently, you might have had some difficulty processing datasets captured with fisheye cameras such as the ones found in GoPros or Parrot Bebop drones.

ODM now comes with support for 4 different camera models:

  • Perspective (default)
  • Brown (like perspective, but capable of handling more complex distortion models)
  • Fisheye
  • Equirectangular (spherical)

To use a particular camera model simply pass –camera-lens <type> (lower case).

image
Bebop dataset before latest changes. Problem?
image
Processed by passing –camera-lens fisheye. Better!

It’s also possible to transfer a camera calibration model computed from one dataset to process another. This is useful to process a dataset that was captured in less-than-ideal conditions (for which good camera calibration parameters cannot be computed), but for which a good dataset captured with the same camera exists.

A cameras.json file is now created and placed in the root folder of each project and that file can be reused to process another dataset via –cameras /path/to/cameras.json.

Automated Docker Builds

Since ODM takes a while to compile, we haven’t been able to leverage Docker Hub’s ability for automatic builds (due to system timeouts). So up until a few days ago we have been building and publishing docker images manually. But no more! Starting from last week, a dedicated build server checks for changes on the ODM and WebODM repositories and automatically builds, tags and pushes the latest changes in master to Docker Hub.

ODM Book

Last but not least, the first edition of OpenDroneMap: The Missing Guide has been published. Spanish and Portuguese translations are also on the way. This has been a very time consuming task, but one which we hope will help more people get the most out of OpenDroneMap.

Future Plans

The community has already provided tremendous feedback. We know what needs to be done and we will continue to listen to our users. Among some of the most requested features:

  • Better GCP interface / workflows
  • Quality/Accuracy reports
  • Override mechanism for EXIF coordinates (PPK)
  • Multiband (TIFF) image support
  • NDVI, VARI index support (and others)
  • WebODM interface/workflow improvements

If your organization uses OpenDroneMap and is in a position to help (financially or by dedicating a developer to a task), get in touch on the forum.

Stitching Historical Aerial Images From 1940 Using OpenDroneMap

 

During the recent OSGeo Code Sprint hosted at the University of Minnesota, we had the opportunity to learn more about the university’s effort to preserve some historical archives of aerial imagery.

We put our eyes on an old 1940 dataset of Hennepin County, Minnesota. The images are overlapping by about 20-30%. There’s also paper tears in many of the scans. We had never tried this before. Would it be good enough for ODM to process? We had to find out.

We quickly put together a script to download some of the images from the University’s online archive, add EXIF tags to the images and send them to ODM using the –fast-orthophoto option, which works well for high altitude flights and datasets with little overlap. We didn’t know what to expect. But a few hours later, when we saw the results, we knew it had worked!

Code available at: https://github.com/pierotofy/historical_aerial_downloader

GeoTIFF: https://drive.google.com/open?id=18UhkAR5jggOtgNvBzadEz-P-bymu14_m

Images credits to the University of Minnesota.

Parallel Shells: distributing split-merge with ClusterODM

 

Code/community sprints are a fascinating energy. Below, we can see a bunch of folks laboring away at laptops scattered through the room at the OSGeo’s 2019 Community Sprint, an exercise in a fascinating dance of introversion and extroversion, of code development and community collaboration.

A portion of the OpenDroneMap team is here for a bit working away at some interesting opportunities. Tonight, I want to highlight an extension to work mentioned earlier on split-merge: distributed split-merge. Distributed split-merge leverages a lot of existing work, as well as some novel and substantial engineering solving the problem of distributing the processing of larger datasets among multiple machines.

Image of the very exciting code sprint.

Image of the code sprint.

 

This is, after all, the current promise of Free and Open Source Software: scalability. But, while the licenses for FOSS allow for this, a fair amount of engineering goes into making this potential a reality. (HT Piero Toffanin / Masserano Labs) This also requires a new / modified project: ClusterODM, a rename and extension of MasseranoLabs NodeODM-proxy. It requires several new bits of tech to properly distribute, collect, redistribute, then recollect and reassemble all the products.

Piero Toffanin with parallel shells to set up multiple NodeODM instances

Piero Toffanin with parallel shells to set up multiple NodeODM instances

 

————————————————————————————————–

“Good evening, Mr. Briggs.”

The mission: To process 12,000 images over Dar es Salaam, Tanzania in 48 hours. Not 17 days. 2 days. To do this, we need 11 large machines (a primary node with 32 cores and 64GB RAM and 10 secondary nodes with 16 cores and 32GB RAM), and a way to distribute the tasks, align the tasks, and put everything back together. Something like this:

… just with a few more nodes.

Piero Toffanin and India Johnson working on testing ClusterODM

Piero Toffanin and India Johnson working on testing ClusterODM

 

This is the second dataset to be tested on distributed split-merge, and the largest to be processed in OpenDroneMap to a fully merged state. Honestly, we don’t know what will happen: will the pieces process successfully and successfully stitch back together into a seamless dataset? Time will tell.

For the record, the parallel shells were merely for NodeODM machine setup.

Actually distributing the jobs? Easy:

./run.sh --split 400 --project-path /path/to/projects/ --sm-cluster http://ClusterODMHostname:3000 projectname

And yes, this will work in WebODM too… .

Split-merge nearing completion

 

For anyone using OpenDroneMap to process really large datasets, some good news came through early last year with improvements to how OpenSfM handles large datasets. This came in the form of an innovative, first of it’s kind, hybrid SfM method which combines the better attributes of global and incremental SfM approaches.

TLDR: This helps make processing large datasets orders of magnitude faster, and can be tuned to be even faster (at some accuracy expense), which is really exciting and wonderful work by the folks (especially Pau) over at Mapillary.

But this change was not enough for OpenDroneMap. After the SfM step, we have several more processing steps, all challenges with respect to data processing techniques, memory usage, and other issues which crop up when you adapt a bunch of libraries meant for one thing to another set of much larger things.

Enter: split-merge. Since early last year, we have also had some scripts to help split up large datasets into smaller pieces, keeping those smaller pieces aligned with each other, and helping with some of the merging of those data back into a cohesive whole at the end. This was a great work-around for processing those larger datasets, but for a variety of reasons (funding and time being the big two), never got completed.

Now a big phase of that work is wrapping up. You can find that work in Pull Request #979. Do you have a really large dataset that needs processing on the ODM command line? Try the following:

./run.sh --project-path /path/to/datasets --split <target number of pictures per submodel> mydataset

Coming soon to a WebODM near you… .

 

(HT Pau Gargallo Piracés at Mapillary, Dakota Benjamin at Humanitarian OpenStreetMap Team, and Piero Toffanin at Masserano Labs)

Someone has to deal with it and who you gonna call?

 

Most of our blog posts on OpenDroneMap are meant for interested users. Every now and then we have a gem for our contributors / power users who like to dive into the code a bit and enhance things.

For any of you who have done this, or have wanted to do this in the past few years, you’ve had to deal with the Ecto framework, a dynamically configurable Directed Acyclic processing Graph (DAG) framework which is way overkill for the way OpenDroneMap is really used, and makes contributing to OpenDroneMap much harder.

Until now! Or. Until soon. Well, after pull request 979 gets into master (with a likely requisite update to version 0.6 for OpenDroneMap), ecto goes away. As usual, we can thank the prodigious Piero Toffanin for this work.

If you’ve been stymied by contributing to ODM in the recent few years, come back. ODM: Now with less ectoplasm!

 

Announcing CloudODM and PyODM

 

2019 is off to a great start for OpenDroneMap. We are announcing the releases of two open source projects, CloudODM and PyODM. Let’s explore each.

CloudODM

Photogrammetry is a memory intensive process. Not all computers are equipped with large amounts of RAM or powerful CPUs. And of course, we’d like ODM’s capabilities to be available on as many platforms and machines as possible. CloudODM is a command line tool to process aerial imagery in the cloud via NodeODM‘s API. Small, native clients are available for all major platforms including Windows, Mac and Linux. Perhaps you have installed NodeODM on one of your powerful machines at home, but you have a less powerful laptop that you use for your daily work. Now you can invoke odm commands from the less powerful computer and let CloudODM handle the rest. Scripting and automation anyone?

PyODM

Speaking of scripting, we couldn’t just release a command line client without having a proper library for doing the same. PyODM is a Python library that speaks the NodeODM API and allows developers to implement image processing capabilities in 5 lines of code!


from pyodm import Node
n = Node('localhost', 3000)
task = n.create_task(['examples/images/image_1.jpg', 'examples/images/image_2.jpg'], {'dsm': True})
task.wait_for_completion()
task.download_assets("results")

Conclusion

We want to take a moment to thank our community of users. Your feedback has been and continues to be invaluable for the growth of the project. It’s knowing that there are thousands of you out there using the software daily that motives us to continue working. So thank you!

If you haven’t yet, keep the feedback coming and let us know what you would like to see next.

Better 3D all the time

 

Recent posts have detailed the improvements in the digital elevation products from OpenDroneMap that are forthcoming, and we are really excited about those.

That code is now relatively mature and likely usable for your use case, with only a couple of caveats:

  • The first caveat is that the processing for point clouds takes 3-4 times as long. That said, the quality is so much better, I feel comfortable with calling that a feature, not a bug.
  • The other caveat is that the code doesn’t yet respect the “–max-concurrency” parameter. It will use every processor you have, whether you want it or not. We will be fixing that before we merge it in with the master branch.

Those caveats aside, the quality of what we get in an elevation model is almost incomparable, and the memory footprint for the dense point cloud step that we improved is 60% what it was, so processing larger datasets should become easier. Finally, while better and more detailed, the total number of points in the point clouds is decreased (about 1/3 to 1/4 the size), which may help the speed of subsequent steps, although I will confess this is an untested theory. Interestingly, even though there are fewer points, they are better distributed, so it looks like more points.