stereolabs / zed-sdk

⚡️The spatial perception framework for rapidly building smart robots and spaces
https://stereolabs.com
MIT License
783 stars 456 forks source link

Completely Nan #292

Closed Saumya-Shah closed 3 years ago

Saumya-Shah commented 3 years ago

Hi, I have a Zed2. Using the Python API, retrieving depth or the point cloud gives an array of all NANs. Below are the settings I am using. I can see a lot of black pixels in the depth viewer but there are non-black pixels too. But using the retrieving code, I get all Nans. Please help.

import pyzed.sl as sl
import time
import numpy as np

zed = sl.Camera()

init_params = sl.InitParameters()
init_params.depth_mode = sl.DEPTH_MODE.ULTRA # Use ULTRA depth mode
init_params.coordinate_units = sl.UNIT.MILLIMETER

err = zed.open(init_params)
if err != sl.ERROR_CODE.SUCCESS:
    print("Camera not found")
    exit(1)

runtime_parameters = sl.RuntimeParameters()
runtime_parameters.sensing_mode = sl.SENSING_MODE.STANDARD  # Use STANDARD sensing mode
# runtime_parameters.sensing_mode = sl.SENSING_MODE.FILL
# Setting the depth confidence parameters
# runtime_parameters.confidence_threshold = 0
# runtime_parameters.textureness_confidence_threshold = 0

image = sl.Mat()
depth = sl.Mat()

zed.retrieve_image(image, sl.VIEW.LEFT)
# Retrieve depth map. Depth is aligned on the left image
depth_status = zed.retrieve_measure(depth, sl.MEASURE.DEPTH)
point_cloud = sl.Mat()
pc_status = zed.retrieve_measure(point_cloud, sl.MEASURE.XYZRGBA)
print(pc_status)
zed.close()
obraun-sl commented 3 years ago

Hi, You need to call the grab() function before retrieving images. Make sure the grab() call return success. See here : https://github.com/stereolabs/zed-examples/blob/master/tutorials/tutorial%203%20-%20depth%20sensing/python/depth_sensing.py#L60