Closed xiaoxTM closed 2 years ago
Hey @xiaoxTM, could you please attach the relevant codes you use for reading and conversion?
Hi,
I cam accros the same problem. Here the relevant code:
with open(gt_name, 'rb') as f: gt = (Image.open(f).convert('RGB')) depth_png = np.array(gt, dtype=int) depth = (256 256 depth_png[:,:,0] + 256 * depth_png[:,:,1] + depth_png[:,:,2]) / 1000
Thanks
Hi, @xiaoxTM and @amitshomer! Thanks for telling us about this issue. Apparently, the description on the webpage is outdated. We will update it asap. Below is the code for reading depth,
DEPTH_C = np.array(1000.0 / (256 * 256 * 256 - 1), np.float32)
depth = (256 * 256 * img[:, :, 2] + 256 * img[:, :, 1] + img[:, :, 0]) * DEPTH_C # in meters
for anyone stuck with this issue, please choose either of the two:
img = PIL.Image.open(img_path)
, or:img = cv2.imread(img_path)
, then img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
afterwards, img = np.array(img, dtype=int)
then you can use the calculation provided by @suniique and you will get the correct result
Hi, all: I noticed that the depth convertion formula is Depth (meters) = (256 256 R + 256 * G + B) / 1000. according to the description here however, I plot the depth image and found that the depth is not correct: the value goes up and down in the depth direction. Did the formula changed or did I missed something somewhere ?
Thanks