These scripts automate the batch processing of georeferenced, time-series coral reef photomosaics using Agisoft Metashape. They follow a Structure-from-Motion (SfM) workflow to generate 3D models and mosaics from photographic images of coral reefs, streamlining the processing pipeline for efficient monitoring and analysis.
- Batch Processing: Automates the full SfM workflow for multiple sites or datasets.
- Photo Management: Reads and validates image files from user-specified directories.
- Automated Alignment: Matches and aligns photos, builds sparse and dense point clouds.
- Marker Detection & Scaling: Detects ground control markers and applies scale bars.
- Quality Control: Filters images and points based on quality metrics.
- Export: Generates and exports DEMs, orthomosaics, and processing reports.
- Logging: Logs all processing steps and results for reproducibility and troubleshooting.
- Compatibility: Two script versions for legacy and current Metashape Python APIs.
graph TD
A[Start - Set Paths and Initial Parameters] --> B[Generate Photo List]
B --> C[Find Marker]
C --> D[MetashapeProcess]
subgraph _
D --> E[Step 1: Initialize - Create Products folder, psx file and s]
E --> F[Step 2: Add, Match, and Align Photos]
F --> G[Step 3: Generate Sparse Point Cloud]
G --> H[Step 4: Scaling Process]
H --> I[Step 5: Reprojection]
I --> J[Step 6: Generate Dense Point Cloud]
J --> K[Step 7: Export Results Orthomosaic DEM]
end
K --> L[End]
style A fill:#f9f,stroke:#333,stroke-width:2px
style B fill:#bbf,stroke:#333,stroke-width:2px
style C fill:#fb0,stroke:#333,stroke-width:2px
style D fill:#9f9,stroke:#333,stroke-width:2px
style E fill:#ff9,stroke:#333,stroke-width:2px
style F fill:#f96,stroke:#333,stroke-width:2px
style G fill:#69f,stroke:#333,stroke-width:2px
style H fill:#c9f,stroke:#333,stroke-width:2px
style I fill:#f66,stroke:#333,stroke-width:2px
style J fill:#9ff,stroke:#333,stroke-width:2px
style K fill:#fc6,stroke:#333,stroke-width:2px
style L fill:#f96,stroke:#333,stroke-width:2px
This repository includes two main batch processing scripts for Agisoft Metashape:
- Description: Original version of the batch processing script.
- Compatibility: Designed for earlier versions of the Metashape Python API.
- Usage: Use if you are working with legacy projects or older Metashape installations.
- Description: Updated version with compatibility for recent Metashape Python API changes (see changelog in script header).
- Key Updates:
- Uses
chunk.analyzeImagesinstead ofchunk.analyzePhotos. - Uses
TiePointsinstead ofPointCloudfor sparse cloud operations. - Updated export and build function names to match API changes.
- Uses
- Usage: Recommended for new projects and current Metashape versions.
Inputs:
- A CSV processing log specifying batch/site information.
- Folders containing site images (JPEG/JPG).
- (Optional) Ground control marker information.
Outputs:
- Agisoft Metashape project files (.psx and .files).
- Log and readme text files for each batch.
- Exported DEMs, orthomosaics, and reports (in supported formats).
- Install Agisoft Metashape (Python API required; see official instructions).
- Prepare your data: Organize your images and create a processing log CSV.
- Edit the script: Update the
process_logandbatch_novariables in the script to match your data. - Run the script:
(or
python SfMBatchProcess_v2.py
SfMBatchProcess_v1.pyfor legacy workflows)
See the LICENSE.md for details.
This repository is a scientific product and is not official communication of the National Oceanic and Atmospheric Administration, or the United States Department of Commerce. All NOAA GitHub project code is provided on an ‘as is’ basis and the user assumes responsibility for its use. Any claims against the Department of Commerce or Department of Commerce bureaus stemming from the use of this GitHub project will be governed by all applicable Federal law. Any reference to specific commercial products, processes, or services by service mark, trademark, manufacturer, or otherwise, does not constitute or imply their endorsement, recommendation or favoring by the Department of Commerce. The Department of Commerce seal and logo, or the seal and logo of a DOC bureau, shall not be used in any manner to imply endorsement of any commercial product or activity by DOC or the United States Government.

