Skip to content

Commit a102eeb

Browse files
committed
added the SGBM and asserts in bm
removed warnings clip tab warning fixed fixed tab size warning added a new sample the new sample fixed spacing problem added a testing for the penalties fixed sample warning fixed last warnings added tests and modified a bit the sources added the tests fixed warning removed redundant samples Rename Sample3.cpp to sample.cpp renamed from Sample3 to sample refactored sample repaired descriptor test added test data usless info erased from test block matching added last tests did some modifications to the files whitespace removal did some modifications to the testing files fixed test descriptor issue Revert "whitespace removal" This reverts commit 76d4aa5. corrected part of the comments made modifications so the sources build successfully fixed some issue for sub pixel refactored sample fixed small issue at testing added some performance files performance tests and other corrections corrected the paths and added some images fixed a bug Delete imgKitty.bmp Delete imgKittyl.bmp performance tests again.... added larger images fixed issues did some last changes added the copyright notice fixed some linux errors
1 parent 707beb3 commit a102eeb

24 files changed

+1538
-453
lines changed

modules/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ $ cmake -D OPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules -D BUILD_opencv_re
5252

5353
22. **opencv_xphoto**: Additional photo processing algorithms: Color balance / Denoising / Inpainting.
5454

55-
23. **opencv_stereo**: Stereo Correspondence done with different descriptors: Census / CS-Census / MCT / BRIEF / MV / RT.
55+
23. **opencv_stereo**: Stereo Correspondence done with different descriptors: Census / CS-Census / MCT / BRIEF / MV.

modules/stereo/include/opencv2/stereo.hpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,10 @@ namespace cv
5959
{
6060
namespace stereo
6161
{
62-
6362
//! @addtogroup stereo
6463
//! @{
6564
// void correctMatches( InputArray F, InputArray points1, InputArray points2,
6665
// OutputArray newPoints1, OutputArray newPoints2 );
67-
enum {
68-
CV_SPECKLE_REMOVAL_ALGORITHM, CV_SPECKLE_REMOVAL_AVG_ALGORITHM
69-
};
7066
/** @brief Filters off small noise blobs (speckles) in the disparity map
7167
@param img The input 16-bit signed disparity image
7268
@param newVal The disparity value used to paint-off the speckles
@@ -117,8 +113,14 @@ namespace cv
117113
virtual void setDisp12MaxDiff(int disp12MaxDiff) = 0;
118114

119115
};
120-
121-
116+
//!speckle removal algorithms. These algorithms have the purpose of removing small regions
117+
enum {
118+
CV_SPECKLE_REMOVAL_ALGORITHM, CV_SPECKLE_REMOVAL_AVG_ALGORITHM
119+
};
120+
//!subpixel interpolationm methods for disparities.
121+
enum{
122+
CV_QUADRATIC_INTERPOLATION, CV_SIMETRICV_INTERPOLATION
123+
};
122124
/** @brief Class for computing stereo correspondence using the block matching algorithm, introduced and
123125
contributed to OpenCV by K. Konolige.
124126
*/
@@ -174,7 +176,7 @@ namespace cv
174176
The function create StereoBM object. You can then call StereoBM::compute() to compute disparity for
175177
a specific stereo pair.
176178
*/
177-
CV_EXPORTS static Ptr< cv::stereo::StereoBinaryBM > create(int numDisparities = 0, int blockSize = 21);
179+
CV_EXPORTS static Ptr< cv::stereo::StereoBinaryBM > create(int numDisparities = 0, int blockSize = 9);
178180
};
179181

180182
/** @brief The class implements the modified H. Hirschmuller algorithm @cite HH08 that differs from the original
@@ -219,6 +221,15 @@ namespace cv
219221
virtual int getMode() const = 0;
220222
virtual void setMode(int mode) = 0;
221223

224+
virtual int getSpekleRemovalTechnique() const = 0 ;
225+
virtual void setSpekleRemovalTechnique(int factor) = 0;
226+
227+
virtual int getBinaryKernelType() const = 0;
228+
virtual void setBinaryKernelType(int value) = 0;
229+
230+
virtual int getSubPixelInterpolationMethod() const = 0;
231+
virtual void setSubPixelInterpolationMethod(int value) = 0;
232+
222233
/** @brief Creates StereoSGBM object
223234
224235
@param minDisparity Minimum possible disparity value. Normally, it is zero but sometimes
@@ -257,9 +268,9 @@ namespace cv
257268
to a custom value.
258269
*/
259270
CV_EXPORTS static Ptr<cv::stereo::StereoBinarySGBM> create(int minDisparity, int numDisparities, int blockSize,
260-
int P1 = 100, int P2 = 1000, int disp12MaxDiff = 0,
261-
int preFilterCap = 0, int uniquenessRatio = 0,
262-
int speckleWindowSize = 0, int speckleRange = 0,
271+
int P1 = 100, int P2 = 1000, int disp12MaxDiff = 1,
272+
int preFilterCap = 0, int uniquenessRatio = 5,
273+
int speckleWindowSize = 400, int speckleRange = 200,
263274
int mode = StereoBinarySGBM::MODE_SGBM);
264275
};
265276
//! @}

