Using max_range parameter from ObjectDetectionParameters

Hello!

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 = zed.open(init_params)
    if err != sl.ERROR_CODE.SUCCESS:
        exit(1)

obj_param = sl.ObjectDetectionParameters()
obj_param.enable_tracking=False
obj_param.image_sync=True
obj_param.enable_segmentation=True
obj_param.max_range = max_detection_distance

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

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 just checked the depth of the bounding box centroid from the depth image. I am using the retrieve_measure(depth_map, sl.MEASURE.DEPTH) function to get the depth, depth_map is an image.
I still receive objects with a depth larger than max_range. Besides, I realized that the depth value and the Z component of the object position are not the same. Sometimes both measurements differ considerably (more than 2 m), is this ok?

1 Like