fabiotosi92 / NeRF-Supervised-Deep-Stereo

A novel paradigm for collecting and generating stereo training data using neural rendering
https://nerfstereo.github.io/
MIT License
348 stars 19 forks source link

About instant-ngp depth #43

Closed Miaowei-HNU closed 8 months ago

Miaowei-HNU commented 9 months ago

Hi,Can you provide me with the code snippet to capture the depth, I'm having trouble with instant-ngp! help @fabiotosi92

fabiotosi92 commented 9 months ago

Hi! In the original code of Instant-Ngp, you simply need to set testbed.render_mode to ngp.Depth.

Miaowei-HNU commented 9 months ago

Hi! In the original code of Instant-Ngp, you simply need to set testbed.render_mode to ngp.Depth.

image I did it in the same way, but I got an all-white image.

fabiotosi92 commented 9 months ago

Are you saving it as np.uint16? I believe the issue might be related to how you are saving the image.

Miaowei-HNU commented 9 months ago

Are you saving it as np.uint16? I believe the issue might be related to how you are saving the image.

I know the way to save the image so I saved the IMAGE(np float32 WH4) to see the exact value . image I don't know how to calculate depth from these values

fabiotosi92 commented 9 months ago

Try to visualize it using matplotlib. Let me know

Miaowei-HNU commented 9 months ago

Try to visualize it using matplotlib. Let me know image

Here's my saved RGB image, the depth map is still all white, I'm curious how the depth is getting parsed out from 'image (H,W,4)'.

fabiotosi92 commented 9 months ago

Consider to use the first channel -> depth[:,:,0]

Miaowei-HNU commented 9 months ago

Consider to use the first channel -> depth[:,:,0]

image It still doesn't feel right. Do you remember how you handled it?

fabiotosi92 commented 9 months ago
disparity = focal* args.baseline / image
disparity[np.isinf(disparity)] = 0
disparity[np.isnan(disparity)] = 0
plt.imsave(outname, disparity[:,:,0], cmap="magma")
Miaowei-HNU commented 9 months ago
disparity = focal* args.baseline / image
disparity[np.isinf(disparity)] = 0
disparity[np.isnan(disparity)] = 0
plt.imsave(outname, disparity[:,:,0], cmap="magma")

Oh, have you try to visualize the depth map, I'm using dataset0000, I'll try to visualize the disparity map.

Miaowei-HNU commented 9 months ago
disparity = focal* args.baseline / image
disparity[np.isinf(disparity)] = 0
disparity[np.isnan(disparity)] = 0
plt.imsave(outname, disparity[:,:,0], cmap="magma")

image I got the disparity map as you provided, but with the first dimension of the image (np) not representing the depth directly

3x5c2 commented 9 months ago

hi @Miaowei-HNU ,also i am troubled in capture the depth can u show me the code