modules/stereo/perf/perf_bm.cpp

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*M///////////////////////////////////////////////////////////////////////////////////////
2+
//
3+
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4+
//
5+
// By downloading, copying, installing or using the software you agree to this license.
6+
// If you do not agree to this license, do not download, install,
7+
// copy or use the software.
8+
//
9+
//
10+
// License Agreement
11+
// For Open Source Computer Vision Library
12+
//
13+
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14+
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15+
// Third party copyrights are property of their respective owners.
16+
//
17+
// Redistribution and use in source and binary forms, with or without modification,
18+
// are permitted provided that the following conditions are met:
19+
//
20+
// * Redistribution's of source code must retain the above copyright notice,
21+
// this list of conditions and the following disclaimer.
22+
//
23+
// * Redistribution's in binary form must reproduce the above copyright notice,
24+
// this list of conditions and the following disclaimer in the documentation
25+
// and/or other materials provided with the distribution.
26+
//
27+
// * The name of the copyright holders may not be used to endorse or promote products
28+
// derived from this software without specific prior written permission.
29+
//
30+
// This software is provided by the copyright holders and contributors "as is" and
31+
// any express or implied warranties, including, but not limited to, the implied
32+
// warranties of merchantability and fitness for a particular purpose are disclaimed.
33+
// In no event shall the Intel Corporation or contributors be liable for any direct,
34+
// indirect, incidental, special, exemplary, or consequential damages
35+
// (including, but not limited to, procurement of substitute goods or services;
36+
// loss of use, data, or profits; or business interruption) however caused
37+
// and on any theory of liability, whether in contract, strict liability,
38+
// or tort (including negligence or otherwise) arising in any way out of
39+
// the use of this software, even if advised of the possibility of such damage.
40+
//
41+
//M*/
42+
43+
#include "perf_precomp.hpp"
44+
45+
using namespace std;
46+
using namespace cv;
47+
using namespace cv::stereo;
48+
using namespace perf;
49+
50+
typedef std::tr1::tuple<Size, MatType, MatDepth> s_bm_test_t;
51+
typedef perf::TestBaseWithParam<s_bm_test_t> s_bm;
52+
53+
PERF_TEST_P( s_bm, sgm_perf,
54+
testing::Combine(
55+
testing::Values( cv::Size(512, 283), cv::Size(320, 240)),
56+
testing::Values( CV_8UC1,CV_8U ),
57+
testing::Values( CV_8UC1,CV_8U,CV_16S )
58+
)
59+
)
60+
{
61+
Size sz = std::tr1::get<0>(GetParam());
62+
int matType = std::tr1::get<1>(GetParam());
63+
int sdepth = std::tr1::get<2>(GetParam());
64+
65+
Mat left(sz, matType);
66+
Mat right(sz, matType);
67+
Mat out1(sz, sdepth);
68+
Ptr<StereoBinarySGBM> sgbm = StereoBinarySGBM::create(0, 16, 5);
69+
sgbm->setBinaryKernelType(CV_DENSE_CENSUS);
70+
declare.in(left, WARMUP_RNG)
71+
.out(out1)
72+
.time(0.1)
73+
.iterations(20);
74+
TEST_CYCLE()
75+
{
76+
sgbm->compute(left, right, out1);
77+
}
78+
SANITY_CHECK(out1);
79+
}
80+
PERF_TEST_P( s_bm, bm_perf,
81+
testing::Combine(
82+
testing::Values( cv::Size(512, 383), cv::Size(320, 240) ),
83+
testing::Values( CV_8UC1,CV_8U ),
84+
testing::Values( CV_8UC1,CV_8U )
85+
)
86+
)
87+
{
88+
Size sz = std::tr1::get<0>(GetParam());
89+
int matType = std::tr1::get<1>(GetParam());
90+
int sdepth = std::tr1::get<2>(GetParam());
91+
92+
Mat left(sz, matType);
93+
Mat right(sz, matType);
94+
Mat out1(sz, sdepth);
95+
Ptr<StereoBinaryBM> sbm = StereoBinaryBM::create(16, 9);
96+
// we set the corresponding parameters
97+
sbm->setPreFilterCap(31);
98+
sbm->setMinDisparity(0);
99+
sbm->setTextureThreshold(10);
100+
sbm->setUniquenessRatio(0);
101+
sbm->setSpeckleWindowSize(400);
102+
sbm->setDisp12MaxDiff(0);
103+
sbm->setAgregationWindowSize(11);
104+
// the user can choose between the average speckle removal algorithm or
105+
// the classical version that was implemented in OpenCV
106+
sbm->setSpekleRemovalTechnique(CV_SPECKLE_REMOVAL_AVG_ALGORITHM);
107+
sbm->setUsePrefilter(false);
108+
109+
declare.in(left, WARMUP_RNG)
110+
.out(out1)
111+
.time(0.1)
112+
.iterations(20);
113+
TEST_CYCLE()
114+
{
115+
sbm->compute(left, right, out1);
116+
}
117+
SANITY_CHECK(out1);
118+
}
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*M///////////////////////////////////////////////////////////////////////////////////////
2+
//
3+
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4+
//
5+
// By downloading, copying, installing or using the software you agree to this license.
6+
// If you do not agree to this license, do not download, install,
7+
// copy or use the software.
8+
//
9+
//
10+
// License Agreement
11+
// For Open Source Computer Vision Library
12+
//
13+
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14+
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15+
// Third party copyrights are property of their respective owners.
16+
//
17+
// Redistribution and use in source and binary forms, with or without modification,
18+
// are permitted provided that the following conditions are met:
19+
//
20+
// * Redistribution's of source code must retain the above copyright notice,
21+
// this list of conditions and the following disclaimer.
22+
//
23+
// * Redistribution's in binary form must reproduce the above copyright notice,
24+
// this list of conditions and the following disclaimer in the documentation
25+
// and/or other materials provided with the distribution.
26+
//
27+
// * The name of the copyright holders may not be used to endorse or promote products
28+
// derived from this software without specific prior written permission.
29+
//
30+
// This software is provided by the copyright holders and contributors "as is" and
31+
// any express or implied warranties, including, but not limited to, the implied
32+
// warranties of merchantability and fitness for a particular purpose are disclaimed.
33+
// In no event shall the Intel Corporation or contributors be liable for any direct,
34+
// indirect, incidental, special, exemplary, or consequential damages
35+
// (including, but not limited to, procurement of substitute goods or services;
36+
// loss of use, data, or profits; or business interruption) however caused
37+
// and on any theory of liability, whether in contract, strict liability,
38+
// or tort (including negligence or otherwise) arising in any way out of
39+
// the use of this software, even if advised of the possibility of such damage.
40+
//
41+
//M*/
42+
#include "perf_precomp.hpp"
43+
44+
using namespace std;
45+
using namespace cv;
46+
using namespace cv::stereo;
47+
using namespace perf;
48+
49+
typedef std::tr1::tuple<Size, MatType, MatDepth> descript_params_t;
50+
typedef perf::TestBaseWithParam<descript_params_t> descript_params;
51+
52+
PERF_TEST_P( descript_params, census_sparse_descriptor,
53+
testing::Combine(
54+
testing::Values( TYPICAL_MAT_SIZES ),
55+
testing::Values( CV_8UC1,CV_8U ),
56+
testing::Values( CV_32SC4,CV_32S )
57+
)
58+
)
59+
{
60+
Size sz = std::tr1::get<0>(GetParam());
61+
int matType = std::tr1::get<1>(GetParam());
62+
int sdepth = std::tr1::get<2>(GetParam());
63+
Mat left(sz, matType);
64+
Mat out1(sz, sdepth);
65+
declare.in(left, WARMUP_RNG)
66+
.out(out1)
67+
.time(0.01);
68+
TEST_CYCLE()
69+
{
70+
censusTransform(left,9,out1,CV_SPARSE_CENSUS);
71+
}
72+
SANITY_CHECK(out1);
73+
}
74+
PERF_TEST_P( descript_params, star_census_transform,
75+
testing::Combine(
76+
testing::Values( TYPICAL_MAT_SIZES ),
77+
testing::Values( CV_8UC1,CV_8U ),
78+
testing::Values( CV_32SC4,CV_32S )
79+
)
80+
)
81+
{
82+
Size sz = std::tr1::get<0>(GetParam());
83+
int matType = std::tr1::get<1>(GetParam());
84+
int sdepth = std::tr1::get<2>(GetParam());
85+
Mat left(sz, matType);
86+
Mat out1(sz, sdepth);
87+
declare.in(left, WARMUP_RNG)
88+
.out(out1)
89+
.time(0.01);
90+
TEST_CYCLE()
91+
{
92+
starCensusTransform(left,9,out1);
93+
}
94+
SANITY_CHECK(out1);
95+
}
96+
PERF_TEST_P( descript_params, modified_census_transform,
97+
testing::Combine(
98+
testing::Values( TYPICAL_MAT_SIZES ),
99+
testing::Values( CV_8UC1,CV_8U ),
100+
testing::Values( CV_32SC4,CV_32S )
101+
)
102+
)
103+
{
104+
Size sz = std::tr1::get<0>(GetParam());
105+
int matType = std::tr1::get<1>(GetParam());
106+
int sdepth = std::tr1::get<2>(GetParam());
107+
108+
Mat left(sz, matType);
109+
Mat out1(sz, sdepth);
110+
111+
declare.in(left, WARMUP_RNG)
112+
.out(out1)
113+
.time(0.01);
114+
TEST_CYCLE()
115+
{
116+
modifiedCensusTransform(left,9,out1,CV_MODIFIED_CENSUS_TRANSFORM);
117+
}
118+
SANITY_CHECK(out1);
119+
}
120+
PERF_TEST_P( descript_params, center_symetric_census,
121+
testing::Combine(
122+
testing::Values( TYPICAL_MAT_SIZES ),
123+
testing::Values( CV_8UC1,CV_8U ),
124+
testing::Values( CV_32SC4,CV_32S )
125+
)
126+
)
127+
{
128+
Size sz = std::tr1::get<0>(GetParam());
129+
int matType = std::tr1::get<1>(GetParam());
130+
int sdepth = std::tr1::get<2>(GetParam());
131+
132+
Mat left(sz, matType);
133+
Mat out1(sz, sdepth);
134+
135+
declare.in(left, WARMUP_RNG)
136+
.out(out1)
137+
.time(0.01);
138+
TEST_CYCLE()
139+
{
140+
symetricCensusTransform(left,7,out1,CV_CS_CENSUS);
141+
}
142+
SANITY_CHECK(out1);
143+
}

