def relative_between_n(table1, table2, axis=0, inv=False): f = relative_between_inv if inv else relative_between relative_poses = [f(poses1, poses2) for poses1, poses2 in zip(table1._sequence(axis), table2._sequence(axis))] return Table.stack(relative_poses)
def mean_robust_n(pose_table, axis=0): def f(poses): if not np.any(poses.valid): return invalid_pose else: return valid_pose(matrix.mean_robust(poses.poses[poses.valid])) mean_poses = [f(poses) for poses in pose_table._sequence(axis)] return Table.stack(mean_poses)
def detect(self, image): detections = self.grid.compute_observation(image) if not detections.success: return empty_detection corner_detections = [struct(ids = id * 4 + k % 4, corners=corner) for k, id, corner in zip(range(len(detections.ids)), detections.ids, detections.image_points)] return subpix_corners(image, Table.stack(corner_detections), self.subpix_region)
def stack_boards(boards): padded_points = max([board.num_points for board in boards]) def pad_points(board): points = board.adjusted_points.astype(np.float64) return struct( points=np.pad(points, [(0, padded_points - points.shape[0]), (0, 0)]), valid = np.arange(padded_points) < board.num_points ) return Table.stack([pad_points(board) for board in boards])
def make_nd_table(items, n): if n > 1: rows = [make_nd_table(row, n - 1) for row in items] return Table.stack(rows) else: return Table.stack(items)