I am trying to do the same I think - I have a model in a local coordinate system derived from scale bars on a calibration plate, and I am trying to get the model in the frame of reference of one camera (camera at origin **and zero the pitch/roll/yaw**).

I ~~didn't have much luck with~~ could only rotate the coordinate system to the camera orientation with Alexey's code, and I could only translate the coordinate system to the camera origin with daxils code (with minor tweak):`chunk.transform.translation = Metashape.Vector([0,0,0])`

But can't figure out how to integrate both!

Looking at the two different chunk.transform.matrices I can see that the T.scale() factor is changing the scale, but I'm unclear exactly what that's for - it looks like it makes the rotations work but breaks the translation? Sorry linear algebra and rotation matrices aren't my forte. Any help is appreciated.

My code:`doc = Metashape.app.document`

chunk = doc.chunk

camera = chunk.cameras[2]

#below moves coordinate system origin to camera origin, but doesn't rotate everything nicely:

R = camera.transform

chunk.transform.translation = Metashape.Vector([0,0,0])

chunk.transform.matrix = chunk.transform.matrix * R.inv()

#below (instead of 3 lines above) rotates coordinate system to camera pose, but doesn't translate properly

T = chunk.transform.matrix

origin = (-1) * camera.center

R = Metashape.Matrix().Rotation(camera.transform.rotation()*Metashape.Matrix().Diag([1,-1,1]))

origin = R.inv().mulp(origin)

chunk.transform.matrix = T.scale() * Metashape.Matrix().Translation(origin) * R.inv()