ON THIS PAGE

  • StereoDepthConfig
  • Examples of functionality
  • Reference

StereoDepthConfig

This message is used to configure the StereoDepth node. With this message you can set filters, confidences, thresholds and mode of the StereoDepth node.

Examples of functionality

Reference

class

dai::StereoDepthConfig

#include StereoDepthConfig.hpp
variable
AlgorithmControl algorithmControl
Controls the flow of stereo algorithm - left-right check, subpixel etc.
variable
PostProcessing postProcessing
Controls the postprocessing of disparity and/or depth map.
variable
CensusTransform censusTransform
Census transform settings.
variable
CostMatching costMatching
Cost matching settings.
variable
CostAggregation costAggregation
Cost aggregation settings.
variable
ConfidenceMetrics confidenceMetrics
Confidence metrics settings.
variable
dai::ProcessorType filtersBackend
function
StereoDepthConfig()
Construct StereoDepthConfig message.
function
~StereoDepthConfig()
function
StereoDepthConfig & setDepthAlign(AlgorithmControl::DepthAlign align)
Parameters
  • align: Set the disparity/depth alignment: centered (between the 'left' and 'right' inputs), or from the perspective of a rectified output stream
function
StereoDepthConfig & setConfidenceThreshold(int confThr)
Confidence threshold for disparity calculation
Parameters
  • confThr: Confidence threshold value 0..255
function
int getConfidenceThreshold()
Get confidence threshold for disparity calculation
function
StereoDepthConfig & setMedianFilter(MedianFilter median)
Parameters
  • median: Set kernel size for disparity/depth median filtering, or disable
function
MedianFilter getMedianFilter()
Get median filter setting
function
StereoDepthConfig & setBilateralFilterSigma(uint16_t sigma)
A larger value of the parameter means that farther colors within the pixel neighborhood will be mixed together, resulting in larger areas of semi-equal color.
Parameters
  • sigma: Set sigma value for 5x5 bilateral filter. 0..65535
function
uint16_t getBilateralFilterSigma()
Get sigma value for 5x5 bilateral filter
function
StereoDepthConfig & setLeftRightCheckThreshold(int threshold)
Parameters
  • threshold: Set threshold for left-right, right-left disparity map combine, 0..255
function
int getLeftRightCheckThreshold()
Get threshold for left-right check combine
function
StereoDepthConfig & setLeftRightCheck(bool enable)
Computes and combines disparities in both L-R and R-L directions, and combine them.For better occlusion handling, discarding invalid disparity values
function
bool getLeftRightCheck()
Get left-right check setting
function
StereoDepthConfig & setExtendedDisparity(bool enable)
Disparity range increased from 95 to 190, combined from full resolution and downscaled images. Suitable for short range objects
function
bool getExtendedDisparity()
Get extended disparity setting
function
StereoDepthConfig & setSubpixel(bool enable)
Computes disparity with sub-pixel interpolation (3 fractional bits by default).Suitable for long range. Currently incompatible with extended disparity
function
bool getSubpixel()
Get subpixel setting
function
StereoDepthConfig & setSubpixelFractionalBits(int subpixelFractionalBits)
Number of fractional bits for subpixel mode. Default value: 3. Valid values: 3,4,5. Defines the number of fractional disparities: 2^x. Median filter postprocessing is supported only for 3 fractional bits.
function
int getSubpixelFractionalBits()
Get number of fractional bits for subpixel mode
function
StereoDepthConfig & setDepthUnit(AlgorithmControl::DepthUnit depthUnit)
Set depth unit of depth map.Meter, centimeter, millimeter, inch, foot or custom unit is available.
function
AlgorithmControl::DepthUnit getDepthUnit()
Get depth unit of depth map.
function
StereoDepthConfig & setDisparityShift(int disparityShift)
Shift input frame by a number of pixels to increase minimum depth. For example shifting by 48 will change effective disparity search range from (0,95] to [48,143]. An alternative approach to reducing the minZ. We normally only recommend doing this when it is known that there will be no objects farther away than MaxZ, such as having a depth camera mounted above a table pointing down at the table surface.
function
StereoDepthConfig & setNumInvalidateEdgePixels(int32_t numInvalidateEdgePixels)
Invalidate X amount of pixels at the edge of disparity frame. For right and center alignment X pixels will be invalidated from the right edge, for left alignment from the left edge.
function
StereoDepthConfig & setFiltersComputeBackend(dai::ProcessorType filtersBackend)
Set filters compute backend
function
dai::ProcessorType getFiltersComputeBackend()
Get filters compute backend
function
float getMaxDisparity()
Useful for normalization of the disparity map.
Returns
Maximum disparity value that the node can return
inline function
void serialize(std::vector< std::uint8_t > & metadata, DatatypeEnum & datatype)
function
struct

