An Introduction to the EcosynthAerial Python Library

Ecosynth has been developing a python library called "EcosynthAerial" that contains some utilities we think could be helpful to people running SfM point cloud workflows with Photoscan or Ecosynther. In this post, I'll show you how to get the library, give a quick overview of its structure, and introduce a couple functions that we've found to be particularly helpful in our own work.

Getting the Library

The Ecosynth library can be installed through your terminal with python's PIP package installer via the command `pip install ecosynth`. If you don't have pip, you can install it via the command `easy_install pip`. If you don't have easy_install, you should be able to find directions quickly through a Google search.

For Windows users, it may be a good idea to download the Anaconda Scientific Computing package from Continuum Analytics since they've done a good job to make sure the core computing packages that EcosynthAerial uses are compiled correctly for Windows.

Once you have the library, you can either open up the HTML GUI or start writing scripts.

If you open the HTML GUI via the command `python -m ecosynth`, you will be presented with a webpage that provides background information about each stage of the Ecosynth Aerial pipeline, links to other information and a link to a form in the Post-Processing section for entering data to run Ecosynth's standard post-processing stage.

To start scripting with the library, just be sure to include `import ecosynth` at the top of the file you are writing your python script in as it will allow you to access the library's individual modules and functions.

Overview of the Library's Structure

The python library currently contains three primary modules:
1. acquire
2. generate
3. postprocess

The acquire module is meant to contain functions for the data acquisition stage where the UAS is present. The module currently contains a group of utility functions for filtering telemetry data from ArduPilot log files.

The generate module is meant to contain functions for the point cloud generation stage where a computer is fed a set of images and generates a three-dimensional structure from those images. The module currently contains a group of utility functions for estimating the physical position of each image in the image set using the flight telemetry.

The postprocess module is meant to contain functions for the post-processing and analysis stage where a point cloud is examined for quality, filtered and georeferenced, and finally used to generate georeferenced raster outputs - such as max_elevation and point_density - that help characterize the structure of the point cloud and can be imported to GIS programs.

Examples of a Couple Functions

The telemetry_to_gps_positions() function

This is a function that might be useful to anyone operating a UAV running the open-source ArduPilot software. It will take the ArduPilot log file, a float value of the UAV's launch location and return an Nx3 array of the latitude, longitude, and altitude of the UAV over the course of its flight. To save the array to a file, simply feed the file object as an keyword argument.

Example Script:

>>> import ecosynth
>>> log_file = open(“path/to/log”, ‘r’)
>>> msl = 50.6
>>> gps_file = open(“path/to/output/directory/GPS_positions.txt”, ‘w’)
>>> ecosynth.acquire.utilities.telemetry_to_gps_txt(log_file, msl, gps_file=gps_file)

Example Input Contents (log_file):

CTUN, 643, 0, 9787, 9800, 0, 0, 5, 422, 0
ATT, 0, 23, 0, 2, 0, 183, 0
NTUN, 29907, 0, 3, 26866, 0, 0, 230, -10
GPS, 232733000, 12, 38.8882963, -76.5585533, 98.0000, 99.8500, 244, 9388
CMD, 100, 85, 16, 1, 0, 14200, 388882720, -765593408

Example Output Contents (gps_file):

364754.663 4305831.507 137.744
364754.771 4305831.238 137.753
364754.827 4305830.938 137.707

The interpolate_gps_positions_for_cams function

This is a function particularly useful to people running SfM data processing pipelines with Photoscan or Ecosynther. The function builds on top of the previous function, by matching an image with an interpolated position along the flight path. Giving Photoscan or Ecosynther a rough estimate of the image's location allows each program to dramatically improve the speed at which they find feature matches between images.

Example Script:

>>> log_file = open(log_filepath, ‘r’)
>>> msl_float = 5.6
>>> cam_filepath = ‘/path/to/cams’
>>> cam_xyz_file = open(cam_xyz_filepath, ‘w’)
>>> generate.utilities.interpolate_gps_positions_for_cams(
log_file, msl_float, cam_filepath, pscan_cam_xyz_file=cam_xyz_file)
>>> cam_xyz_file.close()

Example pscan_cam_xyz_file Output:

# <label> <x> <y> <z>
a.JPG 364754.663290 4305831.506730 136.543925


A great way to learn more about the library is by looking through the library's documentation currently hosted here.

And we'd love to get any feedback about the library and how to make it better!

Views: 323


You need to be a member of Ecosynth to add comments!

Join Ecosynth


© 2017   Created by Erle Ellis. Content is made available under CC BY 4.0.   Powered by

Badges  |  Report an Issue  |  Terms of Service