Calibrate a Photoscan

Agisoft Photoscan usually outputs models randomly positioned and oriented. For further use and exchange a proper orientation and scale is essential. To center your model first of all you need to define 2 points 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 – ignore the expected measuring unit (m). Hit update.


Now you can use the Region bounding box and a python script to fix the rotation. Change the -> View -> Perspective/Orthographic (5 Key) to Orthographic and turn on/off cameras whilst adjusting your region box. Select -> View -> Reset View to zero out the axis.


Align the model using the Rotate Model tool. Use the update icon to save the changes.


Now switch to the reconstruction volume tool and rotate the red, green and blue band perpendicular to the corresponding axis. This will give you the correct x,y,z orientation. The center of the region box defines the origin of our model.


As soon as you are satisfied with the position and rotation hit Update. Now 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.3.0

import PhotoScan 
import math 

doc =
chunk = doc.chunk

R = chunk.region.rot		#Bounding box rotation matrix
C =		#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
	S = PhotoScan.Matrix().Diag([1, 1, 1, 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.matrix = S * T.inv()		#resulting chunk transformation matrix

Save the file as “Coordinate System to Bounding” 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” script. Done.