예제 #1
0
def _load_frame_and_sensor(
    segment: FusionSegment,
    annotation_info: Dict[str, Any],
    subset_path: str,
    is_test: bool,
) -> None:
    frame = Frame()
    for data_frames in annotation_info["frame_data"].values():
        for data_frame in data_frames:
            calibrated_sensor_info = annotation_info["calibrated_sensors"][
                data_frame["calibrated_sensor_token"]]
            common_sensor = annotation_info["sensor"][
                calibrated_sensor_info["sensor_token"]]
            sensor_name = common_sensor["channel"]

            if sensor_name not in segment.sensors:
                segment.sensors.add(
                    get_sensor("camera", sensor_name, calibrated_sensor_info))

            data = Data(
                os.path.join(subset_path, data_frame["filename"]),
                timestamp=data_frame["timestamp"] / 10**6,
            )

            if not is_test:
                data.label.box2d, data.label.rle = _get_labels(
                    data_frame["token"], annotation_info)

            frame[sensor_name] = data
        segment.append(frame)
예제 #2
0
def _load_frame_and_sensor(
    segment: FusionSegment,
    current_frame_token: str,
    annotation_info: Dict[str, Any],
    subset_path: str,
    is_test: bool,
) -> None:
    frame = Frame()
    for sensor_frame in annotation_info["frame_data"][current_frame_token]:
        calibrated_sensor_info = annotation_info["calibrated_sensors"][
            sensor_frame["calibrated_sensor_token"]
        ]
        common_sensor = annotation_info["sensor"][calibrated_sensor_info["sensor_token"]]
        sensor_name = common_sensor["channel"]
        sensor_type = common_sensor["modality"]

        if sensor_name not in segment.sensors:
            segment.sensors.add(get_sensor(sensor_type, sensor_name, calibrated_sensor_info))

        data = Data(
            os.path.join(subset_path, sensor_frame["filename"]),
            timestamp=sensor_frame["timestamp"] / 10**6,
        )

        if not is_test and sensor_type == "lidar":
            data.label.box3d = _get_labels(
                current_frame_token,
                annotation_info["ego_poses"][sensor_frame["ego_pose_token"]],
                segment.sensors[sensor_name].extrinsics,
                annotation_info,
            )

        frame[sensor_name] = data
    segment.append(frame)