def getPCandBBfromPandas(self, box, calib): #求出车辆的中心点 从此处的中心点是根据KITTI中相机坐标系下的中心点 # 减去一半的高度移到地面上 center = [box["x"], box["y"] - box["height"] / 2, box["z"]] size = [box["width"], box["length"], box["height"]] #下面这个函数没有完全看明白 应该是将roy角转换成四元数吧 orientation = Quaternion(axis=[0, 1, 0], radians=box["rotation_y"]) * Quaternion( axis=[1, 0, 0], radians=np.pi / 2) BB = Box(center, size, orientation) #用中心点坐标和w,h,l以及旋转角来初始化BOX这个类 State = True try: # VELODYNE PointCloud velodyne_path = os.path.join( self.KITTI_velo, box["scene"], '%06d.bin' % (box["frame"])) #f'{box["frame"]:06}.bin') #从点云的.bin文件中读取点云数据并且转换为4*x的矩阵,且去掉最后的一行的点云的密度表示数据 PC = PointCloud( np.fromfile(velodyne_path, dtype=np.float32).reshape(-1, 4).T) #将点云转换到相机坐标系下 因为label中的坐标和h,w,l在相机坐标系下的 PC.transform(calib) except FileNotFoundError: # logging.error("No such file found\n%s\n", velodyne_path) PC = PointCloud(np.array([[0, 0, 0]]).T) State = False return PC, BB, State
def getPCandBBfromPandas(self, box, calib): center = [box["x"], box["y"] - box["height"] / 2, box["z"]] size = [box["width"], box["length"], box["height"]] orientation = Quaternion( axis=[0, 1, 0], radians=box["rotation_y"]) * Quaternion( axis=[1, 0, 0], radians=np.pi / 2) # 这波啊,这波是X-Y平面的旋转 # 绕Y正半轴逆时针旋转,弧度为box["rotation_y"] # 再绕X正半轴逆时针旋转,角度为90° BB = Box(center, size, orientation) try: # VELODYNE PointCloud velodyne_path = os.path.join(self.KITTI_velo, box["scene"], '{:06}.bin'.format(box["frame"])) # ./data/traning/velodyne/box["scene"]/box["frame"].bin # box["scene"],例如0020文件夹,对应第二十一个场景序列 # box["frame"].bin,例如000001.bin PC = PointCloud( np.fromfile(velodyne_path, dtype=np.float32).reshape(-1, 4).T) PC.transform(calib) # 校准 except: # in case the Point cloud is missing # (0001/[000177-000180].bin) 果然没了 PC = PointCloud(np.array([[0, 0, 0]]).T) return PC, BB
def getPCandBBfromPandas(self, box, calib): center = [box["x"], box["y"] - box["height"] / 2, box["z"]] size = [box["width"], box["length"], box["height"]] orientation = Quaternion( axis=[0, 1, 0], radians=box["rotation_y"]) * Quaternion( axis=[1, 0, 0], radians=np.pi / 2) BB = Box(center, size, orientation) try: # VELODYNE PointCloud velodyne_path = os.path.join(self.KITTI_velo, box["scene"], f'{box["frame"]:06}.bin') PC = PointCloud( np.fromfile(velodyne_path, dtype=np.float32).reshape(-1, 4).T) PC.transform(calib) except FileNotFoundError: # in case the Point cloud is missing # (0001/[000177-000180].bin) PC = PointCloud(np.array([[0, 0, 0]]).T) return PC, BB