Forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Sylvain M.

Pages: [1]
1
General / Managing non-aligned photos
« on: July 07, 2025, 05:29:14 PM »
Hello everyone!

I use Metashape to create orthophotos from aerial drone missions over forests.
Most of the time, I fly a DJI Mavic 3M at an altitude of 120 metres (the maximum regulatory height in Europe), which produces orthophotos at around 4 cm/px. This resolution is more than sufficient for our forestry needs.

However, I sometimes have problems aligning the photos, especially when flying low (60 m) above a dense canopy. This seems normal as the shots look the same and it is difficult to distinguish one tree from another.

However, last week I experienced alignment issues during a flight at 120 m.

No matter how much I adjust the alignment settings, a few photos still don't align.
Could someone who has mastered this step give me some advice?
If automated alignment fails, can you manually enter matching points between the photos?

(Attached are a few screenshots to illustrate the problem and the nature of the photos to be processed.)

2
Hi everyone,

Based on the script available at this address [1], I've set up a processing chain to build Drone orthophotos using a Python script.
I'm equipped with a DJI Mavic 3M drone, and I sometimes fly multispectral missions, which generates not only RGB photos (in JPG format), but also TIF images for each spectral band (Red, RedEdge, NIR, Green).
If I import the photos manually into a Metashape project, I can define it as a multi-camera system.

However, I don't know how to code this in Python.

Does anyone have a code snippet that handles this functionality?

Or, if anyone is able to help me ‘from scratch’, here's how the Mavic 3M's photo folders are structured:
- all images are in the same input folder.
- the “rgb” images are the only ones in JPG format (filegroup = “rgb”)
- the “green” images are in TIF format and their name ends with “_MS_G.TIF” (filegroup = “green”)
- nir' images are in TIF format and their name ends with “_MS_NIR.TIF” (filegroup = “nir”)
- red' images are in TIF format and their name ends with “_MS_R.TIF” (filegroup = “red”)
- re' images are in TIF format and their name ends with “_MS_RE.TIF” (filegroup = “re”)

This is what it would look like as a Python function:
Code: [Select]
def load_images_from_folder(folder):
    images = []
    for filename in os.listdir(folder):
        if filename.endswith('.JPG'):
            images.append((os.path.join(folder, filename), 'rgb'))
        elif filename.endswith('_MS_G.TIF'):
            images.append((os.path.join(folder, filename), 'green'))
        elif filename.endswith('_MS_NIR.TIF'):
            images.append((os.path.join(folder, filename), 'nir'))
        elif filename.endswith('_MS_R.TIF'):
            images.append((os.path.join(folder, filename), 'red'))
        elif filename.endswith('_MS_RE.TIF'):
            images.append((os.path.join(folder, filename), 're'))
    return images

Thanks in advance to anyone who can help me!

Sylvain M.

[1] https://github.com/agisoft-llc/metashape-scripts/blob/master/src/samples/general_workflow.py

3
Further to this thread, I'm opening a new thread about reprojecting an Orthomosaic via Metashape's Python module.

I have an orthomosaic in WGS 84 (EPSG 4326), which I'd like to export in Lambert 93 (EPSG 2154).

I haven't found the right syntax for this kind of task.

Could you help me adapt this part of my code?

Code: [Select]
chunk.exportRaster(ortho_folder, source_data = Metashape.OrthomosaicData)
Thank you in advance for your help!  :)

4
Hi everyone,

I'm a beginner on Metashape, as well as on Python.
My goal is to automate in Python a processing chain to create an orthomosaic from a folder of multispectral photos (from a DJI Mavic 3M drone).
For the moment, I've created an Agisoft batch job (XML) that meets my needs.

By any chance, is there a tool that can convert a batch job into a Python script?

If not, I'd like to take advantage of this thread to work on this script step by step, with the help of anyone who can help me.
So I'll start by sharing the first bits of code I've written (I confess, with the help of ChatGPT), which could perhaps be optimised?

Code: [Select]
import Metashape
import os

# Params
project_path = r"D:\PROJECTPATH\MYPROJECT.psx"
photos_folder = r"D:\PHOTOSPATH"

# Create project and chunk
doc = Metashape.Document()
doc.save(path=project_path)
chunk = doc.addChunk()

# Photos import
# I don't think this method is optimal: it should be possible to specify that this is a multi-camera system
photo_list = [os.path.join(photos_folder, photo) for photo in os.listdir(photos_folder) if photo.lower().endswith(('.jpg', '.jpeg', '.png', '.tif', '.tiff'))]
chunk.addPhotos(photo_list)

doc.save()

Thank you very much for any help you can give me, or any examples you can send me links to.

Pages: [1]