modules/stereo/perf/perf_main.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*M///////////////////////////////////////////////////////////////////////////////////////
2+
//
3+
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4+
//
5+
// By downloading, copying, installing or using the software you agree to this license.
6+
// If you do not agree to this license, do not download, install,
7+
// copy or use the software.
8+
//
9+
//
10+
// License Agreement
11+
// For Open Source Computer Vision Library
12+
//
13+
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14+
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15+
// Third party copyrights are property of their respective owners.
16+
//
17+
// Redistribution and use in source and binary forms, with or without modification,
18+
// are permitted provided that the following conditions are met:
19+
//
20+
// * Redistribution's of source code must retain the above copyright notice,
21+
// this list of conditions and the following disclaimer.
22+
//
23+
// * Redistribution's in binary form must reproduce the above copyright notice,
24+
// this list of conditions and the following disclaimer in the documentation
25+
// and/or other materials provided with the distribution.
26+
//
27+
// * The name of the copyright holders may not be used to endorse or promote products
28+
// derived from this software without specific prior written permission.
29+
//
30+
// This software is provided by the copyright holders and contributors "as is" and
31+
// any express or implied warranties, including, but not limited to, the implied
32+
// warranties of merchantability and fitness for a particular purpose are disclaimed.
33+
// In no event shall the Intel Corporation or contributors be liable for any direct,
34+
// indirect, incidental, special, exemplary, or consequential damages
35+
// (including, but not limited to, procurement of substitute goods or services;
36+
// loss of use, data, or profits; or business interruption) however caused
37+
// and on any theory of liability, whether in contract, strict liability,
38+
// or tort (including negligence or otherwise) arising in any way out of
39+
// the use of this software, even if advised of the possibility of such damage.
40+
//
41+
//M*/
42+
#include "perf_precomp.hpp"
43+
44+
CV_PERF_TEST_MAIN(stereo)

0 commit comments

Comments
 (0)