Depth map changes if object is close to camera (unity)

Hello,

I’ve been using unity to display the depthmap from the camera to a RenderTexture.

I’m using //depthTexture = zed.CreateTextureImageType(sl.VIEW.DEPTH); to retrieve the texture from the camera, which I then Blit into a render texture.

However what I noticed is that the gray values shift quite drammatically if one object is really close to the camera (e.g. passing the hand close to the camera), almost like if it’s automatically adjusting the range.

The documentation says:

To display the depth map, we scale its values to [0, 255], where 255 (white) represents the closest possible depth value and 0 (black) represents the most distant possible depth value.
Blockquote

so I assumed that such and auto-adjustment shouldn’t happen.

What am I missing? How can I get a stable depth image?

Thanks!

Hi,

This texture is only made for display, and should not be used to get precise value of depth (see https://www.stereolabs.com/docs/api/group__Video__group.html#ga77fc7bfc159040a1e2ffb074a8ad248c).

To get precise values of depth, you should use “CreateTextureMeasureType” instead.

Stereolabs Support