def get_boxes_in_3d(self): boxes3d = [] for i, basename in enumerate(self.frame_basenames): bbox = self.bbox[basename] cam_mat = self.calib[basename] cam = cam_utils.Camera(basename, cam_mat['A'], cam_mat['R'], cam_mat['T'], self.shape[0], self.shape[1]) bbox3d = misc_utils.lift_box_in_3d(cam, bbox) boxes3d.append(bbox3d) return boxes3d
def order_boxes(self, frame_number): basename = self.frame_basenames[frame_number] boxes = self.bbox[basename] cam_mat = self.calib[basename] cam = cam_utils.Camera(basename, cam_mat['A'], cam_mat['R'], cam_mat['T'], self.shape[0], self.shape[1]) bbox3d = misc_utils.lift_box_in_3d(cam, boxes) points3d = np.zeros((0, 3)) for i in range(bbox3d.shape[0]): points3d = np.vstack((points3d, bbox3d[i, 0, :])) _, depth = cam.project(points3d) return sorted([i for i in range(len(depth))], key=lambda x: depth[x])