Forum

Author Topic: Agisoft coordinate frame for poses conversion  (Read 7318 times)

davidbc

  • Newbie
  • *
  • Posts: 3
    • View Profile
Agisoft coordinate frame for poses conversion
« on: June 18, 2023, 03:03:23 PM »
Hello !
I am attempting to create a Python script to easily convert simple camera poses from Colmap to Agisoft, and the other way around.

I'm facing an issue with the camera coordinate system. I discovered that Colmap uses the following frame (from the camera's point of view):
[right, down, forwards] or [x, -y, -z].

However, I'm unable to find the coordinate frame used by Agisoft.
Do you have any insights into how I might resolve this issue?

My code is available here :
https://github.com/BCDavid/AgiPoses/




Colmap camera

1 0.97385556446084887 0.0013754180278881748 0.22599387574296945 0.023026417883844571 -5.4855674554568541 -0.73764511114013154 3.3757266221556628 1 DSC07956.JPG

Quaternion :
0.97385556446084887 0.0013754180278881748 0.22599387574296945 0.023026417883844571

Quaternion to 3x3 matrice :
0.8967931  -0.04422714  0.44023413
0.04547048  0.99893578  0.00772874
-0.44010744  0.01308658  0.89784975

Translation :
-5.4855674554568541
-0.73764511114013154
3.3757266221556628


Colmap camera matrice :

X (Right)   -y (Down)   -Z (Forwards) Translation

0.8967931  -0.04422714  0.44023413 -5.48556746
0.04547048  0.99893578  0.00772874 -0.73764511
-0.44010744  0.01308658  0.89784975 3.37572662



Agisoft camera

<transform>7.7821820478012271e-01 8.1507179109980107e-02 -6.2268210629689480e-01 2.4353860387551292e+00 1.4932407108378803e-01 -9.8712015548332599e-01 5.7411849243326533e-02 -2.3594825709565909e-01 -6.0998257970516445e-01 -1.3766037335452860e-01 -7.8036585910976708e-01 -1.1088427336932636e+00 0 0 0 1</transform>

3x3 matrice :
7.7821820478012271e-01 8.1507179109980107e-02 -6.2268210629689480e-01
1.4932407108378803e-01 -9.8712015548332599e-01 5.7411849243326533e-02
-6.0998257970516445e-01 -1.3766037335452860e-01 -7.8036585910976708e-01

Translation :
2.4353860387551292e+00
-2.3594825709565909e-01
-1.1088427336932636e+00


Agisoft camera matrice :

7.7821820478012271e-01 8.1507179109980107e-02 -6.2268210629689480e-01 2.4353860387551292e+00
1.4932407108378803e-01 -9.8712015548332599e-01 5.7411849243326533e-02 -2.3594825709565909e-01
-6.0998257970516445e-01 -1.3766037335452860e-01 -7.8036585910976708e-01 -1.1088427336932636e+00
« Last Edit: June 19, 2023, 03:45:46 PM by davidbc »

Paulo

  • Hero Member
  • *****
  • Posts: 1526
    • View Profile
Re: Agisoft coordinate frame for poses conversion
« Reply #1 on: June 18, 2023, 04:22:33 PM »
Hello davidbc,

I think the Agisoft camera frame is the same X right, Y down and Z in viewing direction. From user manual Appendix D:
Code: [Select]
The local camera coordinate system has origin at the camera projection center. The Z axis points towards
the viewing direction, X axis points to the right, Y axis points down.
Best Regards,
Paul Pelletier,
Surveyor

davidbc

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Agisoft coordinate frame for poses conversion
« Reply #2 on: June 18, 2023, 10:36:23 PM »
Hello @paulo, thank you! I couldn't find it in the manual.
So I shouldn't have to convert the coordinates.
However, I can't get a result by only transferring the coordinates.

In the following screenshot, you can see the correct pose and the imported one.
Do you think I've forgotten something?

Paulo

  • Hero Member
  • *****
  • Posts: 1526
    • View Profile
Re: Agisoft coordinate frame for poses conversion
« Reply #3 on: June 18, 2023, 11:45:07 PM »
Hi,

reading the github colmap documentation, I found the following https://colmap.github.io/format.html#images-txt:
Quote
This file contains the pose and keypoints of all reconstructed images in the dataset using two lines per image. Here, the first two lines define the information of the first image, and so on. The reconstructed pose of an image is specified as the projection from world to the camera coordinate system of an image using a quaternion (QW, QX, QY, QZ) and a translation vector (TX, TY, TZ).

So the pose info from colmap images.txt file represents transformation from world to camera. So I guess you would need to invert the Rotation matrix and also the translation vector to get correct camera to world transform....
Best Regards,
Paul Pelletier,
Surveyor

davidbc

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Agisoft coordinate frame for poses conversion
« Reply #4 on: June 19, 2023, 12:28:38 AM »
Thanks a lot! Seems to work fine, will do more test tomorrow and update the repo.
Thank you @Paulo !


Hi,

reading the github colmap documentation, I found the following https://colmap.github.io/format.html#images-txt:
Quote
This file contains the pose and keypoints of all reconstructed images in the dataset using two lines per image. Here, the first two lines define the information of the first image, and so on. The reconstructed pose of an image is specified as the projection from world to the camera coordinate system of an image using a quaternion (QW, QX, QY, QZ) and a translation vector (TX, TY, TZ).

So the pose info from colmap images.txt file represents transformation from world to camera. So I guess you would need to invert the Rotation matrix and also the translation vector to get correct camera to world transform....