Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/imgproc/perf/perf_distanceTransform.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
CV_ENUM(DistanceType, DIST_L1, DIST_L2 , DIST_C)
9
CV_ENUM(MaskSize, DIST_MASK_3, DIST_MASK_5, DIST_MASK_PRECISE)
10
CV_ENUM(DstType, CV_8U, CV_32F)
11
CV_ENUM(LabelType, DIST_LABEL_CCOMP, DIST_LABEL_PIXEL)
12
13
typedef tuple<Size, DistanceType, MaskSize, DstType> SrcSize_DistType_MaskSize_DstType;
14
typedef tuple<Size, DistanceType, MaskSize, LabelType> SrcSize_DistType_MaskSize_LabelType;
15
typedef perf::TestBaseWithParam<SrcSize_DistType_MaskSize_DstType> DistanceTransform_Test;
16
typedef perf::TestBaseWithParam<SrcSize_DistType_MaskSize_LabelType> DistanceTransform_NeedLabels_Test;
17
18
PERF_TEST_P(DistanceTransform_Test, distanceTransform,
19
testing::Combine(
20
testing::Values(cv::Size(640, 480), cv::Size(800, 600), cv::Size(1024, 768), cv::Size(1280, 1024)),
21
DistanceType::all(),
22
MaskSize::all(),
23
DstType::all()
24
)
25
)
26
{
27
Size srcSize = get<0>(GetParam());
28
int distanceType = get<1>(GetParam());
29
int maskSize = get<2>(GetParam());
30
int dstType = get<3>(GetParam());
31
32
Mat src(srcSize, CV_8U);
33
Mat dst(srcSize, dstType);
34
35
declare
36
.in(src, WARMUP_RNG)
37
.out(dst, WARMUP_RNG)
38
.time(30);
39
40
TEST_CYCLE() distanceTransform( src, dst, distanceType, maskSize, dstType);
41
42
double eps = 2e-4;
43
44
SANITY_CHECK(dst, eps);
45
}
46
47
PERF_TEST_P(DistanceTransform_NeedLabels_Test, distanceTransform_NeedLabels,
48
testing::Combine(
49
testing::Values(cv::Size(640, 480), cv::Size(800, 600), cv::Size(1024, 768), cv::Size(1280, 1024)),
50
DistanceType::all(),
51
MaskSize::all(),
52
LabelType::all()
53
)
54
)
55
{
56
Size srcSize = get<0>(GetParam());
57
int distanceType = get<1>(GetParam());
58
int maskSize = get<2>(GetParam());
59
int labelType = get<3>(GetParam());
60
61
Mat src(srcSize, CV_8U);
62
Mat label(srcSize, CV_32S);
63
Mat dst(srcSize, CV_32F);
64
65
declare
66
.in(src, WARMUP_RNG)
67
.out(label, WARMUP_RNG)
68
.out(dst, WARMUP_RNG)
69
.time(30);
70
71
TEST_CYCLE() distanceTransform( src, dst, label, distanceType, maskSize, labelType);
72
73
double eps = 2e-4;
74
75
SANITY_CHECK(label, eps);
76
SANITY_CHECK(dst, eps);
77
}
78
79
} // namespace
80
81