EliaFantini / APS-Aerial-Photography-Simulation-for-photogrammetric-flight-design

Python software with GUI, capable of simulating an aerial photo given a pair DEM-Orthophoto (in GeoTIFF format)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🛩️Aerial_Photography_Simulation GitHub commit activity GitHub last commit GitHub code size GitHub repo size GitHub follow GitHub fork GitHub watchers GitHub star

The goal of the project is to create a python program with a graphic interface, capable of simulating an aerial photograph by applying the collinearity equations to the data contained within a DEM and an orthophoto, both provided by the user as files in GeoTIFF format.

The left image shows a drawing that explains the different coordinate systems and the parameters to be considered, while the right image shows a possible result of the software.

Immagine 2022-08-03 172951 Immagine 2022-08-03 173233

Author

Demo

ezgif com-gif-maker (5)

Requirements

The Python programming language was chosen to create the required software. The reason of this choice is due to the fact that for it there are several libraries extremely optimized for work on n-dimensional arrays of data. These libraries are:

  • RasterIO
  • Numpy
  • OpenCV
  • Scipy

In particular, RasterIO is the library for reading and manipulating the rasters contained in GeoTIFF files. It was chosen over the standard Python GDAL because, unlike it, it does not suffer from problems with pointers that can crash the program. For the graphic interface the PyQt5 library was used. The code was executed by a Python interpreter 3.7 in an Anaconda3 environment, since the installation of some libraries such as RasterIO would have been particularly complicated otherwise.

How to install

Step 1 Install Anaconda3:


Step 2 Create a new environment:
  • open up anaconda prompt as an administrator;
  • write on the terminal
conda create -n myenv python=3.7 anaconda 

Step 3 Install libraries:
  • write on the same terminal
conda install -n myenv rasterio  
  • write on terminal
conda install -n myenv scipy 
  • write on terminal
activate myenv 
  • write on terminal
pip install opencv-python
  • write on terminal
pip install pyqt5
  • write on terminal
conda list
  • check if all packages installed correctly;

Step 4 Run MainWindowGUI.py:
  • from the same terminal window, with myenv activated, navigate to source file folder with “cd” command.
  • Once in the folder containing MainWindowGUI.py and all other source files, write on the terminal
python MainWindowGUI.py

If everything went fine, APS’s should now open.

How to use

The dataset in the Data folder contains a compressed version of the original orthophoto file, which originally was 200MB. There was no GeoTIFF compressor available online so it is put there just to be visualized but it won't work in the software as it lacks the geographical informations which make a TIFF image a GeoTIFF image. If anyone would like to try the software on my dataset, download it from this Google Drive link and replace the data in Data folder.

The graphic interface allows the user to set the following parameters:

  • File path of the orthophoto in .tif format. the user may choose to manually write the path to the file or select it by clicking the browse button. If the path does not exist or the file valid file, the path is automatically reset;
  • File path of the DEM in .tif format. Similar functionality to the file path above;
  • File path of the .txt text file containing the names of the images to be simulated, the coordinates of the centre of take of each of them (X, Y, Z) and their three attitude angles (ω, φ, ϰ), and optionally, the rotation matrix (direct cosines). These parameters shall be provided spaced by a single tabular key character (HT) and in the following order: PhotoID, X, Y, Z, Omega, Phi, Kappa, (r11, r12, r13, r21, r22, r23, r31, r32, r33). Each set of parameters shall be separated from the previous one by an Enter character ("\n"). This format reflects that generated automatically by various photogrammetry software;
  • Path of the folder in which the processed images are to be saved;
  • Photographic sensor size (mm x mm), selectable from several presets;
  • Resolution of the simulated photograph, selectable from several presets;
  • Customised sensor size and image resolution, selectable manually by clicking the button marked "...";
  • Focal length of the camera in mm (distance of the grip centre from the sensor);
  • Main point co-ordinates (ξ,η) in mm (co-ordinates of the projection of the grip centre on the sensor);
  • Resampling algorithm applied in the process of rototranslation of the DEM file to make correspond, in the georeferenced 3-dimensional space, the elevation information of the pixel (i,j) in the DEM to the RGB colour information of pixel (i,j) in the orthophoto;
  • Resampling algorithm applied to the simulated image to fill pixels without information.

The following image shows the settings interface:

Immagine1

The two following images represent the dataset I was given (left: orthophoto - right: DEM):

Immagine1 Immagine1

Once pressed start, a loading bar will tell how much time is left. The following image shows the result of a random 80x80mm camera sensor's simulated photo:

Immagine4

For a more detailed description of how the code works and some example with more extreme paramaters settings, such as with strongly a angled camera which will have stronger prospective distortions, read the abstract file ( the pdf is written in italian, I suggest the use of an automated translation tool).

🛠 Skills

Python. Collinearity equations, basics of photogrammetry. Usage of Python GUI libraries.

🔗 Links

portfolio linkedin

About

Python software with GUI, capable of simulating an aerial photo given a pair DEM-Orthophoto (in GeoTIFF format)


Languages

Language:Python 100.0%