Depth Camera distance measuring issue while in motion

I have installed a Zed2i Camera on the front of a railway engine, facing sideways towards the electric poles (masts) that hold the overhead wires. This means the camera is positioned at a 90-degree angle to the direction the train is moving.

I wrote a program that accurately measures the distance between the camera and the masts. When the train moves 5 km north, the distance measurements are perfect. However, when the train moves back south on the same track (in reverse), the distance readings are incorrect, even though the camera remains fixed in its position.

The camera uses stereo vision (like how our eyes see depth). What could be causing this issue?
Below is Zed Configuration I use:

zed = sl.Camera()
init_params = sl.InitParameters(
depth_mode=sl.DEPTH_MODE.ULTRA,
coordinate_units=sl.UNIT.INCH,
camera_resolution=sl.RESOLUTION.HD1080,
camera_fps=30,
depth_maximum_distance=780,
depth_minimum_distance=15,
depth_stabilization = 50
)
init_params.camera_resolution = sl.RESOLUTION.HD1080
init_params.camera_fps = 30
if zed.open(init_params) != sl.ERROR_CODE.SUCCESS:
print(“Failed to open ZED camera.”)
return
runtime_parameters = sl.RuntimeParameters(confidence_threshold = 50, texture_confidence_threshold = 50)

Logic to measure distance is quite simple. Object detection model is trained to detect target object. I pass all those depth values inside bounding box to median function. It gives perfect direction in single direction but while returning to same point it gives erroneous depth value.

Hi @BrainyAI
unfortunately, it’s not possible to understand the cause of this issue without the full source code and an SVO recording to test it.
You can send the material for debugging to support@stereolabs.com if you cannot share it publicly.