Exemple #1
0
 def calibrate_pt_dlt(self, data=None):
     if data is None:
         data = self.calibration_raw_6d
     data3d = data[:,3:6]
     data2d = data[:,0:2]
     Pmat, residuals = camera_math.DLT(data3d, data2d)
     self.Mhat = Pmat
     self.Mhatinv = np.linalg.pinv(self.Mhat)
     self.camera_center = camera_math.center(Pmat)
     
     print 'mhat: '
     print self.Mhat
     print 'camera center: '
     print self.camera_center
     print 'residuals'
     print residuals
     print 'decomp'
     camera_math.decomp(self.Mhat, SHOW=1)
     return
Exemple #2
0
 def write_to_xml(self, pmat, filename=None):
     if filename is None:
         filename = time.strftime("ptf_calibration_xml_%Y%m%d_%H%M%S.txt",time.localtime())
     print 'pmat: '
     print pmat
     K,R,t = camera_math.decomp(pmat)
     print 'K: ', K
     print 'R: ', R
     Knew = np.eye(3)
     Rnew = R
     Rt = np.hstack((R,t))
     Kscaled = K / K[2,2]
     print 'kscaled: '
     print Kscaled
     Pnew = np.dot( Kscaled, Rt)
     self.SingleCameraCalibration = reconstruct.SingleCameraCalibration_from_basic_pmat(Pnew, cam_id='ptf', res=[1000,1000])
     #self.SingleCameraCalibration.to_file(filename)
     #reconstruct.pretty_dump(self.SingleCameraCalibration)
     # now load Reconstructor
     self.Reconstructor = reconstruct.Reconstructor([self.SingleCameraCalibration])
     return