org.opencv.calib3d
public class StereoBM extends java.lang.Object
Class for computing stereo correspondence using the block matching algorithm.
// Block matching stereo correspondence algorithm class StereoBM
// C++ code:
enum { NORMALIZED_RESPONSE = CV_STEREO_BM_NORMALIZED_RESPONSE,
BASIC_PRESET=CV_STEREO_BM_BASIC,
FISH_EYE_PRESET=CV_STEREO_BM_FISH_EYE,
NARROW_PRESET=CV_STEREO_BM_NARROW };
StereoBM();
// the preset is one of..._PRESET above.
// ndisparities is the size of disparity range,
// in which the optimal disparity at each pixel is searched for.
// SADWindowSize is the size of averaging window used to match pixel blocks
// (larger values mean better robustness to noise, but yield blurry disparity maps)
StereoBM(int preset, int ndisparities=0, int SADWindowSize=21);
// separate initialization function
void init(int preset, int ndisparities=0, int SADWindowSize=21);
// computes the disparity for the two rectified 8-bit single-channel images.
// the disparity will be 16-bit signed (fixed-point) or 32-bit floating-point image of the same size as left.
void operator()(InputArray left, InputArray right, OutputArray disparity, int disptype=CV_16S);
Ptr
};
The class is a C++ wrapper for the associated functions. In particular, :ocv:funcx:"StereoBM.operator()" is the wrapper for
"cvFindStereoCorrespondenceBM"... Sample code:
(Ocl) An example for using the stereoBM matching algorithm can be found at opencv_source_code/samples/ocl/stereo_match.cpp
Modifier and Type | Field and Description |
---|---|
static int |
BASIC_PRESET |
static int |
FISH_EYE_PRESET |
static int |
NARROW_PRESET |
static int |
PREFILTER_NORMALIZED_RESPONSE |
static int |
PREFILTER_XSOBEL |
Constructor and Description |
---|
StereoBM()
The constructors.
|
StereoBM(int preset)
The constructors.
|
StereoBM(int preset,
int ndisparities,
int SADWindowSize)
The constructors.
|
Modifier and Type | Method and Description |
---|---|
void |
compute(Mat left,
Mat right,
Mat disparity)
Computes disparity using the BM algorithm for a rectified stereo pair.
|
void |
compute(Mat left,
Mat right,
Mat disparity,
int disptype)
Computes disparity using the BM algorithm for a rectified stereo pair.
|
public static final int BASIC_PRESET
public static final int FISH_EYE_PRESET
public static final int NARROW_PRESET
public static final int PREFILTER_NORMALIZED_RESPONSE
public static final int PREFILTER_XSOBEL
public StereoBM()
The constructors.
The constructors initialize StereoBM
state. You can then call
StereoBM.operator()
to compute disparity for a specific stereo
pair.
Note: In the C API you need to deallocate CvStereoBM
state when
it is not needed anymore using cvReleaseStereoBMState(&stereobm)
.
public StereoBM(int preset)
The constructors.
The constructors initialize StereoBM
state. You can then call
StereoBM.operator()
to compute disparity for a specific stereo
pair.
Note: In the C API you need to deallocate CvStereoBM
state when
it is not needed anymore using cvReleaseStereoBMState(&stereobm)
.
preset
- specifies the whole set of algorithm parameters, one of:
After constructing the class, you can override any parameters set by the preset.
public StereoBM(int preset, int ndisparities, int SADWindowSize)
The constructors.
The constructors initialize StereoBM
state. You can then call
StereoBM.operator()
to compute disparity for a specific stereo
pair.
Note: In the C API you need to deallocate CvStereoBM
state when
it is not needed anymore using cvReleaseStereoBMState(&stereobm)
.
preset
- specifies the whole set of algorithm parameters, one of:
After constructing the class, you can override any parameters set by the preset.
ndisparities
- the disparity search range. For each pixel algorithm will
find the best disparity from 0 (default minimum disparity) to
ndisparities
. The search range can then be shifted by changing
the minimum disparity.SADWindowSize
- the linear size of the blocks compared by the algorithm.
The size should be odd (as the block is centered at the current pixel).
Larger block size implies smoother, though less accurate disparity map.
Smaller block size gives more detailed disparity map, but there is higher
chance for algorithm to find a wrong correspondence.public void compute(Mat left, Mat right, Mat disparity)
Computes disparity using the BM algorithm for a rectified stereo pair.
The method executes the BM algorithm on a rectified stereo pair. See the
stereo_match.cpp
OpenCV sample on how to prepare images and call
the method. Note that the method is not constant, thus you should not use the
same StereoBM
instance from within different threads
simultaneously. The function is parallelized with the TBB library.
left
- Left 8-bit single-channel image.right
- Right image of the same size and the same type as the left one.disparity
- Output disparity map. It has the same size as the input
images. When disptype==CV_16S
, the map is a 16-bit signed
single-channel image, containing disparity values scaled by 16. To get the
true disparity values from such fixed-point representation, you will need to
divide each disp
element by 16. If disptype==CV_32F
,
the disparity map will already contain the real disparity values on output.public void compute(Mat left, Mat right, Mat disparity, int disptype)
Computes disparity using the BM algorithm for a rectified stereo pair.
The method executes the BM algorithm on a rectified stereo pair. See the
stereo_match.cpp
OpenCV sample on how to prepare images and call
the method. Note that the method is not constant, thus you should not use the
same StereoBM
instance from within different threads
simultaneously. The function is parallelized with the TBB library.
left
- Left 8-bit single-channel image.right
- Right image of the same size and the same type as the left one.disparity
- Output disparity map. It has the same size as the input
images. When disptype==CV_16S
, the map is a 16-bit signed
single-channel image, containing disparity values scaled by 16. To get the
true disparity values from such fixed-point representation, you will need to
divide each disp
element by 16. If disptype==CV_32F
,
the disparity map will already contain the real disparity values on output.disptype
- Type of the output disparity map, CV_16S
(default) or CV_32F
.