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
depthai.StereoDepthConfig(depthai.Buffer)
class
class
CensusTransform
The basic cost function used by the Stereo Accelerator for matching the left and right images is the Census Transform. It works on a block of pixels and computes a bit vector which represents the structure of the image in that block. There are two types of Census Transform based on how the middle pixel is used: Classic Approach and Modified Census. The comparisons that are made between pixels can be or not thresholded. In some cases a mask can be applied to filter out only specific bits from the entire bit stream. All these approaches are: Classic Approach: Uses middle pixel to compare against all its neighbors over a defined window. Each comparison results in a new bit, that is 0 if central pixel is smaller, or 1 if is it bigger than its neighbor. Modified Census Transform: same as classic Census Transform, but instead of comparing central pixel with its neighbors, the window mean will be compared with each pixel over the window. Thresholding Census Transform: same as classic Census Transform, but it is not enough that a neighbor pixel to be bigger than the central pixel, it must be significant bigger (based on a threshold). Census Transform with Mask: same as classic Census Transform, but in this case not all of the pixel from the support window are part of the binary descriptor. We use a ma sk “M” to define which pixels are part of the binary descriptor (1), and which pixels should be skipped (0).
class
CostAggregation
Cost Aggregation is based on Semi Global Block Matching (SGBM). This algorithm uses a semi global technique to aggregate the cost map. Ultimately the idea is to build inertia into the stereo algorithm. If a pixel has very little texture information, then odds are the correct disparity for this pixel is close to that of the previous pixel considered. This means that we get improved results in areas with low texture.
class
CostMatching
The matching cost is way of measuring the similarity of image locations in stereo correspondence algorithm. Based on the configuration parameters and based on the descriptor type, a linear equation is applied to computing the cost for each candidate disparity at each pixel.
class
MedianFilter
Median filter config Members: MEDIAN_OFF KERNEL_3x3 KERNEL_5x5 KERNEL_7x7
class
PostProcessing
Post-processing filters, all the filters are applied in disparity domain.
method
method
get(self) -> RawStereoDepthConfig: RawStereoDepthConfig
Retrieve configuration data for StereoDepth. Returns: config for stereo depth algorithm
method
getBilateralFilterSigma(self) -> int: int
Get sigma value for 5x5 bilateral filter
method
getConfidenceThreshold(self) -> int: int
Get confidence threshold for disparity calculation
method
getDepthUnit(self) -> RawStereoDepthConfig.AlgorithmControl.DepthUnit: RawStereoDepthConfig.AlgorithmControl.DepthUnit
Get depth unit of depth map.
method
getLeftRightCheckThreshold(self) -> int: int
Get threshold for left-right check combine
method
getMaxDisparity(self) -> float: float
Useful for normalization of the disparity map. Returns: Maximum disparity value that the node can return
method
getMedianFilter(self) -> MedianFilter: MedianFilter
Get median filter setting
method
set(self, config: RawStereoDepthConfig) -> StereoDepthConfig: StereoDepthConfig
Set explicit configuration. Parameter ``config``: Explicit configuration
method
setBilateralFilterSigma(self, sigma: int) -> StereoDepthConfig: StereoDepthConfig
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. Parameter ``sigma``: Set sigma value for 5x5 bilateral filter. 0..65535
method
setConfidenceThreshold(self, confThr: int) -> StereoDepthConfig: StereoDepthConfig
Confidence threshold for disparity calculation Parameter ``confThr``: Confidence threshold value 0..255
method
setDepthAlign(self, align: RawStereoDepthConfig.AlgorithmControl.DepthAlign) -> StereoDepthConfig: StereoDepthConfig
Parameter ``align``: Set the disparity/depth alignment: centered (between the 'left' and 'right' inputs), or from the perspective of a rectified output stream
method
setDepthUnit(self, arg0: RawStereoDepthConfig.AlgorithmControl.DepthUnit) -> StereoDepthConfig: StereoDepthConfig
Set depth unit of depth map. Meter, centimeter, millimeter, inch, foot or custom unit is available.
method
setDisparityShift(self, arg0: int) -> StereoDepthConfig: StereoDepthConfig
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.
method
setExtendedDisparity(self, enable: bool) -> StereoDepthConfig: StereoDepthConfig
Disparity range increased from 95 to 190, combined from full resolution and downscaled images. Suitable for short range objects
method
setLeftRightCheck(self, enable: bool) -> StereoDepthConfig: StereoDepthConfig
Computes and combines disparities in both L-R and R-L directions, and combine them. For better occlusion handling, discarding invalid disparity values
method
setLeftRightCheckThreshold(self, sigma: int) -> StereoDepthConfig: StereoDepthConfig
Parameter ``threshold``: Set threshold for left-right, right-left disparity map combine, 0..255
method
setMedianFilter(self, median: MedianFilter) -> StereoDepthConfig: StereoDepthConfig
Parameter ``median``: Set kernel size for disparity/depth median filtering, or disable
method
setNumInvalidateEdgePixels(self, arg0: int) -> StereoDepthConfig: StereoDepthConfig
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.
method
setSubpixel(self, enable: bool) -> StereoDepthConfig: StereoDepthConfig
Computes disparity with sub-pixel interpolation (3 fractional bits by default). Suitable for long range. Currently incompatible with extended disparity
method
setSubpixelFractionalBits(self, subpixelFractionalBits: int) -> StereoDepthConfig: StereoDepthConfig
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.
class
depthai.StereoDepthConfig.AlgorithmControl
class
DepthAlign
Align the disparity/depth to the perspective of a rectified output, or center it Members: RECTIFIED_RIGHT : RECTIFIED_LEFT : CENTER :
class
DepthUnit
Measurement unit for depth data Members: METER : CENTIMETER : MILLIMETER : INCH : FOOT : CUSTOM :
method
property
centerAlignmentShiftFactor
Used only for debug purposes. centerAlignmentShiftFactor is set automatically in firmware, from camera extrinsics when depth alignment to camera is enabled. Center alignment is achieved by shifting the obtained disparity map by a scale factor. It's used to align to a different camera that is on the same horizontal baseline as the two stereo cameras. E.g. if we have a device with 10 cm stereo baseline, and we have another camera inbetween, 9cm from the LEFT camera and 1 cm from the RIGHT camera we can align the obtained disparity map using a scale factor of 0.9. Note that aligning disparity map to a different camera involves 2 steps: 1. Shifting obtained disparity map. 2. Warping the image to counter rotate and scaling to match the FOV. Center alignment factor 1 is equivalent to RECTIFIED_RIGHT Center alignment factor 0 is equivalent to RECTIFIED_LEFT
method
property
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.
method
property
depthAlign
Set the disparity/depth alignment to the perspective of a rectified output, or center it
method
property
depthUnit
Measurement unit for depth data. Depth data is integer value, multiple of depth unit.
method
property
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.
method
property
enableExtended
Disparity range increased from 95 to 190, combined from full resolution and downscaled images. Suitable for short range objects
method
property
enableLeftRightCheck
Computes and combines disparities in both L-R and R-L directions, and combine them. For better occlusion handling
method
property
enableSubpixel
Computes disparity with sub-pixel interpolation (5 fractional bits), suitable for long range
method
property
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
method
property
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.
method
property
subpixelFractionalBits
Number of fractional bits for subpixel mode Valid values: 3,4,5 Defines the number of fractional disparities: 2^x Median filter postprocessing is supported only for 3 fractional bits
method
class
depthai.StereoDepthConfig.AlgorithmControl.DepthAlign
variable
variable
variable
variable
method
method
method
method
method
method
method
method
method
method
property
property
class
depthai.StereoDepthConfig.AlgorithmControl.DepthUnit
variable
variable
variable
variable
variable
variable
variable
method
method
method
method
method
method
method
method
method
method
property
property
class
depthai.StereoDepthConfig.CensusTransform
class
KernelSize
Census transform kernel size possible values. Members: AUTO : KERNEL_5x5 : KERNEL_7x7 : KERNEL_7x9 :
method
property
enableMeanMode
If enabled, each pixel in the window is compared with the mean window value instead of the central pixel.
method
property
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.
method
property
kernelSize
Census transform kernel size.
method
property
threshold
Census transform comparison threshold value.
method
class
depthai.StereoDepthConfig.CensusTransform.KernelSize
variable
variable
variable
variable
variable
method
method
method
method
method
method
method
method
method
method
property
property
class
depthai.StereoDepthConfig.CostAggregation
method
property
divisionFactor
Cost calculation linear equation parameters.
method
property
horizontalPenaltyCostP1
Horizontal P1 penalty cost parameter.
method
property
horizontalPenaltyCostP2
Horizontal P2 penalty cost parameter.
method
property
verticalPenaltyCostP1
Vertical P1 penalty cost parameter.
method
property
verticalPenaltyCostP2
Vertical P2 penalty cost parameter.
method
class
depthai.StereoDepthConfig.CostMatching
class
DisparityWidth
Disparity search range: 64 or 96 pixels are supported by the HW. Members: DISPARITY_64 : DISPARITY_96 :
class
LinearEquationParameters
The linear equation applied for computing the cost is: COMB_COST = α*AD + β*(CTC<<3). CLAMP(COMB_COST >> 5, threshold). Where AD is the Absolute Difference between 2 pixels values. CTC is the Census Transform Cost between 2 pixels, based on Hamming distance (xor). The α and β parameters are subject to fine tuning by the user.
method
property
confidenceThreshold
Disparities with confidence value under this threshold are accepted. Higher confidence threshold means disparities with less confidence are accepted too.
method
property
disparityWidth
Disparity search range, default 96 pixels.
method
property
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.
method
property
invalidDisparityValue
Used only for debug purposes, SW postprocessing handled only invalid value of 0 properly.
method
property
linearEquationParameters
Cost calculation linear equation parameters.
method
class
depthai.StereoDepthConfig.CostMatching.DisparityWidth
variable
variable
variable
method
method
method
method
method
method
method
method
method
method
property
property
class
depthai.StereoDepthConfig.CostMatching.LinearEquationParameters
variable
variable
variable
method
class
depthai.StereoDepthConfig.MedianFilter
variable
variable
variable
variable
variable
method
method
method
method
method
method
method
method
method
method
property
property
class
depthai.StereoDepthConfig.PostProcessing
class
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.
class
DecimationFilter
Decimation filter. Reduces the depth scene complexity. The filter runs on kernel sizes [2x2] to [8x8] pixels.
class
SpatialFilter
1D edge-preserving spatial filter using high-order domain transform.
class
SpeckleFilter
Speckle filtering. Removes speckle noise.
class
TemporalFilter
Temporal filtering with optional persistence.
class
ThresholdFilter
Threshold filtering. Filters out distances outside of a given interval.
method
property
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.
method
property
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.
method
property
decimationFilter
Decimation filter. Reduces disparity/depth map x/y complexity, reducing runtime complexity for other filters.
method
property
median
Set kernel size for disparity/depth median filtering, or disable
method
property
spatialFilter
Edge-preserving filtering: This type of filter will smooth the depth noise while attempting to preserve edges.
method
property
speckleFilter
Speckle filtering. Removes speckle noise.
method
property
temporalFilter
Temporal filtering with optional persistence.
method
property
thresholdFilter
Threshold filtering. Filters out distances outside of a given interval.
method
class
depthai.StereoDepthConfig.PostProcessing.BrightnessFilter
method
property
maxBrightness
Maximum range in depth units. If input pixel is less or equal than this value the depth value is invalidated.
method
property
minBrightness
Minimum pixel brightness. If input pixel is less or equal than this value the depth value is invalidated.
method
class
depthai.StereoDepthConfig.PostProcessing.DecimationFilter
class
DecimationMode
Decimation algorithm type. Members: PIXEL_SKIPPING : NON_ZERO_MEDIAN : NON_ZERO_MEAN :
method
property
decimationFactor
Decimation factor. Valid values are 1,2,3,4. Disparity/depth map x/y resolution will be decimated with this value.
method
property
decimationMode
Decimation algorithm type.
method
class
depthai.StereoDepthConfig.PostProcessing.DecimationFilter.DecimationMode
variable
variable
variable
PIXEL_SKIPPING: typing.ClassVar[RawStereoDepthConfig.PostProcessing.DecimationFilter.DecimationMode]
variable
method
method
method
method
method
method
method
method
method
method
property
property
class
depthai.StereoDepthConfig.PostProcessing.SpatialFilter
method
property
alpha
The Alpha factor in an exponential moving average with Alpha=1 - no filter. Alpha = 0 - infinite filter. Determines the amount of smoothing.
method
property
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.
method
property
enable
Whether to enable or disable the filter.
method
property
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.
method
property
numIterations
Number of iterations over the image in both horizontal and vertical direction.
method
class
depthai.StereoDepthConfig.PostProcessing.SpeckleFilter
method
property
enable
Whether to enable or disable the filter.
method
property
speckleRange
Speckle search range.
method
class
depthai.StereoDepthConfig.PostProcessing.TemporalFilter
class
PersistencyMode
Persistency algorithm type. Members: PERSISTENCY_OFF : VALID_8_OUT_OF_8 : VALID_2_IN_LAST_3 : VALID_2_IN_LAST_4 : VALID_2_OUT_OF_8 : VALID_1_IN_LAST_2 : VALID_1_IN_LAST_5 : VALID_1_IN_LAST_8 : PERSISTENCY_INDEFINITELY :
method
property
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.
method
property
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.
method
property
enable
Whether to enable or disable the filter.
method
property
persistencyMode
Persistency mode. If the current disparity/depth value is invalid, it will be replaced by an older value, based on persistency mode.
method
class
depthai.StereoDepthConfig.PostProcessing.TemporalFilter.PersistencyMode
variable
variable
PERSISTENCY_OFF: typing.ClassVar[RawStereoDepthConfig.PostProcessing.TemporalFilter.PersistencyMode]
variable
variable
variable
variable
variable
variable
variable
variable
method
method
method
method
method
method
method
method
method
method
property
property
Need assistance?
Head over to Discussion Forum for technical support or any other questions you might have.