luxonis / depthai-ros

Official ROS Driver for DepthAI Sensors.
MIT License
255 stars 186 forks source link

add DisparityWidth, Disparity Companding, SubpixelFractionalBits options #279

Closed borongyuan closed 1 year ago

borongyuan commented 1 year ago

Adding these options can help with better Stereo Depth tuning.

Using DISPARITY_64 alone is not a good idea. But it's not the same when using it with other parameters. The doc says "Median filter postprocessing is supported only for 3 fractional bits". This is because the median filter supports a maximum of 1024 Disparity. For DISPARITY_96 and 4 fractional bits, the maximun disparity is 1520. However, for DISPARITY_64 and 4 fractional bits, the maximum disparity is 1008, which is just below the limit. Another choice is to use DISPARITY_64 with extended disparity and 3 fractional bits. It's maximun disparity is also 1008. Which means the disparity range is increased to 126, while median filter is still available.

Another way to increase disparity range is to enable Companding. Unlike extended disparity, it does not consume more HW resources. So it is useful for high resolution inputs.

After adding these options, I found the following two sets of good parameter combinations.

/oak:
  ros__parameters:
    stereo:
      i_depth_filter_size: 5
      i_disparity_width: DISPARITY_64
      i_enable_companding: false
      i_extended_disp: true
      i_subpixel: true
      i_subpixel_fractional_bits: 3
/oak:
  ros__parameters:
    stereo:
      i_depth_filter_size: 5
      i_disparity_width: DISPARITY_64
      i_enable_companding: true
      i_extended_disp: false
      i_subpixel: true
      i_subpixel_fractional_bits: 4
Serafadam commented 1 year ago

Thanks for the PR!