def find_gt_bboxes(id, data_folder, segment_name, start_frame, end_frame): """ This function is for finding the gt bboxes Args: id (str): id of the tracklet gt_folder (str): root for data storage segment_name (str): the segment to look at start_frame (int): which frame to search Return list of bboxes """ gt_info = np.load(os.path.join(data_folder, 'gt_info', '{:}.npz'.format(segment_name)), allow_pickle=True) ego_info = np.load(os.path.join(data_folder, 'ego_info', '{:}.npz'.format(segment_name)), allow_pickle=True) bboxes, ids = gt_info['bboxes'][start_frame], gt_info['ids'][start_frame] index = ids.index(id) gts = list() for i in range(start_frame + 1, end_frame + 1): # first frame needs no evaluation # so begin from start_frame + 1 frame_bboxes = gt_info['bboxes'][i] frame_ids = gt_info['ids'][i] index = frame_ids.index(id) bbox = frame_bboxes[index] bbox = BBox.array2bbox(bbox) ego_matrix = ego_info[str(i)] bbox = BBox.bbox2world(ego_matrix, bbox) gts.append(bbox) return gts
def find_bboxes(id, data_folder, segment_name, start_frame, end_frame): """ In the SOT, the beginning frame is a GT BBox This function is for finding the gt bbox Args: id (str): id of the tracklet data_folder (str): root for data storage segment_name (str): the segment to look at start_frame (int): which frame to search Return BBox (numpy array): [x, y, z, h, l, w, h] """ gt_info = np.load(os.path.join(data_folder, 'gt_info', '{:}.npz'.format(segment_name)), allow_pickle=True) ego_info = np.load(os.path.join(data_folder, 'ego_info', '{:}.npz'.format(segment_name)), allow_pickle=True) bboxes, ids = gt_info['bboxes'][start_frame], gt_info['ids'][start_frame] index = ids.index(id) start_bbox = bboxes[index] gts = list() for i in range(start_frame, end_frame + 1): frame_bboxes = gt_info['bboxes'][i] frame_ids = gt_info['ids'][i] index = frame_ids.index(id) bbox = frame_bboxes[index] bbox = BBox.array2bbox(bbox) ego_matrix = ego_info[str(i)] bbox = BBox.bbox2world(ego_matrix, bbox) gts.append(bbox) return start_bbox, gts
def preprocess(self): """ Some data need eplicit transformation to the world coordinate: point cloud, detection bboxes """ self.pc = utils.pc2world(self.ego, self.pc) if self.dets is not None: self.dets = [BBox.bbox2world(self.ego, det) for det in self.dets] return
def tracker_api(configs, id, start_bbox, start_frame, data_loader, track_len, gts=None, visualize=False): """ api for the tracker Args: configs: model configuration read from config.yaml id (str): each tracklet has an id start_bbox ([x, y, z, yaw, l, w, h]): the beginning location of this id data_loader (an iterator): iterator returning data of each incoming frame Return: { frame_number0: pred_bbox0, frame_number1: pred_bbox1, ... frame_numberN: pred_bboxN } """ tracker = sot_3d.Tracker(id=id, configs=configs, start_bbox=start_bbox, start_frame=start_frame, track_len=track_len) tracklet_result = dict() for frame_index in range(track_len): print('////////////////////////////////////////') print('Processing {:} {:} / {:}'.format(id, frame_index + 1, track_len)) # initialize a tracker frame_data = next(data_loader) # if the first frame, add the start_bbox input_bbox = None if frame_index == 0: input_bbox = BBox.bbox2world(frame_data['ego'], BBox.array2bbox(start_bbox)) input_data = sot_3d.FrameData(ego_info=frame_data['ego'], pc=frame_data['pc'], start_bbox=input_bbox, terrain=frame_data['terrain'], dets=frame_data['dets']) # run the frame level tracking frame_output = tracker.track(input_data) # the frame 0 may produce no output if not frame_output: continue # if gt is not None, we may compare our prediction with gt frame_result = compare_to_gt(frame_index, frame_output, gts) max_frame_key = max(list(frame_result.keys())) for i in range(max_frame_key + 1): print('BBox0 : {:}'.format(frame_result[i]['bbox0'])) print('BBox1 : {:}'.format(frame_result[i]['bbox1'])) print('Motion : {:}'.format(frame_result[i]['motion'])) if gts: print('GT BBox0 : {:}'.format(frame_result[i]['gt_bbox0'])) print('GT BBox1 : {:}'.format(frame_result[i]['gt_bbox1'])) print('GT Motion: {:}'.format(frame_result[i]['gt_motion'])) print('IOUS : {:} {:}'.format(frame_result[i]['iou2d'], frame_result[i]['iou3d'])) print('\n') tracklet_result[frame_index + start_frame] = frame_result[max_frame_key] if visualize: frame_result_visualization(frame_result[max_frame_key], tracker.input_data.pc) return tracklet_result