Return list of (filename, mae, ok) per depth_XXXX.npy pair.
(ref_dir: Path, cand_dir: Path)
| 126 | |
| 127 | |
| 128 | def depth_mae(ref_dir: Path, cand_dir: Path): |
| 129 | """Return list of (filename, mae, ok) per depth_XXXX.npy pair.""" |
| 130 | out = [] |
| 131 | ref_files = sorted((ref_dir / "depth").glob("depth_*.npy")) |
| 132 | cand_dir_depth = cand_dir / "depth" |
| 133 | for rf in ref_files: |
| 134 | cf = cand_dir_depth / rf.name |
| 135 | if not cf.exists(): |
| 136 | out.append((rf.name, None, False)) |
| 137 | continue |
| 138 | a = np.load(rf).astype(np.float64) |
| 139 | b = np.load(cf).astype(np.float64) |
| 140 | if a.shape != b.shape: |
| 141 | out.append((rf.name, float("nan"), False)) |
| 142 | continue |
| 143 | # Ignore NaNs symmetrically. |
| 144 | mask = np.isfinite(a) & np.isfinite(b) |
| 145 | if not mask.any(): |
| 146 | out.append((rf.name, 0.0, True)) |
| 147 | continue |
| 148 | mae = float(np.mean(np.abs(a[mask] - b[mask]))) |
| 149 | out.append((rf.name, mae, mae < MAE_THRESHOLD)) |
| 150 | return out |
| 151 | |
| 152 | |
| 153 | def png_u8_mae(ref_dir: Path, cand_dir: Path, subdir: str, prefix: str): |