mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 14:13:15 +08:00
removed preset parameter in createStereoBM, updated stereo_match sample
This commit is contained in:
parent
b6efe30527
commit
df89f30b4a
@ -677,10 +677,9 @@ public:
|
||||
OutputArray disparity ) = 0;
|
||||
};
|
||||
|
||||
enum { STEREO_DISP_SCALE=16, STEREO_PREFILTER_NORMALIZED_RESPONSE = 0, STEREO_PREFILTER_XSOBEL = 1,
|
||||
STEREOBM_BASIC_PRESET=0, STEREOBM_FISH_EYE_PRESET=1, STEREOBM_NARROW_PRESET=2 };
|
||||
enum { STEREO_DISP_SCALE=16, STEREO_PREFILTER_NORMALIZED_RESPONSE = 0, STEREO_PREFILTER_XSOBEL = 1 };
|
||||
|
||||
CV_EXPORTS Ptr<StereoMatcher> createStereoBM(int preset, int numDisparities=0, int SADWindowSize=21);
|
||||
CV_EXPORTS Ptr<StereoMatcher> createStereoBM(int numDisparities=0, int SADWindowSize=21);
|
||||
|
||||
CV_EXPORTS Ptr<StereoMatcher> createStereoSGBM(int minDisparity, int numDisparities, int SADWindowSize,
|
||||
int P1=0, int P2=0, int disp12MaxDiff=0,
|
||||
@ -695,9 +694,7 @@ class CV_EXPORTS_W StereoBM
|
||||
{
|
||||
public:
|
||||
enum { PREFILTER_NORMALIZED_RESPONSE = 0, PREFILTER_XSOBEL = 1,
|
||||
BASIC_PRESET=STEREOBM_BASIC_PRESET,
|
||||
FISH_EYE_PRESET=STEREOBM_FISH_EYE_PRESET,
|
||||
NARROW_PRESET=STEREOBM_NARROW_PRESET };
|
||||
BASIC_PRESET=0, FISH_EYE_PRESET=1, NARROW_PRESET=2 };
|
||||
|
||||
//! the default constructor
|
||||
CV_WRAP StereoBM();
|
||||
|
@ -95,8 +95,7 @@ void cvFindStereoCorrespondenceBM( const CvArr* leftarr, const CvArr* rightarr,
|
||||
|
||||
CV_Assert( state != 0 );
|
||||
|
||||
cv::Ptr<cv::StereoMatcher> sm = cv::createStereoBM(cv::STEREOBM_BASIC_PRESET,
|
||||
state->numberOfDisparities,
|
||||
cv::Ptr<cv::StereoMatcher> sm = cv::createStereoBM(state->numberOfDisparities,
|
||||
state->SADWindowSize);
|
||||
sm->set("preFilterType", state->preFilterType);
|
||||
sm->set("preFilterSize", state->preFilterSize);
|
||||
@ -130,7 +129,7 @@ namespace cv
|
||||
{
|
||||
|
||||
StereoBM::StereoBM()
|
||||
{ init(STEREOBM_BASIC_PRESET); }
|
||||
{ init(BASIC_PRESET); }
|
||||
|
||||
StereoBM::StereoBM(int _preset, int _ndisparities, int _SADWindowSize)
|
||||
{ init(_preset, _ndisparities, _SADWindowSize); }
|
||||
|
@ -54,7 +54,7 @@ namespace cv
|
||||
|
||||
struct StereoBMParams
|
||||
{
|
||||
StereoBMParams(int _preset=STEREOBM_BASIC_PRESET, int _numDisparities=64, int _SADWindowSize=21)
|
||||
StereoBMParams(int _numDisparities=64, int _SADWindowSize=21)
|
||||
{
|
||||
preFilterType = STEREO_PREFILTER_XSOBEL;
|
||||
preFilterSize = 9;
|
||||
@ -780,9 +780,9 @@ public:
|
||||
params = StereoBMParams();
|
||||
}
|
||||
|
||||
StereoBMImpl( int _preset, int _numDisparities, int _SADWindowSize )
|
||||
StereoBMImpl( int _numDisparities, int _SADWindowSize )
|
||||
{
|
||||
params = StereoBMParams(_preset, _numDisparities, _SADWindowSize);
|
||||
params = StereoBMParams(_numDisparities, _SADWindowSize);
|
||||
}
|
||||
|
||||
void compute( InputArray leftarr, InputArray rightarr, OutputArray disparr )
|
||||
@ -927,9 +927,9 @@ CV_INIT_ALGORITHM(StereoBMImpl, "StereoMatcher.BM",
|
||||
|
||||
}
|
||||
|
||||
cv::Ptr<cv::StereoMatcher> cv::createStereoBM(int _preset, int _numDisparities, int _SADWindowSize)
|
||||
cv::Ptr<cv::StereoMatcher> cv::createStereoBM(int _numDisparities, int _SADWindowSize)
|
||||
{
|
||||
return new StereoBMImpl(_preset, _numDisparities, _SADWindowSize);
|
||||
return new StereoBMImpl(_numDisparities, _SADWindowSize);
|
||||
}
|
||||
|
||||
/* End of file. */
|
||||
|
@ -66,8 +66,8 @@ int main(int argc, char** argv)
|
||||
bool no_display = false;
|
||||
float scale = 1.f;
|
||||
|
||||
StereoBM bm;
|
||||
StereoSGBM sgbm;
|
||||
Ptr<StereoMatcher> bm = createStereoBM(16,9);
|
||||
Ptr<StereoMatcher> sgbm = createStereoSGBM(0,16,3);
|
||||
StereoVar var;
|
||||
|
||||
for( int i = 1; i < argc; i++ )
|
||||
@ -220,32 +220,33 @@ int main(int argc, char** argv)
|
||||
|
||||
numberOfDisparities = numberOfDisparities > 0 ? numberOfDisparities : ((img_size.width/8) + 15) & -16;
|
||||
|
||||
bm.state->roi1 = roi1;
|
||||
bm.state->roi2 = roi2;
|
||||
bm.state->preFilterCap = 31;
|
||||
bm.state->SADWindowSize = SADWindowSize > 0 ? SADWindowSize : 9;
|
||||
bm.state->minDisparity = 0;
|
||||
bm.state->numberOfDisparities = numberOfDisparities;
|
||||
bm.state->textureThreshold = 10;
|
||||
bm.state->uniquenessRatio = 15;
|
||||
bm.state->speckleWindowSize = 100;
|
||||
bm.state->speckleRange = 32;
|
||||
bm.state->disp12MaxDiff = 1;
|
||||
//bm->set("roi1", roi1);
|
||||
//bm->set("roi2", roi2);
|
||||
bm->set("preFilterCap", 31);
|
||||
bm->set("SADWindowSize", SADWindowSize > 0 ? SADWindowSize : 9);
|
||||
bm->set("minDisparity", 0);
|
||||
bm->set("numDisparities", numberOfDisparities);
|
||||
bm->set("textureThreshold", 10);
|
||||
bm->set("uniquenessRatio", 15);
|
||||
bm->set("speckleWindowSize", 100);
|
||||
bm->set("speckleRange", 32);
|
||||
bm->set("disp12MaxDiff", 1);
|
||||
|
||||
sgbm.preFilterCap = 63;
|
||||
sgbm.SADWindowSize = SADWindowSize > 0 ? SADWindowSize : 3;
|
||||
sgbm->set("preFilterCap", 63);
|
||||
int sgbmWinSize = SADWindowSize > 0 ? SADWindowSize : 3;
|
||||
sgbm->set("SADWindowSize", sgbmWinSize);
|
||||
|
||||
int cn = img1.channels();
|
||||
|
||||
sgbm.P1 = 8*cn*sgbm.SADWindowSize*sgbm.SADWindowSize;
|
||||
sgbm.P2 = 32*cn*sgbm.SADWindowSize*sgbm.SADWindowSize;
|
||||
sgbm.minDisparity = 0;
|
||||
sgbm.numberOfDisparities = numberOfDisparities;
|
||||
sgbm.uniquenessRatio = 10;
|
||||
sgbm.speckleWindowSize = bm.state->speckleWindowSize;
|
||||
sgbm.speckleRange = bm.state->speckleRange;
|
||||
sgbm.disp12MaxDiff = 1;
|
||||
sgbm.fullDP = alg == STEREO_HH;
|
||||
sgbm->set("P1", 8*cn*sgbmWinSize*sgbmWinSize);
|
||||
sgbm->set("P2", 32*cn*sgbmWinSize*sgbmWinSize);
|
||||
sgbm->set("minDisparity", 0);
|
||||
sgbm->set("numDisparities", numberOfDisparities);
|
||||
sgbm->set("uniquenessRatio", 10);
|
||||
sgbm->set("speckleWindowSize", 100);
|
||||
sgbm->set("speckleRange", 32);
|
||||
sgbm->set("disp12MaxDiff", 1);
|
||||
sgbm->set("fullDP", alg == STEREO_HH);
|
||||
|
||||
var.levels = 3; // ignored with USE_AUTO_PARAMS
|
||||
var.pyrScale = 0.5; // ignored with USE_AUTO_PARAMS
|
||||
@ -267,12 +268,12 @@ int main(int argc, char** argv)
|
||||
|
||||
int64 t = getTickCount();
|
||||
if( alg == STEREO_BM )
|
||||
bm(img1, img2, disp);
|
||||
bm->compute(img1, img2, disp);
|
||||
else if( alg == STEREO_VAR ) {
|
||||
var(img1, img2, disp);
|
||||
}
|
||||
else if( alg == STEREO_SGBM || alg == STEREO_HH )
|
||||
sgbm(img1, img2, disp);
|
||||
sgbm->compute(img1, img2, disp);
|
||||
t = getTickCount() - t;
|
||||
printf("Time elapsed: %fms\n", t*1000/getTickFrequency());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user