File: perf_distanceTransform.cpp

package info (click to toggle)
opencv 4.5.1%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 268,248 kB
  • sloc: cpp: 969,170; xml: 682,525; python: 36,732; lisp: 30,170; java: 25,155; ansic: 7,927; javascript: 5,643; objc: 2,041; sh: 935; cs: 601; perl: 494; makefile: 145
file content (79 lines) | stat: -rw-r--r-- 2,527 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"

namespace opencv_test {

CV_ENUM(DistanceType, DIST_L1, DIST_L2 , DIST_C)
CV_ENUM(MaskSize, DIST_MASK_3, DIST_MASK_5, DIST_MASK_PRECISE)
CV_ENUM(DstType, CV_8U, CV_32F)
CV_ENUM(LabelType, DIST_LABEL_CCOMP, DIST_LABEL_PIXEL)

typedef tuple<Size, DistanceType, MaskSize, DstType> SrcSize_DistType_MaskSize_DstType;
typedef tuple<Size, DistanceType, MaskSize, LabelType> SrcSize_DistType_MaskSize_LabelType;
typedef perf::TestBaseWithParam<SrcSize_DistType_MaskSize_DstType> DistanceTransform_Test;
typedef perf::TestBaseWithParam<SrcSize_DistType_MaskSize_LabelType> DistanceTransform_NeedLabels_Test;

PERF_TEST_P(DistanceTransform_Test, distanceTransform,
            testing::Combine(
                testing::Values(cv::Size(640, 480), cv::Size(800, 600), cv::Size(1024, 768), cv::Size(1280, 1024)),
                DistanceType::all(),
                MaskSize::all(),
                DstType::all()
                )
            )
{
    Size srcSize = get<0>(GetParam());
    int distanceType = get<1>(GetParam());
    int maskSize = get<2>(GetParam());
    int dstType = get<3>(GetParam());

    Mat src(srcSize, CV_8U);
    Mat dst(srcSize, dstType);

    declare
        .in(src, WARMUP_RNG)
        .out(dst, WARMUP_RNG)
        .time(30);

    TEST_CYCLE() distanceTransform( src, dst, distanceType, maskSize, dstType);

    double eps = 2e-4;

    SANITY_CHECK(dst, eps);
}

PERF_TEST_P(DistanceTransform_NeedLabels_Test, distanceTransform_NeedLabels,
            testing::Combine(
                testing::Values(cv::Size(640, 480), cv::Size(800, 600), cv::Size(1024, 768), cv::Size(1280, 1024)),
                DistanceType::all(),
                MaskSize::all(),
                LabelType::all()
                )
    )
{
    Size srcSize = get<0>(GetParam());
    int distanceType = get<1>(GetParam());
    int maskSize = get<2>(GetParam());
    int labelType = get<3>(GetParam());

    Mat src(srcSize, CV_8U);
    Mat label(srcSize, CV_32S);
    Mat dst(srcSize, CV_32F);

    declare
        .in(src, WARMUP_RNG)
        .out(label, WARMUP_RNG)
        .out(dst, WARMUP_RNG)
        .time(30);

    TEST_CYCLE() distanceTransform( src, dst, label, distanceType, maskSize, labelType);

    double eps = 2e-4;

    SANITY_CHECK(label, eps);
    SANITY_CHECK(dst, eps);
}

} // namespace