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 projector_planes(proj): """ Function: projector_planes Generates the planes representing each row and column of the projector Parameters: proj - *<DLPProjector>* The projector to generate the planes of Returns: *Tuple* in the form (vertical_planes, horizontal_planes). row_planes will have shape (width, 4) and col_planes will have shape (height, 4). Each plane is defined by the coefficients [a, b, c, d], where a*x + b*y + c*z = d """ # generate pixel rays in the projector frame proj_pixels_proj_frame = pixel_rays(proj) from nose.tools import set_trace; set_trace() # translate and rotate the rays into the global frame proj_pixels = to_global_frame(proj_pixels_proj_frame, proj) # get projector location in the global frame proj_pose = to_global_frame([0, 0, 0], proj) # add projector location to the vertical points vertical_shape = (proj.resolution[0], 1, 3) proj_points_vertical = np.concatenate((proj_pixels, np.ones(vertical_shape) * proj_pose), axis=1) # calculate the vertical planes proj_planes_vertical = fit_plane(proj_points_vertical) # add projector location to the horizontalumn points horizontal_shape = (1, proj.resolution[1], 3) proj_points_horizontal = np.concatenate((proj_pixels, np.ones(horizontal_shape) * proj_pose), axis=0) # calculate the horizontalumn planes proj_planes_horizontal = fit_plane(np.transpose(proj_points_horizontal, (1, 0, 2))) return proj_planes_vertical, proj_planes_horizontal