Agisoft Metashape
Agisoft Metashape => Python and Java API => Topic started by: Yoann Courtois on December 16, 2021, 02:16:50 PM
-
Hey !
Based on previous topic (https://www.agisoft.com/forum/index.php?topic=11167.msg50189#msg50189), we found how we can get 3*3 rotation matrix and then yaw/pitch/roll values from 4*4 transformation matrix of an aligned images.
Using same function but with .translation() instead of .rotation(), we can easily get 3*1 translation matrix and so X,Y,Z coordinates.
But now for special test we would like to invert the process :
Based on 3*3 rotation and 3*1 translation matrix, we would like to get the 4*4 transformation matrix in metashape system.
Translation part is easy as X, Y and Z can be directly put in the 4*4 matrix like this :
[[*, *, *, X],
[*, *, *, Y],
[*, *, *, Z],
[0, 0, 0, 1]]
But for the rotation part, it looks .rotation() apply a calculation from the "star part" on the above matrix ([[*, *, ...]]) to the 3*3 rotation matrix.
So we would like to invert this function to create our own 4*4 matrix based on 3*3 rotation and 3*1 translation matrix.
Note : We get our 3*3 rotation matrix from yaw/pitch/roll values using ypr2mat() function
Hope it's clear enough ::)
Regards
-
Hello Yoann,
given a 3*3 rotation matrix R, to get the 4*4 equivalent you just do:
Metashape.Matrix.Rotation(R) see p. 70 of API document
given the 3*1 translation vector T, to get the 4*4 equicalenet, just do:
Metashape.Matrix.Translation(T)
Hope this is helpful,
-
Hello Paul,
Indeed, you are right ! But ...
We have worked a whole day on the problem that in some cases, 3*3 rotation matrix is not equal to (Metashape.Matrix.Rotation(R)).rotation().
Finally we found that they are equivalent, because they describe the same yaw/pitch/roll angles, but looking at each value of both matrix, they are different...
We have then been able to apply angle corrections to our images as needed.
Thank you.
-
Yoann, bien de savoir que cela a fonctionné,
Bonne continuation!