dai::StereoDepthConfig::AlgorithmControl

variable
DepthAlign depthAlign
Set the disparity/depth alignment to the perspective of a rectified output, or center it
variable
DepthUnit depthUnit
Measurement unit for depth data. Depth data is integer value, multiple of depth unit.
variable
float customDepthUnitMultiplier
Custom depth unit multiplier, if custom depth unit is enabled, relative to 1 meter. A multiplier of 1000 effectively means depth unit in millimeter.
variable
bool enableLeftRightCheck
Computes and combines disparities in both L-R and R-L directions, and combine them. For better occlusion handling
variable
bool enableSwLeftRightCheck
Enables software left right check. Applicable to RVC4 only.
variable
bool enableExtended
Disparity range increased from 95 to 190, combined from full resolution and downscaled images. Suitable for short range objects
variable
bool enableSubpixel
Computes disparity with sub-pixel interpolation (5 fractional bits), suitable for long range
variable
std::int32_t leftRightCheckThreshold
Left-right check threshold for left-right, right-left disparity map combine, 0..128 Used only when left-right check mode is enabled. Defines the maximum difference between the confidence of pixels from left-right and right-left confidence maps
variable
std::int32_t subpixelFractionalBits
Number of fractional bits for subpixel modeValid values: 3,4,5Defines the number of fractional disparities: 2^xMedian filter postprocessing is supported only for 3 fractional bits
variable
std::int32_t disparityShift
Shift input frame by a number of pixels to increase minimum depth. For example shifting by 48 will change effective disparity search range from (0,95] to [48,143]. An alternative approach to reducing the minZ. We normally only recommend doing this when it is known that there will be no objects farther away than MaxZ, such as having a depth camera mounted above a table pointing down at the table surface.
variable
std::optional< float > centerAlignmentShiftFactor
variable
std::int32_t numInvalidateEdgePixels
Invalidate X amount of pixels at the edge of disparity frame. For right and center alignment X pixels will be invalidated from the right edge, for left alignment from the left edge.
function
enum

int32_t DepthAlign

Align the disparity/depth to the perspective of a rectified output, or center it
enumerator
RECTIFIED_RIGHT
enumerator
RECTIFIED_LEFT
enumerator
CENTER
enum

int32_t DepthUnit

Measurement unit for depth data
enumerator
METER
enumerator
CENTIMETER
enumerator
MILLIMETER
enumerator
INCH
enumerator
FOOT
enumerator
CUSTOM
struct

dai::StereoDepthConfig::CensusTransform

#include StereoDepthConfig.hpp
variable
KernelSize kernelSize
Census transform kernel size.
variable
uint64_t kernelMask
Census transform mask, default - auto, mask is set based on resolution and kernel size. Disabled for 400p input resolution. Enabled for 720p. 0XA82415 for 5x5 census transform kernel. 0XAA02A8154055 for 7x7 census transform kernel. 0X2AA00AA805540155 for 7x9 census transform kernel. Empirical values.
variable
bool enableMeanMode
If enabled, each pixel in the window is compared with the mean window value instead of the central pixel.
variable
uint32_t threshold
Census transform comparison threshold value.
variable
int8_t noiseThresholdOffset
Used to reduce small fixed levels of noise across all luminance values in the current image. Valid range is [0,127]. Default value is 0.
variable
int8_t noiseThresholdScale
Used to reduce noise values that increase with luminance in the current image. Valid range is [-128,127]. Default value is 0.
function
enum

std::int32_t KernelSize

Census transform kernel size possible values.
enumerator
AUTO
enumerator
KERNEL_5x5
enumerator
KERNEL_7x7
enumerator
KERNEL_7x9
struct

