Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/imgproc/perf/perf_pyramids.cpp
16344 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
#include "perf_precomp.hpp"
5
6
namespace opencv_test {
7
8
PERF_TEST_P(Size_MatType, pyrDown, testing::Combine(
9
testing::Values(sz1080p, sz720p, szVGA, szQVGA, szODD),
10
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4)
11
)
12
)
13
{
14
Size sz = get<0>(GetParam());
15
int matType = get<1>(GetParam());
16
const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5;
17
perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE;
18
19
Mat src(sz, matType);
20
Mat dst((sz.height + 1)/2, (sz.width + 1)/2, matType);
21
22
declare.in(src, WARMUP_RNG).out(dst);
23
24
TEST_CYCLE() pyrDown(src, dst);
25
26
SANITY_CHECK(dst, eps, error_type);
27
}
28
29
PERF_TEST_P(Size_MatType, pyrDown_ovx, testing::Combine(
30
testing::Values(sz1080p, sz720p, szVGA, szQVGA, szODD),
31
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4)
32
)
33
)
34
{
35
Size sz = get<0>(GetParam());
36
int matType = get<1>(GetParam());
37
const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5;
38
perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE;
39
40
Mat src(sz, matType);
41
Mat dst((sz.height + 1) / 2, (sz.width + 1) / 2, matType);
42
43
declare.in(src, WARMUP_RNG).out(dst);
44
45
TEST_CYCLE() pyrDown(src, dst, cv::Size(), BORDER_REPLICATE);
46
47
SANITY_CHECK(dst, eps, error_type);
48
}
49
50
PERF_TEST_P(Size_MatType, pyrUp, testing::Combine(
51
testing::Values(sz720p, szVGA, szQVGA, szODD),
52
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4)
53
)
54
)
55
{
56
Size sz = get<0>(GetParam());
57
int matType = get<1>(GetParam());
58
const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5;
59
perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE;
60
61
Mat src(sz, matType);
62
Mat dst(sz.height*2, sz.width*2, matType);
63
64
declare.in(src, WARMUP_RNG).out(dst);
65
66
TEST_CYCLE() pyrUp(src, dst);
67
68
SANITY_CHECK(dst, eps, error_type);
69
}
70
71
PERF_TEST_P(Size_MatType, buildPyramid, testing::Combine(
72
testing::Values(sz1080p, sz720p, szVGA, szQVGA, szODD),
73
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4)
74
)
75
)
76
{
77
Size sz = get<0>(GetParam());
78
int matType = get<1>(GetParam());
79
int maxLevel = 5;
80
const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5;
81
perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE;
82
Mat src(sz, matType);
83
std::vector<Mat> dst(maxLevel);
84
85
declare.in(src, WARMUP_RNG);
86
87
TEST_CYCLE() buildPyramid(src, dst, maxLevel);
88
89
Mat dst0 = dst[0], dst1 = dst[1], dst2 = dst[2], dst3 = dst[3], dst4 = dst[4];
90
91
SANITY_CHECK(dst0, eps, error_type);
92
SANITY_CHECK(dst1, eps, error_type);
93
SANITY_CHECK(dst2, eps, error_type);
94
SANITY_CHECK(dst3, eps, error_type);
95
SANITY_CHECK(dst4, eps, error_type);
96
}
97
98
} // namespace
99
100