Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: sarko on September 06, 2012, 12:37:16 AM

Title: Question on setting user calibration
Post 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:


Code: [Select]
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. 
Title: Re: Question on setting user calibration
Post by: sarko on September 06, 2012, 01:49:46 AM
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.

Title: Re: Question on setting user calibration
Post by: an198317 on June 04, 2013, 08:16:52 PM
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
Title: Re: Question on setting user calibration
Post by: Alexey Pasumansky on June 12, 2013, 01:37:18 PM
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.