OpenCV 2.4.7

org.opencv.calib3d
Class StereoSGBM

java.lang.Object
  extended by org.opencv.calib3d.StereoSGBM

public class StereoSGBM
extends java.lang.Object

Class for computing stereo correspondence using the semi-global block matching algorithm.

class StereoSGBM

// C++ code:

StereoSGBM();

StereoSGBM(int minDisparity, int numDisparities, int SADWindowSize,

int P1=0, int P2=0, int disp12MaxDiff=0,

int preFilterCap=0, int uniquenessRatio=0,

int speckleWindowSize=0, int speckleRange=0,

bool fullDP=false);

virtual ~StereoSGBM();

virtual void operator()(InputArray left, InputArray right, OutputArray disp);

int minDisparity;

int numberOfDisparities;

int SADWindowSize;

int preFilterCap;

int uniquenessRatio;

int P1, P2;

int speckleWindowSize;

int speckleRange;

int disp12MaxDiff;

bool fullDP;...

};

The class implements the modified H. Hirschmuller algorithm [HH08] that differs from the original one as follows:

Note:

See Also:
org.opencv.calib3d.StereoSGBM

Field Summary
static int DISP_SCALE
           
static int DISP_SHIFT
           
 
Constructor Summary
StereoSGBM()
          Initializes StereoSGBM and sets parameters to custom values.??
StereoSGBM(int minDisparity, int numDisparities, int SADWindowSize)
          Initializes StereoSGBM and sets parameters to custom values.??
StereoSGBM(int minDisparity, int numDisparities, int SADWindowSize, int P1, int P2, int disp12MaxDiff, int preFilterCap, int uniquenessRatio, int speckleWindowSize, int speckleRange, boolean fullDP)
          Initializes StereoSGBM and sets parameters to custom values.??
 
Method Summary
 void compute(Mat left, Mat right, Mat disp)
           
 int get_disp12MaxDiff()
           
 boolean get_fullDP()
           
 int get_minDisparity()
           
 int get_numberOfDisparities()
           
 int get_P1()
           
 int get_P2()
           
 int get_preFilterCap()
           
 int get_SADWindowSize()
           
 int get_speckleRange()
           
 int get_speckleWindowSize()
           
 int get_uniquenessRatio()
           
 void set_disp12MaxDiff(int disp12MaxDiff)
           
 void set_fullDP(boolean fullDP)
           
 void set_minDisparity(int minDisparity)
           
 void set_numberOfDisparities(int numberOfDisparities)
           
 void set_P1(int P1)
           
 void set_P2(int P2)
           
 void set_preFilterCap(int preFilterCap)
           
 void set_SADWindowSize(int SADWindowSize)
           
 void set_speckleRange(int speckleRange)
           
 void set_speckleWindowSize(int speckleWindowSize)
           
 void set_uniquenessRatio(int uniquenessRatio)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISP_SCALE

public static final int DISP_SCALE
See Also:
Constant Field Values

DISP_SHIFT

public static final int DISP_SHIFT
See Also:
Constant Field Values
Constructor Detail

StereoSGBM

public StereoSGBM()

Initializes StereoSGBM and sets parameters to custom values.??

The first constructor initializes StereoSGBM with all the default parameters. So, you only have to set StereoSGBM.numberOfDisparities at minimum. The second constructor enables you to set each parameter to a custom value.

See Also:
org.opencv.calib3d.StereoSGBM.StereoSGBM

StereoSGBM

public StereoSGBM(int minDisparity,
                  int numDisparities,
                  int SADWindowSize)

Initializes StereoSGBM and sets parameters to custom values.??

The first constructor initializes StereoSGBM with all the default parameters. So, you only have to set StereoSGBM.numberOfDisparities at minimum. The second constructor enables you to set each parameter to a custom value.

Parameters:
minDisparity - Minimum possible disparity value. Normally, it is zero but sometimes rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
numDisparities - Maximum disparity minus minimum disparity. The value is always greater than zero. In the current implementation, this parameter must be divisible by 16.
SADWindowSize - Matched block size. It must be an odd number >=1. Normally, it should be somewhere in the 3..11 range.
See Also:
org.opencv.calib3d.StereoSGBM.StereoSGBM

StereoSGBM

public StereoSGBM(int minDisparity,
                  int numDisparities,
                  int SADWindowSize,
                  int P1,
                  int P2,
                  int disp12MaxDiff,
                  int preFilterCap,
                  int uniquenessRatio,
                  int speckleWindowSize,
                  int speckleRange,
                  boolean fullDP)

Initializes StereoSGBM and sets parameters to custom values.??

The first constructor initializes StereoSGBM with all the default parameters. So, you only have to set StereoSGBM.numberOfDisparities at minimum. The second constructor enables you to set each parameter to a custom value.

Parameters:
minDisparity - Minimum possible disparity value. Normally, it is zero but sometimes rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
numDisparities - Maximum disparity minus minimum disparity. The value is always greater than zero. In the current implementation, this parameter must be divisible by 16.
SADWindowSize - Matched block size. It must be an odd number >=1. Normally, it should be somewhere in the 3..11 range.
P1 - The first parameter controlling the disparity smoothness. See below.
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).
disp12MaxDiff - Maximum allowed difference (in integer pixel units) in the left-right disparity check. Set it to a non-positive value to disable the check.
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.
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.
speckleWindowSize - Maximum size of smooth disparity regions to consider their noise speckles and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the 50-200 range.
speckleRange - Maximum disparity variation within each connected component. If you do speckle filtering, set the parameter to a positive value, it will be implicitly multiplied by 16. Normally, 1 or 2 is good enough.
fullDP - Set it to true 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.
See Also:
org.opencv.calib3d.StereoSGBM.StereoSGBM
Method Detail

compute

public void compute(Mat left,
                    Mat right,
                    Mat disp)

get_disp12MaxDiff

public int get_disp12MaxDiff()

get_fullDP

public boolean get_fullDP()

get_minDisparity

public int get_minDisparity()

get_numberOfDisparities

public int get_numberOfDisparities()

get_P1

public int get_P1()

get_P2

public int get_P2()

get_preFilterCap

public int get_preFilterCap()

get_SADWindowSize

public int get_SADWindowSize()

get_speckleRange

public int get_speckleRange()

get_speckleWindowSize

public int get_speckleWindowSize()

get_uniquenessRatio

public int get_uniquenessRatio()

set_disp12MaxDiff

public void set_disp12MaxDiff(int disp12MaxDiff)

set_fullDP

public void set_fullDP(boolean fullDP)

set_minDisparity

public void set_minDisparity(int minDisparity)

set_numberOfDisparities

public void set_numberOfDisparities(int numberOfDisparities)

set_P1

public void set_P1(int P1)

set_P2

public void set_P2(int P2)

set_preFilterCap

public void set_preFilterCap(int preFilterCap)

set_SADWindowSize

public void set_SADWindowSize(int SADWindowSize)

set_speckleRange

public void set_speckleRange(int speckleRange)

set_speckleWindowSize

public void set_speckleWindowSize(int speckleWindowSize)

set_uniquenessRatio

public void set_uniquenessRatio(int uniquenessRatio)

OpenCV 2.4.7 Documentation