MCPcopy Create free account
hub / github.com/CUT3R/CUT3R / writeDispFile

Function writeDispFile

datasets_preprocess/flow_IO.py:432–455  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

430
431
432def 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
458def readKITTIObjMap(filepath):

Callers

nothing calls this directly

Calls 4

writePngDispFunction · 0.85
writeNpyFileFunction · 0.85
writeDsp5FileFunction · 0.70
printFunction · 0.50

Tested by

no test coverage detected