Camara cannot captured valid depth maps with python api?

When I use python code to capture the depth image, the depth image shown using opencv is as follows
(upload://py3lc8fMDl3nGESI7trrKgqskyB.png)
But the depth image saved with the code is as follows
(upload://vKWAwAimxhN5dQO1ns8PCU1bT1D.png)
The array of depth images is as follows
‘depth’: array([[ nan, nan, nan, …, 28.595, 28.603, 28.603],
[ nan, nan, nan, …, nan, nan, nan],
[ nan, nan, nan, …, nan, nan, nan],
…,
[ nan, nan, nan, …, 1.3295, 1.3295, 1.3297],
[ nan, nan, nan, …, 1.3327, 1.3328, 1.3347],
[ nan, nan, nan, …, 1.3333, 1.3347, 1.3349]], dtype=float32)
Why is this a problem, is it a problem with my depth image capture?
Here’s my code:
def main():
global image_net, exit_signal, run_signal, detections
capture_thread = Thread(target=torch_thread,
kwargs={‘weights’: opts.weights, ‘img_size’: opts.img_size, “conf_thres”: opts.conf_thres})
capture_thread.start()

print("Initializing Camera...")
zed = sl.Camera()
input_type = sl.InputType()
if opts.svo is not None:
    input_type.set_from_svo_file(opts.svo)
    cv2.imwrite('./visualization/my_new_depth.png', depth_frame)
    cv2.imshow('depth',depth_frame)

This is the picture mentioned above


Hi @XueFu,

The depth image you have saved seems correct. The nan values correspond with the values for which the depth data isn’t computed because of stereo occlusion, the depth value is infinity, or the value is filtered by the confidence threshold. This is expected behavior, and corresponds with the black values on your first image.

The difference between the first and the second image is that the first one has been normalized between 0 and 255 values, whereas the depth images saves the actual depth values, which are not converted into pixel grayscale values.

If you normalize the image between the 0-255 range, you should find similar results.