Forum

Author Topic: Convert camera coordinates to world coordinates  (Read 2451 times)

McGavish

  • Newbie
  • *
  • Posts: 4
    • View Profile
Convert camera coordinates to world coordinates
« on: August 25, 2021, 12:05:27 PM »
Hi,

I'm using Metashape Standard and I would like to convert all cameras coordinates calculated from alignment to world coordinates. I can extract 4x4 camera transform matrix from xml file (Export Cameras option) but I'm not sure how to do the conversion. I don't know where I can find world orientation in Metashape Standard. Is it possible?

Bzuco

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: Convert camera coordinates to world coordinates
« Reply #1 on: August 26, 2021, 02:18:45 PM »
Until someone tells you, if it is possible or how to convert, you can find some help "decomposing a 4x4 transformation matrix" on google.
You can also export cameras to FBX and import it in Blender, which will tell you what is the position and rotation in world space.

McGavish

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Convert camera coordinates to world coordinates
« Reply #2 on: August 28, 2021, 11:49:45 AM »
Thanks Bzuco! I managed to transform rotation matrix from Metashape to Euler angles but these seem to be not very optimal solution because of possible Gimbal Lock (for example two cameras very close to each other have very different XYZ rotation angles, but still very similar overall angle). That's why it's probably better to keep all values in matrix.

I'm not sure about one more thing whether camera rotation matrix from cameras.xml is already in world coordinates or if I should multiply it by chunk transform (in Metashape Standard). @Alexey, could you confrim this?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Convert camera coordinates to world coordinates
« Reply #3 on: August 30, 2021, 01:47:37 PM »
Hello McGavish,

Since Standard edition doesn't support georeferencing, you'll get a kind of Local Coordinate system. If you have manually scaled, rotated or shifted the model (and there are S, T or R marks next to the chunk's label in the Workspace pane), then you should also multiply the camera.transform matrix by chunk.transform (from the left) and then work with the resulting matrix, that will already include all the manual modifications applied to the model space.
Best regards,
Alexey Pasumansky,
Agisoft LLC