Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/imgproc/perf/perf_corners.cpp
16339 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
CV_ENUM(BorderType, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_REFLECT_101)
9
10
typedef tuple<string, int, int, double, BorderType> Img_BlockSize_ApertureSize_k_BorderType_t;
11
typedef perf::TestBaseWithParam<Img_BlockSize_ApertureSize_k_BorderType_t> Img_BlockSize_ApertureSize_k_BorderType;
12
13
PERF_TEST_P(Img_BlockSize_ApertureSize_k_BorderType, cornerHarris,
14
testing::Combine(
15
testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
16
testing::Values( 3, 5 ),
17
testing::Values( 3, 5 ),
18
testing::Values( 0.04, 0.1 ),
19
BorderType::all()
20
)
21
)
22
{
23
string filename = getDataPath(get<0>(GetParam()));
24
int blockSize = get<1>(GetParam());
25
int apertureSize = get<2>(GetParam());
26
double k = get<3>(GetParam());
27
BorderType borderType = get<4>(GetParam());
28
29
Mat src = imread(filename, IMREAD_GRAYSCALE);
30
ASSERT_FALSE(src.empty()) << "Unable to load source image: " << filename;
31
32
Mat dst;
33
34
TEST_CYCLE() cornerHarris(src, dst, blockSize, apertureSize, k, borderType);
35
36
SANITY_CHECK(dst, 2e-5, ERROR_RELATIVE);
37
}
38
39
typedef tuple<string, int, int, BorderType> Img_BlockSize_ApertureSize_BorderType_t;
40
typedef perf::TestBaseWithParam<Img_BlockSize_ApertureSize_BorderType_t> Img_BlockSize_ApertureSize_BorderType;
41
42
PERF_TEST_P(Img_BlockSize_ApertureSize_BorderType, cornerEigenValsAndVecs,
43
testing::Combine(
44
testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
45
testing::Values( 3, 5 ),
46
testing::Values( 3, 5 ),
47
BorderType::all()
48
)
49
)
50
{
51
string filename = getDataPath(get<0>(GetParam()));
52
int blockSize = get<1>(GetParam());
53
int apertureSize = get<2>(GetParam());
54
BorderType borderType = get<3>(GetParam());
55
56
Mat src = imread(filename, IMREAD_GRAYSCALE);
57
ASSERT_FALSE(src.empty()) << "Unable to load source image: " << filename;
58
59
Mat dst;
60
61
TEST_CYCLE() cornerEigenValsAndVecs(src, dst, blockSize, apertureSize, borderType);
62
63
Mat l1;
64
extractChannel(dst, l1, 0);
65
66
SANITY_CHECK(l1, 2e-5, ERROR_RELATIVE);
67
}
68
69
PERF_TEST_P(Img_BlockSize_ApertureSize_BorderType, cornerMinEigenVal,
70
testing::Combine(
71
testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
72
testing::Values( 3, 5 ),
73
testing::Values( 3, 5 ),
74
BorderType::all()
75
)
76
)
77
{
78
string filename = getDataPath(get<0>(GetParam()));
79
int blockSize = get<1>(GetParam());
80
int apertureSize = get<2>(GetParam());
81
BorderType borderType = get<3>(GetParam());
82
83
Mat src = imread(filename, IMREAD_GRAYSCALE);
84
ASSERT_FALSE(src.empty()) << "Unable to load source image: " << filename;
85
86
Mat dst;
87
88
TEST_CYCLE() cornerMinEigenVal(src, dst, blockSize, apertureSize, borderType);
89
90
SANITY_CHECK(dst, 2e-5, ERROR_RELATIVE);
91
}
92
93
} // namespace
94
95