# Depth accuracy calculation of measurements

Hi there,
I am using the zed2i as an outdoor measurement tool. I saw the depth accuracy is about 2%-5% when it comes to less than 10m. But when I use it as the measurement tool outdoor, I found the accuracy is quite bad when the distance from the camera is further than 6m.

Case 1. Distance: 9.3m. Traffic sign ground truth: 2.5m. Calculate from depth map: 6.06m. (very bad)

Case 2. Distance: 8.3m. Traffic sign ground truth: 2.5m. Calculate from depth map: 2.43m. (Good)

How I calculate the measurement: Euclidean distance formula.

Parameters:
Neural depth mode.
3.8.2 SDK.
Resolution: both 2k and 1080 are the same.

Is this situation to be expected? How can I calculate the furthest working distance in this scenario?

Another screenshot is showing that the same height fence will give different height results.

Hi @John
how did you calculate the distance by using the Depth Map?
Can you write down the formula/code that you used?
What I see in the pictures that you attached is not coherent…

There are two points for every lines. Say A(x1,y1) and B(x2,y2). Both of them are selected by mouse.
This is the function that I get (X,Y,Z) by (x,y).

def get_value(x, y):
Z = npz[‘depth’][y][x]
X = (( x - npz[‘cx’]) * Z) / (npz[‘fx’])
Y = (( y - npz[‘cy’]) * Z) / (npz[‘fy’])
return [X,Y,Z]

npz is dumped from the SVO file by below code.

``````        zed.retrieve_measure(depth, sl.MEASURE.DEPTH)
cx = zed.get_camera_information().calibration_parameters.left_cam.cx
cy = zed.get_camera_information().calibration_parameters.left_cam.cy
fx = zed.get_camera_information().calibration_parameters.left_cam.fx
fy = zed.get_camera_information().calibration_parameters.left_cam.fy
timestamp = zed.get_timestamp(sl.TIME_REFERENCE.CURRENT)
np.savez('./temp.npz', depth = depth.get_data(), timestamp=str(timestamp), fx=fx,fy=fy, cx=cx,cy=cy)
``````

After that, I just use the Euclidean distance formula like below:

``````distance = math.sqrt((X1 - X2) * (X1 - X2) +
(Y1 - Y2) * (Y1- Y2) +
(Z1 - Z2) * (Z1 - Z2))
``````

The close and horizontal situation is not bad, but the far vertical one is very wrong. The border is about 6m.

My device: ZED 2i 2.1mm with polarizer.

I tried to generate the point cloud and open it by open3d, then, I found that the pole was not straight.

Distance from the camera: 8m

Distance from the camera: >8m

View from the original position.