Forum

Author Topic: How to set region volume to 2 camera locations?  (Read 5830 times)

Fernando

  • Newbie
  • *
  • Posts: 16
    • View Profile
How to set region volume to 2 camera locations?
« on: July 07, 2014, 01:39:21 AM »
Hi, I was wondering if I could manually set the region bounding box to 2 points in space: 2 camera locations.

So for example these are the camera locations:

cam1(0,0,0)
cam2(100,100,100)

Together they form the maximum / most outer points of the region volume.

How can I set the region to that volume?

Thanks!
« Last Edit: July 08, 2014, 10:29:31 AM by Fernando »

Fernando

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: How to set region volume to 2 camera locations?
« Reply #1 on: July 09, 2014, 02:19:17 PM »
Hi, maybe someone could help me? Or is this a really dumb question? Sorry, I'm a total Python noob  :'(

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14854
    • View Profile
Re: How to set region volume to 2 camera locations?
« Reply #2 on: July 09, 2014, 03:03:44 PM »
Hello Fernando,

Are region sides supposed to be parallel to the coordinate system planes?
Best regards,
Alexey Pasumansky,
Agisoft LLC

Fernando

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: How to set region volume to 2 camera locations?
« Reply #3 on: July 09, 2014, 05:05:05 PM »
Hello Alexey,

No, that is not necessary.

Thanks

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14854
    • View Profile
Re: How to set region volume to 2 camera locations?
« Reply #4 on: July 09, 2014, 05:15:50 PM »
Hello Fernando,

Please try the following:

Code: [Select]
import PhotoScan

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

p1 = PhotoScan.app.getInt("Specify first camera index:", 0)
p2 = PhotoScan.app.getInt("Specify second camera index:", len(chunk.cameras)-1)
p1 = chunk.cameras[p1]
p2 = chunk.cameras[p2]

region = PhotoScan.Region()
dist = p2.center - p1.center
region.size = PhotoScan.Vector([dist.x, dist.y, dist.z])
region.center = (p1.center + p2.center) / 2.
region.rot = PhotoScan.Matrix().diag([1,1,1])
chunk.region = region

PhotoScan.app.update()


On script run you'll be asked about camera indices you wish to use (leading zero).
Best regards,
Alexey Pasumansky,
Agisoft LLC

Fernando

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: How to set region volume to 2 camera locations?
« Reply #5 on: July 10, 2014, 06:57:01 PM »
Thank you so much Alexey! I'll give this a try.