Hello Natsumi,
given 3 markers (m1 = <Marker '1'>, m2 = <Marker '2'>, m3 = <Marker '3'>) that you want to use as horizontal axis (1-2) and vertical axis(1-3) in BuildOrthomosaic from Model surface then following code would do the trick:
def cross(a, b):
result = Metashape.Vector([a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y *b.x])
return result.normalized()
chunk = Metashape.app.document.chunk
T = chunk.transform.matrix
horizontal = T.mulp(m2.position) - T.mulp(m1.position) # markers m1, m2 define horizontal axis
vertical = T.mulp(m3.position) - T.mulp(m1.position) # markers m1, m3 define vertical axis
normal = cross(horizontal, vertical)
vertical = -cross(horizontal, normal)
horizontal = horizontal.normalized()
orthoproj = Metashape.OrthoProjection()
if chunk.crs.geoccs:
orthoproj.crs = chunk.crs.geoccs # case of georeferenced project
else:
orthoproj.crs = chunk.crs # case of Local CS project
R = Metashape.Matrix ([horizontal, vertical, normal])
t = R*T.mulp(m1.position)
orthoproj.matrix = Metashape.Matrix.Translation(-t)*Metashape.Matrix.Rotation(R)
chunk.buildOrthomosaic(surface_data=Metashape.ModelData, projection = orthoproj)
see attachmnet...