Agisoft Metashape
Agisoft Metashape => Python and Java API => Topic started by: Fernando 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!
-
Hi, maybe someone could help me? Or is this a really dumb question? Sorry, I'm a total Python noob :'(
-
Hello Fernando,
Are region sides supposed to be parallel to the coordinate system planes?
-
Hello Alexey,
No, that is not necessary.
Thanks
-
Hello Fernando,
Please try the following:
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).
-
Thank you so much Alexey! I'll give this a try.