After aligning the cameras in Agisoft Photoscan the orientation of the model is randomly positioned. Since we need to go back and forth between different applications a solid orientation and scale compared to world coordinate system is necessary. So let’s center our model. First of all we need to define 2 points on the model with known distance. Zoom in the sparse or dense cloud and select the first reference point with the Marquee Tool, then select RMB > Create Marker. That can take a while, depending on the amount of cameras used in the project. Repeat that step with the second point.
In the Workspace window select the 2 created Markers and click on the Add Scale Bar Icon from the shelf. A line appears at your model.
Go to the Reference Tab and enter the known distance in cm. Hit update.
Now we can use the Region bounding box and a python script to fix the rotation. It helps to alter the View: Perspective/Orthographic and turn on/off cameras whilst adjusting your region box correctly. Reset or rotate the view to zero out the axis.
Then align the model using the Rotate Model tool. Hit update.
Now switch to the reconstruction volume tool and rotate the red, green and blue band perpendicular to the corresponding axis. This will give us the correct x,y,z orientation. The region box center is where the center 0,0,0 of our model will be.
As soon as you are satisfied with the position and rotation hit Update. Now let’s run the “magic script”. Copy that code completely from # to matrix and paste it in a new Notepad document. The code is from the Agisoft Wiki.
#rotates model coordinate system in accordance of bounding box for active chunk #scale is kept #compatibility: Agisoft PhotoScan Professional 1.1.0 import PhotoScan import math doc = PhotoScan.app.document chunk = doc.chunk R = chunk.region.rot #Bounding box rotation matrix C = chunk.region.center #Bounding box center vector if chunk.transform.matrix: T = chunk.transform.matrix s = math.sqrt(T[0,0] ** 2 + T[0,1] ** 2 + T[0,2] ** 2) #scaling S = PhotoScan.Matrix().diag([s, s, s, 1]) #scale matrix else: S = PhotoScan.Matrix().diag([1, 1, 1, 1]) T = PhotoScan.Matrix( [[R[0,0], R[0,1], R[0,2], C], [R[1,0], R[1,1], R[1,2], C], [R[2,0], R[2,1], R[2,2], C], [0, 0, 0, 1]]) chunk.transform.matrix = S * T.inv() #resulting chunk transformation matrix
Save the file as “Coordinate System to Bounding Box.py” in C:UsersYour UsernameDocumentsAgisoft. By default windows appends a .txt suffix, which we need to remove.
Go to the directory and remove the .txt suffix. Confirm.
In Photoscan go to > Tools > Run Script and point to the “Coordinate System to Bounding Box.py” script. Done.