Load KITTI Odometry scene data (镜像 KittiOdometryReader)。 Layout: {data_root}/sequences/{scene_path}/image_2/{XXXXXX}.png — 左彩色 rectified RGB {data_root}/sequences/{scene_path}/calib.txt — P0 P1 P2 P3 Tr {data_root}/poses/{scene_path}.txt —
(data_root: Path, scene_path: str, frame_indices: list)
| 1066 | |
| 1067 | |
| 1068 | def _load_kitti_odometry(data_root: Path, scene_path: str, frame_indices: list): |
| 1069 | """Load KITTI Odometry scene data (镜像 KittiOdometryReader)。 |
| 1070 | |
| 1071 | Layout: |
| 1072 | {data_root}/sequences/{scene_path}/image_2/{XXXXXX}.png — 左彩色 rectified RGB |
| 1073 | {data_root}/sequences/{scene_path}/calib.txt — P0 P1 P2 P3 Tr |
| 1074 | {data_root}/poses/{scene_path}.txt — 3×4 c2w per frame (仅 00-10 有) |
| 1075 | |
| 1076 | KITTI Odometry 无稠密深度 GT,depth 以零填充, |
| 1077 | 点云接口会返回空(_unproject_frame 用 depth>0.01 过滤), |
| 1078 | 前端仍可用相机锥 + RGB + 轨迹查看。 |
| 1079 | """ |
| 1080 | seq_dir = data_root / "sequences" / scene_path |
| 1081 | rgb_dir = seq_dir / "image_2" |
| 1082 | calib_path = seq_dir / "calib.txt" |
| 1083 | poses_path = data_root / "poses" / f"{scene_path}.txt" |
| 1084 | |
| 1085 | rgb_paths = sorted(rgb_dir.glob("*.png"), key=lambda p: int(p.stem)) |
| 1086 | |
| 1087 | # 内参: 取 P2 的左上 3x3 (KITTI Odometry 左 rectified 相机) |
| 1088 | calib = _parse_kitti_calib(calib_path) if calib_path.is_file() else {} |
| 1089 | P2 = calib.get('P2') |
| 1090 | K = P2[:3, :3].astype(np.float32).copy() if P2 is not None else np.eye(3, dtype=np.float32) |
| 1091 | |
| 1092 | all_poses = _parse_kitti_poses(poses_path) |
| 1093 | |
| 1094 | images, depths, extrinsics = [], [], [] |
| 1095 | for idx in frame_indices: |
| 1096 | if idx >= len(rgb_paths): |
| 1097 | continue |
| 1098 | |
| 1099 | img = cv2.imread(str(rgb_paths[idx])) |
| 1100 | if img is not None: |
| 1101 | img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) |
| 1102 | else: |
| 1103 | img = np.zeros((375, 1242, 3), dtype=np.uint8) |
| 1104 | |
| 1105 | # 无深度 GT:零深度占位 |
| 1106 | H, W = img.shape[:2] |
| 1107 | depth = np.zeros((H, W), dtype=np.float32) |
| 1108 | |
| 1109 | # 位姿: c2w (3×4),若缺失 (test 序列 11-21 或文件缺失) 则回退单位阵 |
| 1110 | if idx < len(all_poses): |
| 1111 | pose = all_poses[idx].astype(np.float32) |
| 1112 | else: |
| 1113 | pose = np.eye(4, dtype=np.float32)[:3, :] |
| 1114 | |
| 1115 | images.append(img) |
| 1116 | depths.append(depth) |
| 1117 | extrinsics.append(pose) |
| 1118 | |
| 1119 | return { |
| 1120 | "images": images, "depths": depths, |
| 1121 | "extrinsics": extrinsics, "K": K, |
| 1122 | } |
| 1123 | |
| 1124 | |
| 1125 | def _load_waymo(scene_dir: Path, frame_indices: list, z_far: float, use_depth_mask: bool = True): |
nothing calls this directly
no test coverage detected