This project provides a script for automating the processing of orthoimagery using Agisoft Metashape. It handles the alignment of photos, depth map generation, point cloud creation, model building, and orthomosaic export. The script also supports GPU processing for performance optimization.
- Photo Alignment: Aligns photos for each chunk in a Metashape project.
- Depth Map Generation: Builds depth maps from aligned photos.
- Point Cloud Generation: Creates a point cloud from depth maps.
- Model Building: Builds a 3D model from the point cloud.
- Model Smoothing: Smooths the 3D model.
- Orthomosaic Creation: Generates an orthomosaic from the 3D model.
- GPU Support: Optionally use one or both GPUs for processing.
- Logging: Logs detailed processing information to files.
- Python 3.9+
- Conda (for environment management)
- Agisoft Metashape (Python module)
- shutil, os, sys, datetime, logging (standard Python libraries)
git clone <repository-url>
cd agisoft_ortho
conda env create -f environment.yaml
conda activate metashape-pipeline
Ensure Metashape is installed in your environment. If not, follow the Metashape installation guide. installable environment file following soon...
If working on PYLOS, the use of tmux or similar is recommended to keep the process going even if you logout or use the terminal in any other way.
The folder structure of your data/flights should be like this:
<input_folder>/
├── <some_unprocessed_folder>_unprocessed/
│ ├── photos/
│ │ ├── <chunk1>/
│ │ └── <chunk2>/
...and so on
It is important to note that every chunk displays one orthomosaic. It can also handle multispectral data (images according to naming convention from DJI, e.g. "...MS_NIR.TIF") And if you have your photos in several folders, but all belong to a single flight, you should first put them inside one chunk. Otherwise you'll receive several orthomosaics from the respective chunks (and not one big).
python3 main.py <config-file.yaml>
The script will display a summary of actions and ask for confirmation before proceeding.
agisoft_ortho/
│
├── tests/
│ ├── test_config.yaml
│ ├── test_main.py
│ ├── test_utils.py
├── pipeline/
│ ├── __init__.py
│ ├── metashape_processor.py # The core functions and classes
│ ├── utils.py # Helper functions are stored inside here
├── setup.py
├── config_tests.yaml # config file (still in test phase but works)
├── README.md
├── main.py # the main pipeline call
└── environment.yml # conda environment (to be tested)
Log files are being created with each execution of the pipeline. The logfiles are stored within <input_folder>/log-files
log-files/
│
├── 2024-09-10_15-30-00.log
├── 2024-09-10_15-45-00.log
└── ...
If you run out of memory, try setting ulimit -s unlimited in your shell session before you run main.py.
To contribute or modify the code:
- Fork the Repository
- Create a Branch
- Make Changes and Test
- Submit a Pull Request
This project is licensed under the MIT License.
Agisoft Metashape for photogrammetry tools. Python and Conda for managing dependencies and environments.