Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/stitching/perf/opencl/perf_stitch.cpp
16348 views
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.
4
//
5
// Copyright (C) 2014, Itseez, Inc, all rights reserved.
6
7
#include "../perf_precomp.hpp"
8
#include "opencv2/ts/ocl_perf.hpp"
9
10
#ifdef HAVE_OPENCL
11
12
namespace opencv_test {
13
using namespace perf;
14
namespace ocl {
15
16
#define SURF_MATCH_CONFIDENCE 0.65f
17
#define ORB_MATCH_CONFIDENCE 0.3f
18
#define WORK_MEGAPIX 0.6
19
20
typedef TestBaseWithParam<string> stitch;
21
22
#ifdef HAVE_OPENCV_XFEATURES2D
23
#define TEST_DETECTORS testing::Values("surf", "orb", "akaze")
24
#else
25
#define TEST_DETECTORS testing::Values("orb", "akaze")
26
#endif
27
28
OCL_PERF_TEST_P(stitch, a123, TEST_DETECTORS)
29
{
30
UMat pano;
31
32
vector<Mat> _imgs;
33
_imgs.push_back( imread( getDataPath("stitching/a1.png") ) );
34
_imgs.push_back( imread( getDataPath("stitching/a2.png") ) );
35
_imgs.push_back( imread( getDataPath("stitching/a3.png") ) );
36
vector<UMat> imgs = ToUMat(_imgs);
37
38
Ptr<detail::FeaturesFinder> featuresFinder = getFeatureFinder(GetParam());
39
Ptr<detail::FeaturesMatcher> featuresMatcher = GetParam() == "orb"
40
? makePtr<detail::BestOf2NearestMatcher>(false, ORB_MATCH_CONFIDENCE)
41
: makePtr<detail::BestOf2NearestMatcher>(false, SURF_MATCH_CONFIDENCE);
42
43
declare.iterations(20);
44
45
while(next())
46
{
47
Stitcher stitcher = Stitcher::createDefault();
48
stitcher.setFeaturesFinder(featuresFinder);
49
stitcher.setFeaturesMatcher(featuresMatcher);
50
stitcher.setWarper(makePtr<SphericalWarper>());
51
stitcher.setRegistrationResol(WORK_MEGAPIX);
52
53
startTimer();
54
stitcher.stitch(imgs, pano);
55
stopTimer();
56
}
57
58
EXPECT_NEAR(pano.size().width, 1182, 50);
59
EXPECT_NEAR(pano.size().height, 682, 30);
60
61
SANITY_CHECK_NOTHING();
62
}
63
64
OCL_PERF_TEST_P(stitch, b12, TEST_DETECTORS)
65
{
66
UMat pano;
67
68
vector<Mat> imgs;
69
imgs.push_back( imread( getDataPath("stitching/b1.png") ) );
70
imgs.push_back( imread( getDataPath("stitching/b2.png") ) );
71
72
Ptr<detail::FeaturesFinder> featuresFinder = getFeatureFinder(GetParam());
73
Ptr<detail::FeaturesMatcher> featuresMatcher = GetParam() == "orb"
74
? makePtr<detail::BestOf2NearestMatcher>(false, ORB_MATCH_CONFIDENCE)
75
: makePtr<detail::BestOf2NearestMatcher>(false, SURF_MATCH_CONFIDENCE);
76
77
declare.iterations(20);
78
79
while(next())
80
{
81
Stitcher stitcher = Stitcher::createDefault();
82
stitcher.setFeaturesFinder(featuresFinder);
83
stitcher.setFeaturesMatcher(featuresMatcher);
84
stitcher.setWarper(makePtr<SphericalWarper>());
85
stitcher.setRegistrationResol(WORK_MEGAPIX);
86
87
startTimer();
88
stitcher.stitch(imgs, pano);
89
stopTimer();
90
}
91
92
EXPECT_NEAR(pano.size().width, 1124, GetParam() == "surf" ? 100 : 50);
93
EXPECT_NEAR(pano.size().height, 644, GetParam() == "surf" ? 60 : 30);
94
95
SANITY_CHECK_NOTHING();
96
}
97
98
OCL_PERF_TEST_P(stitch, boat, TEST_DETECTORS)
99
{
100
Size expected_dst_size(10789, 2663);
101
checkDeviceMaxMemoryAllocSize(expected_dst_size, CV_16SC3, 4);
102
103
#if defined(_WIN32) && !defined(_WIN64)
104
if (cv::ocl::useOpenCL())
105
throw ::perf::TestBase::PerfSkipTestException();
106
#endif
107
108
UMat pano;
109
110
vector<Mat> _imgs;
111
_imgs.push_back( imread( getDataPath("stitching/boat1.jpg") ) );
112
_imgs.push_back( imread( getDataPath("stitching/boat2.jpg") ) );
113
_imgs.push_back( imread( getDataPath("stitching/boat3.jpg") ) );
114
_imgs.push_back( imread( getDataPath("stitching/boat4.jpg") ) );
115
_imgs.push_back( imread( getDataPath("stitching/boat5.jpg") ) );
116
_imgs.push_back( imread( getDataPath("stitching/boat6.jpg") ) );
117
vector<UMat> imgs = ToUMat(_imgs);
118
119
Ptr<detail::FeaturesFinder> featuresFinder = getFeatureFinder(GetParam());
120
Ptr<detail::FeaturesMatcher> featuresMatcher = GetParam() == "orb"
121
? makePtr<detail::BestOf2NearestMatcher>(false, ORB_MATCH_CONFIDENCE)
122
: makePtr<detail::BestOf2NearestMatcher>(false, SURF_MATCH_CONFIDENCE);
123
124
declare.iterations(20);
125
126
while(next())
127
{
128
Stitcher stitcher = Stitcher::createDefault();
129
stitcher.setFeaturesFinder(featuresFinder);
130
stitcher.setFeaturesMatcher(featuresMatcher);
131
stitcher.setWarper(makePtr<SphericalWarper>());
132
stitcher.setRegistrationResol(WORK_MEGAPIX);
133
134
startTimer();
135
stitcher.stitch(imgs, pano);
136
stopTimer();
137
}
138
139
EXPECT_NEAR(pano.size().width, expected_dst_size.width, 200);
140
EXPECT_NEAR(pano.size().height, expected_dst_size.height, 100);
141
142
SANITY_CHECK_NOTHING();
143
}
144
145
} } // namespace opencv_test::ocl
146
147
#endif // HAVE_OPENCL
148
149