dai::StereoDepthConfig::ConfidenceMetrics

variable
uint8_t occlusionConfidenceWeight
Weight used with occlusion estimation to generate final confidence map. Valid range is [0,32]
variable
uint8_t motionVectorConfidenceWeight
Weight used with local neighborhood motion vector variance estimation to generate final confidence map. Valid range is [0,32].
variable
uint8_t motionVectorConfidenceThreshold
Threshold offset for MV variance in confidence generation. A value of 0 allows most variance. Valid range is [0,3].
variable
uint8_t flatnessConfidenceWeight
Weight used with flatness estimation to generate final confidence map. Valid range is [0,32].
variable
uint8_t flatnessConfidenceThreshold
Threshold for flatness check in SGM block. Valid range is [1,7].
variable
bool flatnessOverride
Flag to indicate whether final confidence value will be overidden by flatness value. Valid range is {true,false}.
function
struct

dai::StereoDepthConfig::CostAggregation

#include StereoDepthConfig.hpp
variable
uint8_t divisionFactor
Cost calculation linear equation parameters.
variable
uint16_t horizontalPenaltyCostP1
Horizontal P1 penalty cost parameter.
variable
uint16_t horizontalPenaltyCostP2
Horizontal P2 penalty cost parameter.
variable
uint16_t verticalPenaltyCostP1
Vertical P1 penalty cost parameter.
variable
uint16_t verticalPenaltyCostP2
Vertical P2 penalty cost parameter.
variable
P1Config p1Config
variable
P2Config p2Config
function
struct

dai::StereoDepthConfig::CostAggregation::P1Config

#include StereoDepthConfig.hpp
variable
bool enableAdaptive
Used to disable/enable adaptive penalty.
variable
uint8_t defaultValue
Used as the default penalty value when nAdapEnable is disabled. A bigger value enforces higher smoothness and reduced noise at the cost of lower edge accuracy. This value must be smaller than P2 default penalty. Valid range is [10,50].
variable
uint8_t edgeValue
Penalty value on edges when nAdapEnable is enabled. A smaller penalty value permits higher change in disparity. This value must be smaller than or equal to P2 edge penalty. Valid range is [10,50].
variable
uint8_t smoothValue
Penalty value on low texture regions when nAdapEnable is enabled. A smaller penalty value permits higher change in disparity. This value must be smaller than or equal to P2 smoothness penalty. Valid range is [10,50].
variable
uint8_t edgeThreshold
Threshold value on edges when nAdapEnable is enabled. A bigger value permits higher neighboring feature dissimilarity tolerance. This value is shared with P2 penalty configuration. Valid range is [8,16].
variable
uint8_t smoothThreshold
Threshold value on low texture regions when nAdapEnable is enabled. A bigger value permits higher neighboring feature dissimilarity tolerance. This value is shared with P2 penalty configuration. Valid range is [2,12].
function
struct

dai::StereoDepthConfig::CostAggregation::P2Config

#include StereoDepthConfig.hpp
variable
bool enableAdaptive
Used to disable/enable adaptive penalty.
variable
uint8_t defaultValue
Used as the default penalty value when nAdapEnable is disabled. A bigger value enforces higher smoothness and reduced noise at the cost of lower edge accuracy. This value must be larger than P1 default penalty. Valid range is [20,100].
variable
uint8_t edgeValue
Penalty value on edges when nAdapEnable is enabled. A smaller penalty value permits higher change in disparity. This value must be larger than or equal to P1 edge penalty. Valid range is [20,100].
variable
uint8_t smoothValue
Penalty value on low texture regions when nAdapEnable is enabled. A smaller penalty value permits higher change in disparity. This value must be larger than or equal to P1 smoothness penalty. Valid range is [20,100].
function
struct

dai::StereoDepthConfig::CostMatching

