Forum

Author Topic: Move origin  (Read 6497 times)

chr00t

  • Newbie
  • *
  • Posts: 12
    • View Profile
Move origin
« on: August 19, 2016, 02:50:26 PM »
Hello,

Would you complete that snippet on how to change the origin?

I want the first camera to become the new origin

import PhotoScan
import math
doc = PhotoScan.app.document
doc.open("project.psx")
chunk = doc.chunk
camera_becoming_origin = chunk.cameras[0];

then transform ?  :o

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15429
    • View Profile
Re: Move origin
« Reply #1 on: August 19, 2016, 03:00:02 PM »
Hello chr00t,

Code: [Select]
import PhotoScan

chunk = PhotoScan.app.document.chunk
origin = chunk.cameras[0].center #first camera center

T = PhotoScan.Matrix().diag([1,1,1,1])
for i in range(3):
T[i,3] = -origin[i]
chunk.transform.matrix = chunk.transform.matrix * T

But you might need to perform check whether the camera is aligned and camera index is not out of range, in case you are including the script in some large automated pipeline.
« Last Edit: August 19, 2016, 03:38:52 PM by Alexey Pasumansky »
Best regards,
Alexey Pasumansky,
Agisoft LLC

chr00t

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Move origin
« Reply #2 on: August 19, 2016, 03:37:07 PM »
I'll consider checking names and range later on for sure :)

But why is this happening?

2016-08-19 14:36:10   File "C:/Users/User/Desktop/Test/Origin.py", line 8, in <module>
2016-08-19 14:36:10     T[i,3] = -origin
2016-08-19 14:36:10 TypeError: 'PhotoScan.Camera' object does not support indexing

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15429
    • View Profile
Re: Move origin
« Reply #3 on: August 19, 2016, 03:39:19 PM »
Sorry, there was a typo, origin  = chunk.cameras[0].center
Best regards,
Alexey Pasumansky,
Agisoft LLC

chr00t

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Move origin
« Reply #4 on: August 23, 2016, 06:01:15 PM »
Working as a charm,

Thanks Alexey