Forum

Author Topic: How to use PhotoScan.CameraReference  (Read 2800 times)

jonathanH

  • Newbie
  • *
  • Posts: 12
    • View Profile
How to use PhotoScan.CameraReference
« on: May 06, 2016, 08:49:49 PM »
Hi, I am trying to retrieve the 'location' and 'rotation' attributes from the CameraReference class. How can one go about getting these? I have tried the following but it does not work:

camLocations = []
camRotations = []
count = 1
for cam in chunk.cameras:
    camLocations.append(str(count)+":"+str(cam.CameraReference.location))
    camRotations.append(str(count)+":"+str(cam.CameraReference.rotation))
    count+=1

Has anyone used this class before?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: How to use PhotoScan.CameraReference
« Reply #1 on: May 06, 2016, 08:58:18 PM »
Hello Jonathan,

To access source values for the cameras displayed in the Reference pane you need to use
Code: [Select]
cam.reference.location
cam.reference.rotation
In case any data is not available you'll be given "None".
Best regards,
Alexey Pasumansky,
Agisoft LLC

jonathanH

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: How to use PhotoScan.CameraReference
« Reply #2 on: May 06, 2016, 09:16:25 PM »
Thanks Alexey,

I'm getting None values. Is there any way of calculating estimated values for a local coordinate system?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: How to use PhotoScan.CameraReference
« Reply #3 on: May 06, 2016, 09:46:46 PM »
Hello Jonathan,

camera.reference contain only source values.

If you have set the coordinate system to local coordinates (chunk is referenced) then coordinates of the camera center can be calculated in the following way:
Code: [Select]
x, y, z = chunk.transform.matrix.mulp(cam.center)to get the estimated yaw, pitch, roll you need to use the following:
Code: [Select]
m = chunk.transform.matrix * cam.transform * PhotoScan.Matrix().diag([1,-1,-1,1])
row = []
for i in range(3):
   row.append(m.row(i))
   row[i].size = 3
   row[i].normalize()
rotation = PhotoScan.Matrix([row[0], row[1], row[2]])
yaw, pitch, roll = PhotoScan.utils.mat2ypr(rotation)
the complex procedure of rotation component extraction will be much easier in the next update, it can be achieved using rotation = m.rotation()
Best regards,
Alexey Pasumansky,
Agisoft LLC

jonathanH

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: How to use PhotoScan.CameraReference
« Reply #4 on: May 06, 2016, 10:27:16 PM »
Thank you so much Alexey!!!

I don't know if it works yet but I seem to be getting a tuple of what looks like angles. I've been searching for how to do this for absolutely ages!

 ;D ;D ;D ;D ;D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D ::) ::) ::) :'(  :) :) :) :) :) :)