Skip to content

Commit 2b64abd

Browse files
committed
Merge pull request #326 from MMp131316:MatchingOperations
2 parents bf0c871 + 12b530c commit 2b64abd

23 files changed

+4005
-1770
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: 221 additions & 198 deletions
Large diffs are not rendered by default.

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)

modules/stereo/perf/perf_precomp.hpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#ifdef __GNUC__
2+
# pragma GCC diagnostic ignored "-Wmissing-declarations"
3+
# if defined __clang__ || defined __APPLE__
4+
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
5+
# pragma GCC diagnostic ignored "-Wextra"
6+
# endif
7+
#endif
8+
9+
#ifndef __OPENCV_PERF_PRECOMP_HPP__
10+
#define __OPENCV_PERF_PRECOMP_HPP__
11+
12+
#include <iostream>
13+
#include "opencv2/ts.hpp"
14+
#include "opencv2/imgcodecs.hpp"
15+
#include "opencv2/stereo.hpp"
16+
#include "opencv2/imgproc.hpp"
17+
#include "opencv2/features2d.hpp"
18+
#include "opencv2/core/utility.hpp"
19+
#include "opencv2/core/private.hpp"
20+
#include "opencv2/core/cvdef.h"
21+
#include "opencv2/core.hpp"
22+
#include "opencv2/highgui.hpp"
23+
#include "opencv2/calib3d.hpp"
24+
25+
#include <algorithm>
26+
#include <cmath>
27+
28+
#ifdef GTEST_CREATE_SHARED_LIBRARY
29+
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
30+
#endif
31+
32+
#endif

0 commit comments

Comments
 (0)