Hello flydrones,
You can use the following sample script as a reference:
import PhotoScan, math
chunk = PhotoScan.app.document.chunk
T = chunk.transform.matrix
for camera in chunk.cameras:
yaw, pitch, roll = math.pi * camera.reference.rotation / 180.
sinx = math.sin(pitch)
cosx = math.cos(pitch)
Rx = PhotoScan.Matrix([[1, 0, 0], [0, cosx, -sinx], [0, sinx, cosx]])
siny = math.sin(roll)
cosy = math.cos(roll)
Ry = PhotoScan.Matrix([[cosy, 0, siny], [0, 1, 0], [-siny, 0, cosy]])
sinz = math.sin(-yaw)
cosz = math.cos(-yaw)
Rz = PhotoScan.Matrix([[cosz, -sinz, 0], [sinz, cosz, 0], [0, 0, 1]])
R = Rz * Rx * Ry
coord = camera.reference.location
coord = chunk.crs.unproject(coord)
m = chunk.crs.localframe(coord)
R = PhotoScan.Matrix( [[m[0,0],m[0,1],m[0,2]], [m[1,0],m[1,1],m[1,2]], [m[2,0],m[2,1],m[2,2]]]).t() * R * PhotoScan.Matrix().Diag((1, -1, -1))
row = list()
for j in range(0, 3):
row.append(PhotoScan.Vector(R.row(j)))
row[j].size = 4
row[j].w = coord[j]
row.append(PhotoScan.Vector([0, 0, 0, 1]))
M = PhotoScan.Matrix([row[0], row[1], row[2], row[3]])
camera.transform = T.inv() * M
chunk.updateTransform()
It should be run when for active chunk every camera has coordinate and angle information input in the Reference pane.