diff --git a/src/config/kitti_config.py b/src/config/kitti_config.py index 4f7dcc3..7a216c7 100644 --- a/src/config/kitti_config.py +++ b/src/config/kitti_config.py @@ -33,7 +33,8 @@ BEV_WIDTH = 608 # across y axis -25m ~ 25m BEV_HEIGHT = 608 # across x axis 0m ~ 50m -DISCRETIZATION = (boundary["maxX"] - boundary["minX"]) / BEV_HEIGHT +DISCRETIZATION_X = (boundary["maxX"] - boundary["minX"]) / BEV_HEIGHT +DISCRETIZATION_Y = (boundary["maxY"] - boundary["minY"]) / BEV_WIDTH colors = [[0, 255, 255], [0, 0, 255], [255, 0, 0]] diff --git a/src/data_process/kitti_bev_utils.py b/src/data_process/kitti_bev_utils.py index 1585400..8ec41d6 100644 --- a/src/data_process/kitti_bev_utils.py +++ b/src/data_process/kitti_bev_utils.py @@ -34,14 +34,18 @@ def removePoints(PointCloud, BoundaryCond): return PointCloud -def makeBVFeature(PointCloud_, Discretization, bc): +def makeBVFeature(PointCloud_, Discretization_X, Discretization_Y, bc): Height = cnf.BEV_HEIGHT + 1 Width = cnf.BEV_WIDTH + 1 # Discretize Feature Map PointCloud = np.copy(PointCloud_) - PointCloud[:, 0] = np.int_(np.floor(PointCloud[:, 0] / Discretization)) - PointCloud[:, 1] = np.int_(np.floor(PointCloud[:, 1] / Discretization) + Width / 2) + + offset_x = np.int_(np.floor(bc['minX'] / Discretization_X)) + offset_y = np.int_(np.floor(bc['minY'] / Discretization_Y)) + + PointCloud[:, 0] = np.int_(np.floor(PointCloud[:, 0] / Discretization_X)) - offset_x + PointCloud[:, 1] = np.int_(np.floor(PointCloud[:, 1] / Discretization_Y)) - offset_y # sort-3times indices = np.lexsort((-PointCloud[:, 2], PointCloud[:, 1], PointCloud[:, 0])) diff --git a/src/data_process/kitti_dataset.py b/src/data_process/kitti_dataset.py index 218ea1c..8debed2 100644 --- a/src/data_process/kitti_dataset.py +++ b/src/data_process/kitti_dataset.py @@ -79,7 +79,7 @@ def load_img_only(self, index): sample_id = int(self.sample_id_list[index]) lidarData = self.get_lidar(sample_id) b = kitti_bev_utils.removePoints(lidarData, cnf.boundary) - rgb_map = kitti_bev_utils.makeBVFeature(b, cnf.DISCRETIZATION, cnf.boundary) + rgb_map = kitti_bev_utils.makeBVFeature(b, cnf.DISCRETIZATION_X, cnf.DISCRETIZATION_Y, cnf.boundary) img_file = os.path.join(self.image_dir, '{:06d}.png'.format(sample_id)) return img_file, rgb_map @@ -103,7 +103,7 @@ def load_img_with_targets(self, index): lidarData, labels[:, 1:] = self.lidar_transforms(lidarData, labels[:, 1:]) b = kitti_bev_utils.removePoints(lidarData, cnf.boundary) - rgb_map = kitti_bev_utils.makeBVFeature(b, cnf.DISCRETIZATION, cnf.boundary) + rgb_map = kitti_bev_utils.makeBVFeature(b, cnf.DISCRETIZATION_X, cnf.DISCRETIZATION_Y, cnf.boundary) target = kitti_bev_utils.build_yolo_target(labels) img_file = os.path.join(self.image_dir, '{:06d}.png'.format(sample_id))