def main(): gt_root_folder = '/dataset/kitti_format/waymo/training/' cam_idx = 0 thresh = 5 lidar_dtype = float gt_label_folder = os.path.join(gt_root_folder, 'label_{}/'.format(cam_idx)) gt_lidar_folder = os.path.join(gt_root_folder, 'velodyne/') gt_calib_folder = os.path.join(gt_root_folder, 'calib/') new_label_folder = os.path.join(gt_root_folder, 'label_filtered_{}/'.format(cam_idx)) os.makedirs(new_label_folder, exist_ok=True) label_names = [ f.name.split('.')[0] for f in os.scandir(gt_label_folder) if f.is_file() and f.name.endswith('.txt') ] for sample_name in tqdm.tqdm(label_names): calib_filename = os.path.join(gt_calib_folder, sample_name + '.txt') gt_filename = os.path.join(gt_label_folder, sample_name + '.txt') lidar_filename = os.path.join(gt_lidar_folder, sample_name + '.bin') lidar_scan = utils.load_velo_scan(lidar_filename, dtype=lidar_dtype) calib = utils.Calibration(calib_filename, cam_idx=cam_idx) objects_gt = utils.read_label(gt_filename) filtered_objects = filter_boxes_kitti(objects_gt, lidar_scan, calib, thresh=thresh) writepath = os.path.join(new_label_folder, sample_name + '.txt') # print(f"Before filtering: {len(objects_gt)}, after filtering {len(filtered_objects)}") with open(writepath, 'w') as f: for obj in filtered_objects: f.write(obj.get_string_ann() + '\n')
def get_lidar(self, idx): assert (idx < self.num_samples) lidar_filename = os.path.join(self.lidar_dir, '%06d.bin' % (idx)) return utils.load_velo_scan(lidar_filename)
def get_lidar(self, idx): assert (idx < self.num_samples) lidar_filename = self.lidar_filenames[idx] return utils.load_velo_scan(lidar_filename)