(results, output_dir, img_path, model_name)
| 41 | |
| 42 | # 数据后处理函数 |
| 43 | def postprocess(results, output_dir, img_path, model_name): |
| 44 | # 检查输出目录 |
| 45 | if not os.path.exists(output_dir): |
| 46 | os.mkdir(output_dir) |
| 47 | |
| 48 | # 读取输入图像 |
| 49 | img = cv2.imread(img_path) |
| 50 | h, w = img.shape[:2] |
| 51 | |
| 52 | # 缩放回原尺寸 |
| 53 | output = cv2.resize(results[0], (w, h), interpolation=cv2.INTER_CUBIC) |
| 54 | |
| 55 | # 可视化输出 |
| 56 | pfm_f, png_f = write_depth(os.path.join(output_dir, model_name), output, bits=2) |