Beispiel #1
0
	def setP(self, P, distortion = None, setInterest = True, store = False):
		'''Set the view to match the given camera projection matrix. P can be 4x4 or 3x4.'''
		K, RT = Calibrate.decomposeKRT(P)
		self.setK(K)
		self.setRT(RT, setInterest)
		self.cameraDistortion = distortion
		if distortion is not None: self.cameraDistortion = (float(distortion[0]),float(distortion[1])) # make it hashable
		if store: self.setResetData()
Beispiel #2
0
	def testP(self):
		K, RT = Calibrate.decomposeKRT(self.P())
		print ('K', K, self.K())
		print ('RT', RT, self.RT())
		print (self.cameraFovX,self.cameraKox,self.cameraKoy,self.cameraKsquare,self.cameraKskew)
		print ((self.cameraPan, self.cameraTilt, self.cameraRoll), self.cameraT, self.cameraInterest)
		print ('cf')
		print (Calibrate.decomposeK(K))
		print (Calibrate.decomposeRT(RT, self.cameraInterest, False))
Beispiel #3
0
def matToVec(P, distortion):
	outVec = np.zeros(11, dtype=np.float32)
	K, RT = Calibrate.decomposeKRT(P)
	outVec[:3] = cv2.Rodrigues(RT[:3, :3])[0].ravel()
	outVec[3:6] = RT[:3, 3]
	outVec[6] = K[0, 0] # Focal Length
	outVec[7:9] = distortion
	outVec[9:] = K[:2, 2] # Optical Centre
	return outVec
Beispiel #4
0
             (215. - 1 - 5 + 8 - 1, -126. + 1 + 4 + 3 - 3,
              182. - 2.5 - 3), (0.292402446, 0.214726448)),
            (215, 76.4, (0.019527, 0.037984), (29.3 - 0.2, 35.0 - 0.2,
                                               -104.6 + 0.1),
             (63 + 2., -119 - 1, 170 + 1), (0.29172, 0.22112)),
            (261, 76.7, (-0.050844, 0.078558),
             (18.1 - 0.3, 24.8 + 1.2, -101.7), (81. + 2, -158 + 4,
                                                199), (0.29115, 0.228548)),
        ]
        for ci, (c, x) in enumerate(zip(cams, xcp)):
            interest, fovX, (ox, oy), pan_tilt_roll, tx_ty_tz, distortion = c
            K, RT = Calibrate.composeK(fovX, ox=ox,
                                       oy=oy), Calibrate.composeRT(
                                           Calibrate.composeR(pan_tilt_roll),
                                           tx_ty_tz, 0)
            K, RT = Calibrate.decomposeKRT(
                xcp[ci][2])  # !!!!use the original values!!!!
            P = np.dot(K, RT)[:3, :]
            P2 = x[2]
            print 'diff', np.dot(P2[:3, :3], np.linalg.pinv(
                P[:3, :3])), 'dt', P[:, 3] - P2[:, 3]
            RT = np.dot(RT, offset)
            xcp[ci] = [
                K[:3, :3], RT[:3, :4],
                np.dot(K, RT)[:3, :], distortion,
                -np.dot(RT[:3, :3].T, RT[:3, 3])
            ]

        distortion = (0.291979, 0.228389)
        K, RT = Calibrate.composeK(fovX, ox=ox, oy=oy), Calibrate.composeRT(
            Calibrate.composeR(pan_tilt_roll), tx_ty_tz, 0)
        mat0 = [