(camera_poses, colors, save_path="/mnt/data/1.png")
| 206 | |
| 207 | |
| 208 | def visualizer(camera_poses, colors, save_path="/mnt/data/1.png"): |
| 209 | fig = plt.figure() |
| 210 | ax = fig.add_subplot(111, projection="3d") |
| 211 | |
| 212 | for pose, color in zip(camera_poses, colors): |
| 213 | rotation = pose[:3, :3] |
| 214 | translation = pose[:3, 3] # Corrected to use 3D translation component |
| 215 | camera_positions = np.einsum( |
| 216 | "...ij,...j->...i", np.linalg.inv(rotation), -translation |
| 217 | ) |
| 218 | |
| 219 | ax.scatter( |
| 220 | camera_positions[0], |
| 221 | camera_positions[1], |
| 222 | camera_positions[2], |
| 223 | c=color, |
| 224 | marker="o", |
| 225 | ) |
| 226 | |
| 227 | ax.set_xlabel("X") |
| 228 | ax.set_ylabel("Y") |
| 229 | ax.set_zlabel("Z") |
| 230 | ax.set_title("Camera Poses") |
| 231 | |
| 232 | plt.savefig(save_path) |
| 233 | plt.close() |
| 234 | |
| 235 | return save_path |
no outgoing calls
no test coverage detected