Author Topic: Metashape External Orientation instead of Aerial Triangulation for selected imag  (Read 194 times)

  • Newbie
  • *
  • Posts: 8
    • View Profile
I'm curious if there is a way to force the position of selected images that do not align? An example of this would be images over water in a large project.  In this particular use case, I have a camera system with very good positions but average orientation however, because its over water, I'm less concerned, I just want to create an ortho without a hole without having to go to photoshop.  In the past, for a precise full INS LiDAR/Camera system, I've used the attached script and it has worked well. Can it be modified to only iterate through selected images or images that are not currently aligned? I'm not sure what variables I can use to separate for the iteration.

Code: [Select]
import Metashape

chunk =
crs =
T = chunk.transform.matrix

origin = None
for camera in chunk.cameras:
if not camera.type == Metashape.Camera.Type.Regular:
if not camera.reference.location:
if not camera.reference.rotation:

pos = crs.unproject(camera.reference.location)
m = crs.localframe(pos)
rot = Metashape.utils.ypr2mat(camera.reference.rotation) * Metashape.Matrix().Diag([1, -1, -1])
R = Metashape.Matrix().Translation(pos) * Metashape.Matrix().Rotation(m.rotation().t() * rot)

if not origin:
origin = pos
chunk.transform.matrix = Metashape.Matrix().Translation(origin)
T = chunk.transform.matrix

camera.transform = T.inv() * R

Thank you in advance for your help.


  • Hero Member
  • *****
  • Posts: 667
    • View Profile

you can just use from github. This script will only set camera transform to  camera reference location and rotation for cameras that are not aligned....

and if you want to affect only images that are not aligned and selected then change line 124 of script  to:
Code: [Select]
        if c.transform is not None or not c.selected:
« Last Edit: May 18, 2021, 04:59:29 AM by Paulo »
Best Regards,

Paul Pelletier