Created
October 30, 2023 17:27
-
-
Save adujardin/dcb03708505989ab6424e3113bb7111c to your computer and use it in GitHub Desktop.
Simple conversion function to get precise disparity from depth data from NewTsukubaStereoDataset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
calib_fx=615 | |
calib_baseline=10 | |
def depth_to_disp(depth_filename, disp_filename): | |
cv_file = cv2.FileStorage(depth_filename, cv2.FILE_STORAGE_READ) | |
matrix = cv_file.getNode("depth").mat() | |
cv_file.release() | |
f = 1/float(calib_baseline*calib_fx) | |
disp = (matrix*f).astype(np.float32) | |
cv2.imwrite(disp_filename, disp) | |
depth_filename="NewTsukubaStereoDataset/groundtruth/depth_maps/left/tsukuba_depth_L_00011.xml" | |
disp_filename="tsukuba_disparity_L_00011.exr" | |
depth_to_disp(depth_filename, disp_filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment