Forum

Author Topic: Exporting estimated camera position and orientation  (Read 5665 times)

yweidmann

  • Newbie
  • *
  • Posts: 9
    • View Profile
Exporting estimated camera position and orientation
« on: January 03, 2017, 03:05:44 PM »
Dear list

Is there a way to access the estimated coordinates and orientations of each camera by scripting? Would like to write my own exporter to include some more information for each camera.

Looking forward to any hint,
Yvo

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14927
    • View Profile
Re: Exporting estimated camera position and orientation
« Reply #1 on: January 18, 2017, 02:40:53 PM »
Hello Yvo,

If you have georeferenced chunk, then the estimated camera position can be accessed using the following line:

Code: [Select]
chunk.crs.project(chunk.transform.matrix.mulp(camera.center))
Accessing the estimated orientation is a little but more complicated:
Code: [Select]
T = chunk.transform.matrix
m = chunk.crs.localframe(T.mulp(camera.center)) #transformation matrix to the LSE coordinates in the given point
R = m * T * camera.transform * PhotoScan.Matrix().Diag([1, -1, -1, 1])

row = list()
for j in range (0, 3): #creating normalized rotation matrix 3x3
    row.append(R.row(j))
    row[j].size = 3
    row[j].normalize()
R = PhotoScan.Matrix([row[0], row[1], row[2]])

yaw, pitch, roll = PhotoScan.utils.mat2ypr(R) #estimated orientation angles
print(yaw, pitch, roll)
« Last Edit: February 16, 2017, 09:18:19 PM by Alexey Pasumansky »
Best regards,
Alexey Pasumansky,
Agisoft LLC

jiji

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Exporting estimated camera position and orientation
« Reply #2 on: March 03, 2017, 01:48:50 AM »
Hello Alex,

I have the same question here and I understand gloabally the whole code that you gave.

But I don't really understand what the chunk.crs.localframe(gt) does exactlly ?
What does the result matrix mean ? and how we can get it from the geocentric point ?
could you give some details about the matrix calculation on this step ?


thx

jiji

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Exporting estimated camera position and orientation
« Reply #3 on: March 03, 2017, 02:20:37 AM »
Is the matrix return by crs.localframe(geocentricPoint) like below ? :

R = [ -sin L;               cos L;               0
         -sin N cos L;   -sin N sin L;   cos N
        -cos N cos L;  -cos N sin L;   -sinN
       ]


I found this matrix when my CRS is WGS 84. But there's some small difference when my CRS is some projection coordinates system.  where does these differences come from ?