write disparity to file. Supports png (KITTI) and npy (numpy) file format. disp: disparity with shape height x width. Invalid values should be represented as np.nan filepath: file path where to write the flow
(disp, filepath)
| 430 | |
| 431 | |
| 432 | def writeDispFile(disp, filepath): |
| 433 | """write disparity to file. Supports png (KITTI) and npy (numpy) file format. |
| 434 | disp: disparity with shape height x width. Invalid values should be represented as np.nan |
| 435 | filepath: file path where to write the flow |
| 436 | """ |
| 437 | if not filepath: |
| 438 | raise ValueError("writeDispFile: empty filepath") |
| 439 | |
| 440 | if len(disp.shape) != 2: |
| 441 | raise IOError( |
| 442 | f"writeDispFile {filepath}: expected shape height x width but received {disp.shape}" |
| 443 | ) |
| 444 | |
| 445 | if disp.shape[0] > disp.shape[1]: |
| 446 | print( |
| 447 | f"writeDispFile {filepath}: Warning: Are you writing an upright image? Expected shape height x width, got {disp.shape}" |
| 448 | ) |
| 449 | |
| 450 | if filepath.endswith(".png"): |
| 451 | writePngDisp(disp, filepath) |
| 452 | elif filepath.endswith(".npy"): |
| 453 | writeNpyFile(disp, filepath) |
| 454 | elif filepath.endswith(".dsp5"): |
| 455 | writeDsp5File(disp, filepath) |
| 456 | |
| 457 | |
| 458 | def readKITTIObjMap(filepath): |
nothing calls this directly
no test coverage detected