| 416 | |
| 417 | |
| 418 | def project_points(points_3d, intrinsics, extrinsics): |
| 419 | # Convert to homogeneous coordinates |
| 420 | points_3d_homogeneous = np.hstack((points_3d, np.ones((points_3d.shape[0], 1)))) |
| 421 | |
| 422 | # Apply extrinsic matrix |
| 423 | points_camera = np.dot(extrinsics, points_3d_homogeneous.T).T |
| 424 | |
| 425 | # Apply intrinsic matrix |
| 426 | points_2d_homogeneous = np.dot(intrinsics, points_camera[:, :3].T).T |
| 427 | |
| 428 | # Convert to 2D coordinates |
| 429 | points_2d = points_2d_homogeneous[:, :2] / points_2d_homogeneous[:, 2:] |
| 430 | depths = points_camera[:, 2] |
| 431 | |
| 432 | return points_2d, depths |
| 433 | |
| 434 | def read_colmap_gt_pose(gt_pose_path, llffhold=8): |
| 435 | colmap_cam_extrinsics = read_extrinsics_binary(gt_pose_path + '/sparse/0/images.bin') |