Inaccurate depth value

i have checked depth value accuracy using zed2i

real distance from wall is 1m but calculated value using depth map is 0.65m
(distance with mono camera using opencv is 1.02m)

how to improve accuracy of depth value?

*** code ***
import cv2
import pyzed.sl as sl
import numpy as np
from utils import *

def main():
# ZED camera init
zed = sl.Camera()

# set camera params
init_params = sl.InitParameters()
init_params.camera_resolution = sl.RESOLUTION.HD1080
init_params.coordinate_units = sl.UNIT.METER
init_params.depth_mode = sl.DEPTH_MODE.ULTRA # Use ULTRA depth mode

# open camera
err = zed.open(init_params)
if err != sl.ERROR_CODE.SUCCESS:
    print(f"Error, unable to open ZED camera: {err}")
    zed.close()
    return 1

camera_info = zed.get_camera_information().camera_configuration
image_size = camera_info.resolution

image_zed = sl.Mat(image_size.width, image_size.height, sl.MAT_TYPE.U8_C4)
image_ocv_rgb = np.zeros((image_size.height, image_size.width, 3), dtype=np.uint8)

depth_map = sl.Mat(image_size.width, image_size.height, sl.MAT_TYPE.F32_C1)
point_cloud = sl.Mat()

runtime_parameters = sl.RuntimeParameters()
runtime_parameters.enable_fill_mode

calib_info = camera_info.calibration_parameters.left_cam
camera_matrix = np.array([[1067.17, 0, 959.66],
                          [0, 1067.9, 535.059],
                          [0, 0, 1]])
dist_coeffs = np.array(([-0.0727677727482817, 0.06090582313382647, 6.853173013136698e-06, 0.00022630862399272667])) 

dictionary = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_7X7_1000)
print(calib_info.fx, calib_info.fy, calib_info.cx, calib_info.cy)

key = '.'
while key != ord('q'):
    if zed.grab(runtime_parameters) == sl.ERROR_CODE.SUCCESS:
        # Retrieve the left image
        zed.retrieve_image(image_zed, sl.VIEW.LEFT, sl.MEM.CPU)
        zed.retrieve_measure(depth_map, sl.MEASURE.DEPTH) # Retrieve depth
        zed.retrieve_measure(point_cloud, sl.MEASURE.XYZRGBA, sl.MEM.CPU, image_size)
        frame = image_zed.get_data()

        # convert to RGB
        image_ocv_rgb = cv2.cvtColor(frame, cv2.COLOR_RGBA2RGB)
        image_gray = cv2.cvtColor(frame, cv2.COLOR_RGBA2GRAY)

        # detect marker
        corners, ids, _ = cv2.aruco.detectMarkers(image_gray, dictionary)

        for corner in corners:
            cv2.polylines(image_ocv_rgb, [corner.astype(np.int32).reshape((-1, 1, 2))], True, (0, 255, 0), 2)
           
        if ids is not None and len(ids) > 1:         
            origin_center ,centers, tvecs, rvecs = marker(corners,ids, camera_matrix, dist_coeffs)
            print(f'original center : {origin_center}')
            print(f'center : {centers}')
            print(f'tvecs : {tvecs}')
            _, origin_center_depth = depth_map.get_value(origin_center[0], origin_center[1])
            _, center_depth = depth_map.get_value(centers[0][0], centers[0][1])
            print(f'origin_center_depth:{origin_center_depth}')
            print(f'center_depth : {center_depth}')
            err_1, origin_pcd = point_cloud.get_value(origin_center[0], origin_center[1])
            err_2, center_pcd = point_cloud.get_value(centers[0][0], centers[0][1])

            # print(f'origin_pcd = {origin_pcd}')
            # print(f'center_pcd = {center_pcd}')

            # image_ocv_rgb, relative_position, relative_rvec = cal_distance(image_ocv_rgb, origin_center ,centers, tvecs, rvecs)
        # Display image
        cv2.imshow("Image", image_ocv_rgb)

        # Handle key event
        key = cv2.waitKey(10)

zed.close()
return 0

if name == “main”:
main()

Hi @kktae0034 ,

I would suggest you try out different depth modes for example depth_mode NEURAL to see if this produces better results in terms of accuracy.

Are you using the factory calibration or a calibration file from the calibration tool?

Is it possible for you to record an SVO with the Aruco in view for us to test your configuration?

Thanks to your reply.

when i changed window to ubuntu, problem has been solved…
depth value is gotten correctly.