def setUp(self): self.rtol = 1e-7 self.atol = 1e-7 np.random.random(3,) - 0.5 self.R = rotation_matrix(np.random.random(3,) - 0.5, np.random.rand() * 2 * np.pi) self.T = np.random.random((3,)) extrinsic_matrix = OpticalEquipment.extrinsic_matrix(self.R, self.T) self.oe = OpticalEquipment(extrinsic_matrix, np.eye(3), None, (1600, 1200))
def setUp(self): self.rtol = 1e-7 R = np.eye(3) T = np.zeros(3) intrinsic_matrix = np.eye(3) distortion = np.zeros(5) self.resolution = (4,3) self.oe = OpticalEquipment(OpticalEquipment.extrinsic_matrix(R, T), intrinsic_matrix, distortion, self.resolution)
def hard_coded_translation_test(self): x = [0, 0, 0] x_global = [1, 1, -1] R = np.eye(3) T = [-1, -1, 1] extrinsic_matrix = OpticalEquipment.extrinsic_matrix(R, T) oe = OpticalEquipment(extrinsic_matrix, np.eye(3), None, (32, 14)) assert_allclose(to_global_frame(x, oe), x_global, rtol=self.rtol)
def hard_coded_translation_and_rotation_test(self): x = [0, 0, 0] x_global = [1, 0, 0] theta = np.radians(45) R = [[np.cos(theta), 0, np.sin(theta)], [0, 1, 0], [-np.sin(theta), 0, np.cos(theta)]] T = [-1/np.sqrt(2), 0, 1/np.sqrt(2)] extrinsic_matrix = OpticalEquipment.extrinsic_matrix(R, T) oe = OpticalEquipment(extrinsic_matrix, np.eye(3), None, (32, 14)) assert_allclose(to_global_frame(x, oe), x_global, rtol=self.rtol, atol=self.atol)
def setUp(self): self.rtol = 1e-7 self.atol = 1e-7 R = np.eye(3) T = np.zeros(3) extrinsic_matrix = OpticalEquipment.extrinsic_matrix(R, T) intrinsic_matrix = np.eye(3) distortion = np.zeros(5) resolution = (3,2) oe = DLPProjector(extrinsic_matrix, intrinsic_matrix, distortion, resolution) self.row_planes, self.col_planes = projector_planes(oe) pixels = np.array([[[0, 0], [0, 1]], [[1, 0], [1, 1]], [[2, 0], [2, 1]]]) self.exp_row_planes = [[1, 0, 0, 0], fit_plane([[1, 0, 1],[1, 1, 1],[0, 0, 0]]), fit_plane([[2, 0, 1],[2, 1, 1],[0, 0, 0]])] self.exp_col_planes = [[0, 1, 0, 0], fit_plane([[0, 1, 1],[1, 1, 1],[2, 1, 1],[0, 0, 0]])]
def setUp(self): self.rtol = 1e-7 self.atol = 1e-7 theta = np.radians(45) R = [[np.cos(theta), 0, np.sin(theta)], [0, 1, 0], [-np.sin(theta), 0, np.cos(theta)]] T = [-np.cos(theta), 0, np.sin(theta)] extrinsic_matrix = OpticalEquipment.extrinsic_matrix(R, T) intrinsic_matrix = np.eye(3) distortion = np.zeros(5) resolution = (2,2) oe = DLPProjector(extrinsic_matrix, intrinsic_matrix, distortion, resolution) self.vert_planes, self.horz_planes = projector_planes(oe) self.exp_vert_planes = [fit_plane([[1, 0, 0], [1, 1, 0], [0, 0, 1]]), [1, 0, 0, 1]] # find where z=1 in the projector plane for the x=0 points x0 = 1 - 1/np.sqrt(2) z0 = 1/np.sqrt(2) self.exp_horz_planes = [[0, 1, 0, 0], fit_plane([[1, 0, 0], [x0, 1, z0], [1, 1, np.sqrt(2)]])]
def setUp(self): self.focal_length = random((2,)) self.alpha = random() self.principal_point = random((2,)) self.calculated_params = OpticalEquipment.intrinsic_parameters( OpticalEquipment.intrinsic_matrix(self.focal_length, self.principal_point, self.alpha))
def setUp(self): self.R = random((3,3)) self.T = random((3,)) self.calculated_params = OpticalEquipment.extrinsic_parameters( OpticalEquipment.extrinsic_matrix(self.R, self.T))