Agisoft Metashape
Agisoft Metashape => Python and Java API => Topic started by: eduardoestrada85 on October 19, 2012, 07:03:36 PM
-
Could someone help me with a script to flip a model that appears when you charge headlong into other software.
It appears that with the head pointing to the ground and need otherwise.
Sorry for the obviousness of my query, but do not understand the process of Ground control pane.
Having the script is not necessary to add markers right?
tnx in advance.
Eduardo.
-
Hello Eduardo,
We can provide a simple script that brings chunk coordinate system in accordance of Bounding Box - coordinate system axis parallel to the Bounding Box ribs.
-
Hi Alexey and tnx for your response.
Ideally, the idea is that the model remains standing. and even better if you can coordinate with the tool Bounding box.
tnx again.
Eduardo.
-
Hello Eduardo,
Here is a sample script that rotates model coordinate system in accordance of bounding box for active chunk
#scale is kept
#compatibility: Agisoft PhotoScan Professional 0.9.0
import PhotoScan
import math
doc = PhotoScan.app.document
chunk = doc.activeChunk
R = chunk.region.rot #Bounding box rotation matrix
C = chunk.region.center #Bounding box center vector
if chunk.transform:
T = chunk.transform
s = math.sqrt(T[0,0]*T[0,0] + T[0,1]*T[0,1] + T[0,2]*T[0,2]) #scaling
S = PhotoScan.Matrix( [[s, 0, 0, 0], [0, s, 0, 0], [0, 0, s, 0], [0, 0, 0, 1]] ) #scale matrix
else:
S = PhotoScan.Matrix( [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]] )
T = PhotoScan.Matrix( [[R[0,0],R[0,1],R[0,2], C[0]], [R[1,0],R[1,1],R[1,2],C[1]], [R[2,0],R[2,1],R[2,2],C[2]], [0,0,0,1]])
chunk.transform = S * T.inv() #resulting chunk transformation matrix
-
tnx Alexey.
-
Hello.
I tried using this script to align a model, but it did't work. I copied the sample script text and created a .py file with it. After aligning the model using Ctrl and Select tool, I run the script using Tool/Run script... without arguments. Is there something I'm missing?