Skip to content

Commit 4a297a2

Browse files
committed
ts: refactor OpenCV tests
- removed tr1 usage (dropped in C++17) - moved includes of vector/map/iostream/limits into ts.hpp - require opencv_test + anonymous namespace (added compile check) - fixed norm() usage (must be from cvtest::norm for checks) and other conflict functions - added missing license headers
1 parent f1e50ec commit 4a297a2

File tree

435 files changed

+2010
-2379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

435 files changed

+2010
-2379
lines changed

modules/calib3d/perf/opencl/perf_stereobm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545

4646
#ifdef HAVE_OPENCL
4747

48-
namespace cvtest {
48+
namespace opencv_test {
4949
namespace ocl {
5050

51-
typedef std::tr1::tuple<int, int> StereoBMFixture_t;
51+
typedef tuple<int, int> StereoBMFixture_t;
5252
typedef TestBaseWithParam<StereoBMFixture_t> StereoBMFixture;
5353

5454
OCL_PERF_TEST_P(StereoBMFixture, StereoBM, ::testing::Combine(OCL_PERF_ENUM(32, 64, 128), OCL_PERF_ENUM(11,21) ) )

modules/calib3d/perf/perf_affine2d.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,9 @@
4343
#include <algorithm>
4444
#include <functional>
4545

46-
namespace cvtest
46+
namespace opencv_test
4747
{
48-
49-
using std::tr1::tuple;
50-
using std::tr1::get;
5148
using namespace perf;
52-
using namespace testing;
53-
using namespace cv;
5449

5550
CV_ENUM(Method, RANSAC, LMEDS)
5651
typedef tuple<int, double, Method, size_t> AffineParams;
@@ -167,4 +162,4 @@ PERF_TEST_P( EstimateAffine, EstimateAffinePartial2D, ESTIMATE_PARAMS )
167162
SANITY_CHECK_NOTHING();
168163
}
169164

170-
} // namespace cvtest
165+
} // namespace opencv_test

modules/calib3d/perf/perf_cicrlesGrid.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#include "perf_precomp.hpp"
22

3-
using namespace std;
4-
using namespace cv;
3+
namespace opencv_test
4+
{
55
using namespace perf;
6-
using std::tr1::make_tuple;
7-
using std::tr1::get;
86

9-
typedef std::tr1::tuple<std::string, cv::Size> String_Size_t;
7+
typedef tuple<std::string, cv::Size> String_Size_t;
108
typedef perf::TestBaseWithParam<String_Size_t> String_Size;
119

1210
PERF_TEST_P(String_Size, asymm_circles_grid, testing::Values(
@@ -40,3 +38,5 @@ PERF_TEST_P(String_Size, asymm_circles_grid, testing::Values(
4038

4139
SANITY_CHECK(ptvec, 2);
4240
}
41+
42+
} // namespace

modules/calib3d/perf/perf_pnp.cpp

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
#include "perf_precomp.hpp"
22

3-
#ifdef HAVE_TBB
4-
#include "tbb/task_scheduler_init.h"
5-
#endif
6-
7-
using namespace std;
8-
using namespace cv;
3+
namespace opencv_test
4+
{
95
using namespace perf;
10-
using std::tr1::make_tuple;
11-
using std::tr1::get;
126

137
CV_ENUM(pnpAlgo, SOLVEPNP_ITERATIVE, SOLVEPNP_EPNP, SOLVEPNP_P3P, SOLVEPNP_DLS, SOLVEPNP_UPNP)
148

15-
typedef std::tr1::tuple<int, pnpAlgo> PointsNum_Algo_t;
9+
typedef tuple<int, pnpAlgo> PointsNum_Algo_t;
1610
typedef perf::TestBaseWithParam<PointsNum_Algo_t> PointsNum_Algo;
1711

1812
typedef perf::TestBaseWithParam<int> PointsNum;
@@ -48,14 +42,14 @@ PERF_TEST_P(PointsNum_Algo, solvePnP,
4842
//add noise
4943
Mat noise(1, (int)points2d.size(), CV_32FC2);
5044
randu(noise, 0, 0.01);
51-
add(points2d, noise, points2d);
45+
cv::add(points2d, noise, points2d);
5246

5347
declare.in(points3d, points2d);
5448
declare.time(100);
5549

5650
TEST_CYCLE_N(1000)
5751
{
58-
solvePnP(points3d, points2d, intrinsics, distortion, rvec, tvec, false, algo);
52+
cv::solvePnP(points3d, points2d, intrinsics, distortion, rvec, tvec, false, algo);
5953
}
6054

6155
SANITY_CHECK(rvec, 1e-6);
@@ -92,22 +86,22 @@ PERF_TEST_P(PointsNum_Algo, solvePnPSmallPoints,
9286

9387
// normalize Rodrigues vector
9488
Mat rvec_tmp = Mat::eye(3, 3, CV_32F);
95-
Rodrigues(rvec, rvec_tmp);
96-
Rodrigues(rvec_tmp, rvec);
89+
cv::Rodrigues(rvec, rvec_tmp);
90+
cv::Rodrigues(rvec_tmp, rvec);
9791

98-
projectPoints(points3d, rvec, tvec, intrinsics, distortion, points2d);
92+
cv::projectPoints(points3d, rvec, tvec, intrinsics, distortion, points2d);
9993

10094
//add noise
10195
Mat noise(1, (int)points2d.size(), CV_32FC2);
10296
randu(noise, -0.001, 0.001);
103-
add(points2d, noise, points2d);
97+
cv::add(points2d, noise, points2d);
10498

10599
declare.in(points3d, points2d);
106100
declare.time(100);
107101

108102
TEST_CYCLE_N(1000)
109103
{
110-
solvePnP(points3d, points2d, intrinsics, distortion, rvec, tvec, false, algo);
104+
cv::solvePnP(points3d, points2d, intrinsics, distortion, rvec, tvec, false, algo);
111105
}
112106

113107
SANITY_CHECK(rvec, 1e-1);
@@ -144,16 +138,13 @@ PERF_TEST_P(PointsNum, DISABLED_SolvePnPRansac, testing::Values(5, 3*9, 7*13))
144138
Mat rvec;
145139
Mat tvec;
146140

147-
#ifdef HAVE_TBB
148-
// limit concurrency to get deterministic result
149-
tbb::task_scheduler_init one_thread(1);
150-
#endif
151-
152141
TEST_CYCLE()
153142
{
154-
solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
143+
cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
155144
}
156145

157146
SANITY_CHECK(rvec, 1e-6);
158147
SANITY_CHECK(tvec, 1e-6);
159148
}
149+
150+
} // namespace
Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
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-
1+
// This file is part of OpenCV project.
2+
// It is subject to the license terms in the LICENSE file found in the top-level directory
3+
// of this distribution and at http://opencv.org/license.html
94
#ifndef __OPENCV_PERF_PRECOMP_HPP__
105
#define __OPENCV_PERF_PRECOMP_HPP__
116

127
#include "opencv2/ts.hpp"
138
#include "opencv2/calib3d.hpp"
14-
#include "opencv2/imgcodecs.hpp"
15-
#include "opencv2/imgproc.hpp"
16-
17-
#ifdef GTEST_CREATE_SHARED_LIBRARY
18-
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
19-
#endif
209

2110
#endif

modules/calib3d/perf/perf_stereosgbm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
#include "perf_precomp.hpp"
3838

39-
namespace cvtest
39+
namespace opencv_test
4040
{
4141
using namespace perf;
4242
using namespace testing;

modules/calib3d/test/opencl/test_stereobm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
#ifdef HAVE_OPENCL
4848

49-
namespace cvtest {
49+
namespace opencv_test {
5050
namespace ocl {
5151

5252
PARAM_TEST_CASE(StereoBMFixture, int, int)

modules/calib3d/test/test_affine2d_estimator.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,7 @@
4141

4242
#include "test_precomp.hpp"
4343

44-
using namespace cv;
45-
using namespace std;
46-
using namespace testing;
47-
48-
#include <vector>
49-
#include <numeric>
44+
namespace opencv_test { namespace {
5045

5146
CV_ENUM(Method, RANSAC, LMEDS)
5247
typedef TestWithParam<Method> EstimateAffine2D;
@@ -156,3 +151,5 @@ TEST_P(EstimateAffine2D, testConversion)
156151
}
157152

158153
INSTANTIATE_TEST_CASE_P(Calib3d, EstimateAffine2D, Method::all());
154+
155+
}} // namespace

modules/calib3d/test/test_affine3.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242

4343
#include "test_precomp.hpp"
4444
#include "opencv2/core/affine.hpp"
45-
#include "opencv2/calib3d.hpp"
46-
#include <iostream>
45+
46+
namespace opencv_test { namespace {
4747

4848
TEST(Calib3d_Affine3f, accuracy)
4949
{
@@ -106,3 +106,5 @@ TEST(Calib3d_Affine3f, accuracy_rvec)
106106
ASSERT_LT(cvtest::norm(va, vo, cv::NORM_L2), 1e-9);
107107
}
108108
}
109+
110+
}} // namespace

modules/calib3d/test/test_affine3d_estimator.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,7 @@
4242

4343
#include "test_precomp.hpp"
4444

45-
using namespace cv;
46-
using namespace std;
47-
48-
#include <string>
49-
#include <iostream>
50-
#include <fstream>
51-
#include <functional>
52-
#include <iterator>
53-
#include <limits>
54-
#include <numeric>
45+
namespace opencv_test { namespace {
5546

5647
class CV_Affine3D_EstTest : public cvtest::BaseTest
5748
{
@@ -101,7 +92,7 @@ bool CV_Affine3D_EstTest::test4Points()
10192
fpts.ptr<Point3f>()[2] = Point3f( rngIn(1,2), rngIn(3,4), rngIn(5, 6) );
10293
fpts.ptr<Point3f>()[3] = Point3f( rngIn(3,4), rngIn(1,2), rngIn(5, 6) );
10394

104-
transform(fpts.ptr<Point3f>(), fpts.ptr<Point3f>() + 4, tpts.ptr<Point3f>(), WrapAff(aff));
95+
std::transform(fpts.ptr<Point3f>(), fpts.ptr<Point3f>() + 4, tpts.ptr<Point3f>(), WrapAff(aff));
10596

10697
Mat aff_est;
10798
vector<uchar> outliers;
@@ -144,11 +135,11 @@ bool CV_Affine3D_EstTest::testNPoints()
144135
Mat tpts(1, n, CV_32FC3);
145136

146137
randu(fpts, Scalar::all(0), Scalar::all(100));
147-
transform(fpts.ptr<Point3f>(), fpts.ptr<Point3f>() + n, tpts.ptr<Point3f>(), WrapAff(aff));
138+
std::transform(fpts.ptr<Point3f>(), fpts.ptr<Point3f>() + n, tpts.ptr<Point3f>(), WrapAff(aff));
148139

149140
/* adding noise*/
150-
transform(tpts.ptr<Point3f>() + m, tpts.ptr<Point3f>() + n, tpts.ptr<Point3f>() + m, bind2nd(plus<Point3f>(), shift_outl));
151-
transform(tpts.ptr<Point3f>() + m, tpts.ptr<Point3f>() + n, tpts.ptr<Point3f>() + m, Noise(noise_level));
141+
std::transform(tpts.ptr<Point3f>() + m, tpts.ptr<Point3f>() + n, tpts.ptr<Point3f>() + m, std::bind2nd(std::plus<Point3f>(), shift_outl));
142+
std::transform(tpts.ptr<Point3f>() + m, tpts.ptr<Point3f>() + n, tpts.ptr<Point3f>() + m, Noise(noise_level));
152143

153144
Mat aff_est;
154145
vector<uchar> outl;
@@ -195,3 +186,5 @@ void CV_Affine3D_EstTest::run( int /* start_from */)
195186
}
196187

197188
TEST(Calib3d_EstimateAffine3D, accuracy) { CV_Affine3D_EstTest test; test.safe_run(); }
189+
190+
}} // namespace

0 commit comments

Comments
 (0)