Computes rotational and translational absolute pose errors. Assumes that the input reconstructions are aligned in the same coordinate system. Computes one error per ground-truth image.
(
sparse_gt: pycolmap.Reconstruction, sparse: pycolmap.Reconstruction
)
| 1090 | |
| 1091 | |
| 1092 | def compute_abs_errors( |
| 1093 | sparse_gt: pycolmap.Reconstruction, sparse: pycolmap.Reconstruction |
| 1094 | ) -> tuple[npt.NDArray[np.floating], npt.NDArray[np.floating]]: |
| 1095 | """Computes rotational and translational absolute pose errors. |
| 1096 | |
| 1097 | Assumes that the input reconstructions are aligned in the same coordinate |
| 1098 | system. Computes one error per ground-truth image. |
| 1099 | """ |
| 1100 | |
| 1101 | dts = np.full(len(sparse_gt.images), fill_value=np.inf, dtype=np.float64) |
| 1102 | dRs = np.full(len(sparse_gt.images), fill_value=180, dtype=np.float64) |
| 1103 | |
| 1104 | if sparse is None: |
| 1105 | pycolmap.logging.error("Reconstruction or alignment failed") |
| 1106 | return dts, dRs |
| 1107 | |
| 1108 | images = {} |
| 1109 | for image in sparse.images.values(): |
| 1110 | images[image.name] = image |
| 1111 | |
| 1112 | dts = np.full(len(sparse_gt.images), fill_value=np.inf, dtype=np.float64) |
| 1113 | dRs = np.full(len(sparse_gt.images), fill_value=180, dtype=np.float64) |
| 1114 | for i, image_gt in enumerate(sparse_gt.images.values()): |
| 1115 | if image_gt.name not in images: |
| 1116 | continue |
| 1117 | |
| 1118 | image = images[image_gt.name] |
| 1119 | |
| 1120 | estimated_from_gt = ( |
| 1121 | image.cam_from_world() * image_gt.cam_from_world().inverse() |
| 1122 | ) |
| 1123 | |
| 1124 | dts[i] = np.linalg.norm(estimated_from_gt.translation) |
| 1125 | dRs[i] = np.rad2deg(estimated_from_gt.rotation.angle()) |
| 1126 | |
| 1127 | return dts, dRs |
| 1128 | |
| 1129 | |
| 1130 | def compute_auc( |
no outgoing calls