1
Python and Java API / Metashape External Orientation instead of Aerial Triangulation for selected imag
« on: May 18, 2021, 01:52:33 AM »
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.
Thank you in advance for your help.
Code: [Select]
import Metashape
chunk = Metashape.app.document.chunk
crs = chunk.crs
T = chunk.transform.matrix
origin = None
for camera in chunk.cameras:
if not camera.type == Metashape.Camera.Type.Regular:
continue
if not camera.reference.location:
continue
if not camera.reference.rotation:
continue
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
chunk.updateTransform()
Thank you in advance for your help.