Ejemplo n.º 1
0
def ExtractNpContent(np_dict, calib):
    """Parse saved np arrays and convert 3D bboxes to camera0 coordinates.

  Args:
    np_dict: a dict of numpy arrays.
    calib: a parsed calibration dictionary.

  Returns:
    A tuple of 6 ndarrays:

    - location_camera: [N, 3]. [x, y, z] in camera0 coordinate.
    - dimension_camera: [N, 3]. The [height, width, length] of objects.
    - phi_camera: [N]. Rotation around y-axis in camera0 coodinate.
    - bboxes_2d: [N, 4]. The corresponding 2D bboxes in the image coordinate.
    - scores: [N]. Confidence scores for each box for the assigned class.
    - class_ids: [N]. The class id assigned to each box.
  """
    bboxes = np_dict["bboxes"]
    scores = np_dict["scores"]
    class_ids = np_dict["class_ids"]
    bboxes_2d = np_dict["bboxes_2d"]

    # Transform from velodyne coordinates to camera coordinates.
    velo_to_cam_transform = kitti_data.VeloToCameraTransformation(calib)
    location_cam = np.zeros((len(bboxes), 3))
    dimension_cam = np.zeros((len(bboxes), 3))
    rotation_cam = np.zeros((len(bboxes), 1))
    for idx, bbox in enumerate(bboxes):
        location_cam[idx, :], dimension_cam[idx, :], rotation_cam[idx, :] = (
            kitti_data.BBox3DToKITTIObject(bbox, velo_to_cam_transform))

    return location_cam, dimension_cam, rotation_cam, bboxes_2d, scores, class_ids
Ejemplo n.º 2
0
 def testKITTIObjToBBoxAndInverse(self):
     objects = kitti_data.LoadLabelFile(self._label_file)
     calib = kitti_data.LoadCalibrationFile(self._calib_file)
     for obj in objects:
         bbox3d = kitti_data._KITTIObjectToBBox3D(
             obj, kitti_data.CameraToVeloTransformation(calib))
         location, dimensions, rotation_y = kitti_data.BBox3DToKITTIObject(
             bbox3d, kitti_data.VeloToCameraTransformation(calib))
         self.assertAllClose(obj['location'], location)
         self.assertAllClose(obj['dimensions'], dimensions)
         self.assertAllClose(obj['rotation_y'], rotation_y)