Forum

Author Topic: align bounding box to GCP coordinates x,y,z planes  (Read 8595 times)

bisenberger

  • Sr. Member
  • ****
  • Posts: 329
    • View Profile
    • Digital Mapping & Graphics
align bounding box to GCP coordinates x,y,z planes
« on: July 12, 2014, 12:46:07 PM »
It would be nice if the bounding box would align to the x,y,z plane defined by GCP's.
Digital Mapping & Graphics LLC
https://digital-mapping.net/

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15029
    • View Profile
Re: align bounding box to GCP coordinates x,y,z planes
« Reply #1 on: July 29, 2014, 08:33:44 AM »
Hello bisenberger,

We are considering such option built-in GUI, but at the moment custom script can be use to align bounding box according to the coordinate system. The sample script is in Python Scripting sub-forum.
Best regards,
Alexey Pasumansky,
Agisoft LLC

bisenberger

  • Sr. Member
  • ****
  • Posts: 329
    • View Profile
    • Digital Mapping & Graphics
Re: align bounding box to GCP coordinates x,y,z planes
« Reply #2 on: August 10, 2014, 09:44:59 PM »
Thanks Alexey  :)
Digital Mapping & Graphics LLC
https://digital-mapping.net/

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15029
    • View Profile
Re: align bounding box to GCP coordinates x,y,z planes
« Reply #3 on: August 15, 2014, 11:03:25 AM »
Hello nadar,

Please try this one:
Code: [Select]
import PhotoScan
import math

doc = PhotoScan.app.document
chunk = doc.activeChunk

T = chunk.transform

v = PhotoScan.Vector( [0,0,0,1] )
v_t = T * v
v_t.size = 3

if chunk.crs:
m = chunk.crs.localframe(v_t)
else:
m = PhotoScan.Matrix().diag([1,1,1,1])

m = m * T

s = math.sqrt(m[0,0]*m[0,0] + m[0,1]*m[0,1] + m[0,2]*m[0,2]) #scale factor

R = PhotoScan.Matrix( [[m[0,0],m[0,1],m[0,2]], [m[1,0],m[1,1],m[1,2]], [m[2,0],m[2,1],m[2,2]]])
R = R * (1. / s)

reg = chunk.region
reg.rot = R.t()
chunk.region = reg
Best regards,
Alexey Pasumansky,
Agisoft LLC

bisenberger

  • Sr. Member
  • ****
  • Posts: 329
    • View Profile
    • Digital Mapping & Graphics
Re: align bounding box to GCP coordinates x,y,z planes
« Reply #4 on: August 22, 2014, 04:36:07 PM »
Excellent!

Would it be possible to run the script from Batch Process?
Digital Mapping & Graphics LLC
https://digital-mapping.net/

bisenberger

  • Sr. Member
  • ****
  • Posts: 329
    • View Profile
    • Digital Mapping & Graphics
align bounding box to GCP coordinates x,y,z planes broken in current release
« Reply #5 on: January 14, 2015, 08:49:52 PM »
The script that was posted in this thread no longer works in the current release, 1.1.0:

http://www.agisoft.com/forum/index.php?topic=2607.0
Digital Mapping & Graphics LLC
https://digital-mapping.net/

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15029
    • View Profile
Re: align bounding box to GCP coordinates x,y,z planes
« Reply #6 on: January 14, 2015, 08:58:10 PM »
Hello Bill,

There were some changes in Python API. Here's script modified for version 1.1:

Code: [Select]
import PhotoScan
import math

doc = PhotoScan.app.document
chunk = doc.chunk

T = chunk.transform.matrix


if chunk.crs:
v_t = T * PhotoScan.Vector( [0,0,0,1] )
v_t.size = 3
m = chunk.crs.localframe(v_t)
else:
m = PhotoScan.Matrix().diag([1,1,1,1])

m = m * T

s = math.sqrt(m[0,0]**2 + m[0,1]**2 + m[0,2]**2) #scale factor

R = PhotoScan.Matrix( [[m[0,0],m[0,1],m[0,2]], [m[1,0],m[1,1],m[1,2]], [m[2,0],m[2,1],m[2,2]]])
R = R * (1. / s)

reg = chunk.region
reg.rot = R.t()
chunk.region = reg
Best regards,
Alexey Pasumansky,
Agisoft LLC