Using max_range parameter from ObjectDetectionParameters


I am trying to use the max_range parameter to define the maximum range to detect objects. Before enabling object detection, I am setting the parameter to a specific value. However, the camera is detecting objects at larger distances than the one specified in max_range.

I found on the SDK documentation that the parameter is initialized to depth_maximum_distance. I am setting max_range < depth_maximum_distance to avoid possible issues on this regard.

Maybe I am missing something in the parameter configuration. Has someone tried to modify this before?

Thank you

Hi @jrodriguezg
Welcome to the Stereolabs community.

Are you setting the max_range value of the ObjectDetectionParameters structure?

Can you share your initialization code?

Hi @Myzhar
Sorry for the late reply!
Yes, I am setting the max_range using the structure. Here is the initialization code:

zed = sl.Camera()
init_params = sl.InitParameters()
init_params.camera_resolution = sl.RESOLUTION.HD720  # Use HD720 video mode
init_params.depth_mode = sl.DEPTH_MODE.PERFORMANCE
init_params.coordinate_units = sl.UNIT.METER
init_params.sdk_verbose = True
init_params.depth_minimum_distance = 0.2
init_params.depth_maximum_distance = 10.0

max_detection_distance = 2.0

err =
    if err != sl.ERROR_CODE.SUCCESS:

obj_param = sl.ObjectDetectionParameters()
obj_param.max_range = max_detection_distance

err = zed.enable_object_detection(obj_param)
  if err != sl.ERROR_CODE.SUCCESS :
      print (repr(err))

Using this code I am able to detect objects at distances larger than 2m differently to the specified value in the ObjectDetectionParameters structure

@jrodriguezg what ZED SDK version are you using?

@Myzhar I am using the 4.0.2 version

Can you please test it with the latest v4.0.3?

Hi @Myzhar

Sorry for the late update. I installed the latest v4.0.4 and I still have the same issue. Among the detected objects, I still get objects farther than the max_range value.

Are you speaking of 2D or 3D information?

I am checking the depth of all detected objects provided by the retrieve_objects() function. I am assuming the depth of the object centroid as the z component of the object position. Is this correct?

Just as an update:

I am not using the information from retrieve_objects anymore to get an idea of depth. Instead, I am getting it directly from the depth map provided by retrieve_measure(depth_map, sl.MEASURE.DEPTH) . However, I still get depth estimations with values larger than max_range.

Do you have any idea of the cause of this behavior @Myzhar ?