Plot the IStereoDepth output in various subplots. Plot depth, gtdepth, cov and mask as much as possible.
(output: IStereoDepth.Output, frame: StereoFrame)
| 219 | @register |
| 220 | @staticmethod |
| 221 | def plot_istereo(output: IStereoDepth.Output, frame: StereoFrame) -> Figure: |
| 222 | """Plot the IStereoDepth output in various subplots. Plot depth, gtdepth, cov and mask as much as possible. |
| 223 | """ |
| 224 | if frame.stereo.gt_depth is not None: |
| 225 | depth_err = (output.depth.detach().cpu() - frame.stereo.gt_depth).abs() |
| 226 | else: |
| 227 | depth_err = None |
| 228 | |
| 229 | plot_args = [ |
| 230 | # Row 1 |
| 231 | # Plot left camera |
| 232 | Plot.plot_image(frame.stereo.imageL.detach().cpu().permute(0, 2, 3, 1)[0]) |
| 233 | >> Plot.plot_no_border() |
| 234 | >> Chain.side_effect(lambda ax: ax.set_title(f"Frame {frame.frame_idx} L", loc="left")), |
| 235 | |
| 236 | # Plot right camera |
| 237 | Plot.plot_image(frame.stereo.imageR.detach().cpu().permute(0, 2, 3, 1)[0]) |
| 238 | >> Plot.plot_no_border() |
| 239 | >> Chain.side_effect(lambda ax: ax.set_title(f"Frame {frame.frame_idx} R", loc="left")), |
| 240 | |
| 241 | # Empty |
| 242 | None, |
| 243 | |
| 244 | # Row 2 |
| 245 | # Plot Predicted Depth |
| 246 | Plot.plot_scalarmap(output.depth.detach().cpu()[0, 0], colorbar=True) |
| 247 | >> Plot.plot_no_border() |
| 248 | >> Chain.side_effect(lambda ax: ax.set_title(f"Pred Depth", loc="left")), |
| 249 | |
| 250 | # Plot predicted cov |
| 251 | Plot.plot_scalarmap(None if output.cov is None else output.cov.sqrt().detach().cpu()[0, 0], colorbar=True) |
| 252 | >> Plot.plot_no_border() |
| 253 | >> Chain.side_effect(lambda ax: ax.set_title(f"Depth Cov (sqrt)", loc="left")), |
| 254 | |
| 255 | # Plot depth error |
| 256 | Plot.plot_scalarmap(None if depth_err is None else depth_err[0, 0].log10(), colorbar=True) |
| 257 | >> Plot.plot_no_border() |
| 258 | >> Chain.side_effect(lambda ax: ax.set_title("Depth Err (log)", loc="left")), |
| 259 | |
| 260 | # Row 3 |
| 261 | # Plot gt Depth |
| 262 | Plot.plot_scalarmap(None if frame.stereo.gt_depth is None else frame.stereo.gt_depth.detach().cpu()[0, 0], colorbar=True) |
| 263 | >> Plot.plot_no_border() |
| 264 | >> Chain.side_effect(lambda ax: ax.set_title(f"GT Depth", loc="left")), |
| 265 | |
| 266 | # Plot predicted cov (pred mask) |
| 267 | Plot.plot_scalarmap(None if output.cov is None else output.cov.sqrt().detach().cpu()[0, 0], colorbar=True) |
| 268 | >> Plot.plot_mask(None if output.mask is None else output.mask[0, 0].detach().cpu()) |
| 269 | >> Plot.plot_no_border() |
| 270 | >> Chain.side_effect(lambda ax: ax.set_title(f"Depth Cov (sqrt, Pred Mask)", loc="left")), |
| 271 | |
| 272 | # Plot depth error (pred mask) |
| 273 | Plot.plot_scalarmap(None if depth_err is None else depth_err[0, 0].log10(), colorbar=True) |
| 274 | >> Plot.plot_mask(None if output.mask is None else output.mask[0, 0].detach().cpu()) |
| 275 | >> Plot.plot_no_border() |
| 276 | >> Chain.side_effect(lambda ax: ax.set_title("Depth Err (log, Pred Mask)", loc="left")), |
| 277 | ] |
| 278 |
no test coverage detected