#include StereoDepthConfig.hpp
variable
DisparityWidth disparityWidth
Disparity search range, default 96 pixels.
variable
bool enableCompanding
Disparity companding using sparse matching. Matching pixel by pixel for N disparities. Matching every 2nd pixel for M disparitites. Matching every 4th pixel for T disparities. In case of 96 disparities: N=48, M=32, T=16. This way the search range is extended to 176 disparities, by sparse matching. Note: when enabling this flag only depth map will be affected, disparity map is not.
variable
uint8_t invalidDisparityValue
Used only for debug purposes, SW postprocessing handled only invalid value of 0 properly.
variable
uint8_t confidenceThreshold
Disparities with confidence value over this threshold are accepted.
variable
bool enableSwConfidenceThresholding
Enable software confidence thresholding. Applicable to RVC4 only.
variable
LinearEquationParameters linearEquationParameters
Cost calculation linear equation parameters.
function
struct

dai::StereoDepthConfig::CostMatching::LinearEquationParameters

#include StereoDepthConfig.hpp
variable
uint8_t alpha
variable
uint8_t beta
variable
uint8_t threshold
function
DEPTHAI_SERIALIZE(LinearEquationParameters, alpha, beta, threshold)
enum

std::uint32_t DisparityWidth

Disparity search range: 64 or 96 pixels are supported by the HW.
enumerator
DISPARITY_64
enumerator
DISPARITY_96
struct

dai::StereoDepthConfig::PostProcessing

#include StereoDepthConfig.hpp
variable
std::array< Filter, 5 > filteringOrder
Order of filters to be applied if filtering is enabled.
variable
MedianFilter median
Set kernel size for disparity/depth median filtering, or disable
variable
std::int16_t bilateralSigmaValue
Sigma value for bilateral filter. 0 means disabled. A larger value of the parameter means that farther colors within the pixel neighborhood will be mixed together.
variable
SpatialFilter spatialFilter
Edge-preserving filtering: This type of filter will smooth the depth noise while attempting to preserve edges.
variable
TemporalFilter temporalFilter
Temporal filtering with optional persistence.
variable
ThresholdFilter thresholdFilter
Threshold filtering. Filters out distances outside of a given interval.
variable
BrightnessFilter brightnessFilter
Brightness filtering. If input frame pixel is too dark or too bright, disparity will be invalidated. The idea is that for too dark/too bright pixels we have low confidence, since that area was under/over exposed and details were lost.
variable
SpeckleFilter speckleFilter
Speckle filtering. Removes speckle noise.
variable
DecimationFilter decimationFilter
Decimation filter. Reduces disparity/depth map x/y complexity, reducing runtime complexity for other filters.
variable
HoleFilling holeFilling
variable
AdaptiveMedianFilter adaptiveMedianFilter
function
struct

dai::StereoDepthConfig::PostProcessing::AdaptiveMedianFilter

variable
bool enable
Flag to enable adaptive median filtering for a final pass of filtering on low confidence pixels.
variable
uint8_t confidenceThreshold
Confidence threshold for adaptive median filtering. Should be less than nFillConfThresh value used in evaDfsHoleFillConfig. Valid range is [0,255].
function
struct

dai::StereoDepthConfig::PostProcessing::BrightnessFilter

#include StereoDepthConfig.hpp
variable
std::int32_t minBrightness
Minimum pixel brightness. If input pixel is less or equal than this value the depth value is invalidated.
variable
std::int32_t maxBrightness
Maximum range in depth units. If input pixel is less or equal than this value the depth value is invalidated.
function
struct

dai::StereoDepthConfig::PostProcessing::DecimationFilter

#include StereoDepthConfig.hpp
variable
std::uint32_t decimationFactor
Decimation factor. Valid values are 1,2,3,4. Disparity/depth map x/y resolution will be decimated with this value.
variable
DecimationMode decimationMode
Decimation algorithm type.
function
enum

int32_t DecimationMode

Decimation algorithm type.
enumerator
PIXEL_SKIPPING
enumerator
NON_ZERO_MEDIAN
enumerator
NON_ZERO_MEAN
struct

dai::StereoDepthConfig::PostProcessing::HoleFilling

