Ejemplo n.º 1
0
 def read_data(self):
     '''
     read data
     returns:
         calib(CarlaCalib)
         label(CarlaLabel)
         pc(dict):
             point cloud in Lidar <tag> frame.
             pc[tag] = np.array [#pts, 3], tag is the name of the dir saving velodynes
     '''
     calib = WaymoCalib(self.calib_path).read_calib_file() if self.output_dict["calib"] else None
     label = WaymoLabel(self.label_path).read_label_file() if self.output_dict["label"] else None
     if self.output_dict["velodyne"]:
         pc = dict()
         for k, v in zip(self.velodyne_list, self.velodyne_paths):
             assert k == v.split('/')[-2]
             pc[k] = utils.read_pc_from_npy(v)
     else:
         pc = None
     return pc, label, calib
Ejemplo n.º 2
0
    def test_rot_obj(self):
        pc = read_pc_from_npy("./unit-test/data/test_CarlaAugmentor_000250.npy")
        calib = CarlaCalib("./unit-test/data/test_CarlaAugmentor_000250_calib.txt").read_calib_file()
        label = CarlaLabel("./unit-test/data/test_CarlaAugmentor_000250_label_imu.txt").read_label_file()
        pc = calib.lidar2imu(pc, key='Tr_imu_to_velo_top')
        bevimg = BEVImage(x_range=(0, 70), y_range=(-40, 40), grid_size=(0.05, 0.05))
        bevimg.from_lidar(pc, scale=1)
        for obj in label.data:
            bevimg.draw_box(obj, calib, bool_gt=True)
        bevimg_img = Image.fromarray(bevimg.data)
        bevimg_img.save(os.path.join('./unit-test/result/', 'test_CarlaAugmentor_rotobj_origin.png'))

        carla_agmtor = CarlaAugmentor()
        label, pc = carla_agmtor.rotate_obj(label, pc, calib, [-30/180.0 * np.pi, 30/180.0 * np.pi])
        bevimg = BEVImage(x_range=(0, 70), y_range=(-40, 40), grid_size=(0.05, 0.05))
        bevimg.from_lidar(pc, scale=1)
        for obj in label.data:
            bevimg.draw_box(obj, calib, bool_gt=True)
        bevimg_img = Image.fromarray(bevimg.data)
        bevimg_img.save(os.path.join('./unit-test/result/', 'test_CarlaAugmentor_rotobj_result.png'))
        print(bcolors.WARNING + "Warning: TestCarlaAugmentor:test_rot_obj: You should check the function manully.:)"+ bcolors.ENDC)
        print(bcolors.WARNING + os.path.join('Warning: TestCarlaAugmentor:test_rot_obj:   ./unit-test/result/', 'test_CarlaAugmentor_rotobj_origin.png') + bcolors.ENDC)
        print(bcolors.WARNING + os.path.join('Warning: TestCarlaAugmentor:test_rot_obj:   ./unit-test/result/', 'test_CarlaAugmentor_rotobj_result.png') + bcolors.ENDC)