Table of Contents

Class StereoSGBM

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

Semi-Global Stereo Matching

public class StereoSGBM : StereoMatcher, IDisposable, ICvPtrHolder
Inheritance
StereoSGBM
Implements
Inherited Members

Constructors

StereoSGBM(nint)

constructor

protected StereoSGBM(nint ptr)

Parameters

ptr nint

Properties

Mode

Set it to StereoSGBM::MODE_HH to run the full-scale two-pass dynamic programming algorithm. It will consume O(W*H*numDisparities) bytes, which is large for 640x480 stereo and huge for HD-size pictures. By default, it is set to false .

public StereoSGBMMode Mode { get; set; }

Property Value

StereoSGBMMode

P1

The first parameter controlling the disparity smoothness. See P2 description.

public int P1 { get; set; }

Property Value

int

P2

The second parameter controlling the disparity smoothness. The larger the values are, the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1 between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good P1 and P2 values are shown (like 8*number_of_image_channels*SADWindowSize*SADWindowSize and 32*number_of_image_channels*SADWindowSize*SADWindowSize , respectively).

public int P2 { get; set; }

Property Value

int

PreFilterCap

Truncation value for the prefiltered image pixels. The algorithm first computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval. The result values are passed to the Birchfield-Tomasi pixel cost function.

public int PreFilterCap { get; set; }

Property Value

int

UniquenessRatio

Margin in percentage by which the best (minimum) computed cost function value should "win" the second best value to consider the found match correct. Normally, a value within the 5-15 range is good enough.

public int UniquenessRatio { get; set; }

Property Value

int

Methods

Create(int, int, int, int, int, int, int, int, int, int, StereoSGBMMode)

public static StereoSGBM Create(int minDisparity, int numDisparities, int blockSize, int p1 = 0, int p2 = 0, int disp12MaxDiff = 0, int preFilterCap = 0, int uniquenessRatio = 0, int speckleWindowSize = 0, int speckleRange = 0, StereoSGBMMode mode = StereoSGBMMode.SGBM)

Parameters

minDisparity int
numDisparities int
blockSize int
p1 int
p2 int
disp12MaxDiff int
preFilterCap int
uniquenessRatio int
speckleWindowSize int
speckleRange int
mode StereoSGBMMode

Returns

StereoSGBM

DisposeManaged()

Releases managed resources

protected override void DisposeManaged()