Agisoft Metashape
Agisoft Metashape => Python and Java API => Topic started by: sarko on September 06, 2012, 12:37:16 AM
-
I am taking my first stab at using the python API in Photoscan. I have been able to create a document, load photos into a chunk and align/create geometry. However, I want to update the camera calibration information and have been unable to get it to work. Relevant snippet of code is below:
for i in range(0,numFiles):
p = PhotoScan.Photo()
testFile = data[i].rstrip()
p.open(testFile)
cenX = p.width/2
cenY = p.height/2
p.user_calib = ps.Calibration(cx=cenX,cy=cenY,fx=12180.0,fy=12180.0)
newChunk.photos.add(p)
I'm trying to use p.user_calib to set the calibration, but it sets all values to zero when I do what's above. Any thoughts???
Thank you.
-
I figured it out. Working now, but I can't filter by mask when I do my align for some reason. Still working on that one if anyone has ideas.
-
Hi sarko,
I am interested in this user_calib argument as well. I noticed you only used cenX, cenY, and focal length. Which kind of other information we can put into user_calib? Can we put camera position XYZ and orientation angles in user_calib as well?
Thanks,
Nan
-
Hello Nan,
User_calib contain only calibration data for camera (image width and height, focal length, principal point distance, radial and tangential distortion coefficients, skew).
To input camera coordinates you can use chunk.ground_control, in case the information is in real world coordinate system or use photo.transform matrix, but please note that in latter case it should be absolutely precise information.