variable
bool enable
Flag to enable post-processing hole-filling.
variable
uint8_t highConfidenceThreshold
Pixels with confidence higher than this value are used to calculate an average disparity per superpixel. Valid range is [1,255]
variable
uint8_t fillConfidenceThreshold
Pixels with confidence below this value will be filled with the average disparity of their corresponding superpixel. Valid range is [1,255].
variable
uint8_t minValidDisparity
Represents the required percentange of pixels with confidence value above nHighConfThresh that are used to calculate average disparity per superpixel, where 1 means 50% or half, 2 means 25% or a quarter and 3 means 12.5% or an eighth. If the required number of pixels are not found, the holes will not be filled.
variable
bool invalidateDisparities
If enabled, sets to 0 the disparity of pixels with confidence below nFillConfThresh, which did not pass nMinValidPixels criteria. Valid range is {true, false}.
function
struct

dai::StereoDepthConfig::PostProcessing::SpatialFilter

#include StereoDepthConfig.hpp
variable
bool enable
Whether to enable or disable the filter.
variable
std::uint8_t holeFillingRadius
An in-place heuristic symmetric hole-filling mode applied horizontally during the filter passes. Intended to rectify minor artefacts with minimal performance impact. Search radius for hole filling.
variable
float alpha
The Alpha factor in an exponential moving average with Alpha=1 - no filter. Alpha = 0 - infinite filter. Determines the amount of smoothing.
variable
std::int32_t delta
Step-size boundary. Establishes the threshold used to preserve "edges". If the disparity value between neighboring pixels exceed the disparity threshold set by this delta parameter, then filtering will be temporarily disabled. Default value 0 means auto: 3 disparity integer levels. In case of subpixel mode it's 3*number of subpixel levels.
variable
std::int32_t numIterations
Number of iterations over the image in both horizontal and vertical direction.
function
struct

dai::StereoDepthConfig::PostProcessing::SpeckleFilter

#include StereoDepthConfig.hpp
variable
bool enable
Whether to enable or disable the filter.
variable
std::uint32_t speckleRange
Speckle search range.
variable
std::uint32_t differenceThreshold
Maximum difference between neighbor disparity pixels to put them into the same blob. Units in disparity integer levels.
function
struct

dai::StereoDepthConfig::PostProcessing::TemporalFilter

#include StereoDepthConfig.hpp
variable
bool enable
Whether to enable or disable the filter.
variable
PersistencyMode persistencyMode
Persistency mode. If the current disparity/depth value is invalid, it will be replaced by an older value, based on persistency mode.
variable
float alpha
The Alpha factor in an exponential moving average with Alpha=1 - no filter. Alpha = 0 - infinite filter. Determines the extent of the temporal history that should be averaged.
variable
std::int32_t delta
Step-size boundary. Establishes the threshold used to preserve surfaces (edges). If the disparity value between neighboring pixels exceed the disparity threshold set by this delta parameter, then filtering will be temporarily disabled. Default value 0 means auto: 3 disparity integer levels. In case of subpixel mode it's 3*number of subpixel levels.
function
enum

int32_t PersistencyMode

Persistency algorithm type.
enumerator
PERSISTENCY_OFF
enumerator
VALID_8_OUT_OF_8
enumerator
VALID_2_IN_LAST_3
enumerator
VALID_2_IN_LAST_4
enumerator
VALID_2_OUT_OF_8
enumerator
VALID_1_IN_LAST_2
enumerator
VALID_1_IN_LAST_5
enumerator
VALID_1_IN_LAST_8
enumerator
PERSISTENCY_INDEFINITELY
struct

dai::StereoDepthConfig::PostProcessing::ThresholdFilter

#include StereoDepthConfig.hpp
variable
std::int32_t minRange
Minimum range in depth units. Depth values under this value are invalidated.
variable
std::int32_t maxRange
Maximum range in depth units. Depth values over this value are invalidated.
function
DEPTHAI_SERIALIZE(ThresholdFilter, minRange, maxRange)
enum

int32_t Filter

enumerator
NONE
enumerator
DECIMATION
enumerator
SPECKLE
enumerator
MEDIAN
enumerator
SPATIAL
enumerator
TEMPORAL
enumerator
FILTER_COUNT
enum

int32_t MedianFilter

Median filter config for disparity post-processing
enumerator
MEDIAN_OFF
enumerator
KERNEL_3x3
enumerator
KERNEL_5x5
enumerator
KERNEL_7x7

Need assistance?

Head over to Discussion Forum for technical support or any other questions you might have.