perf_corners.cpp 3.17 KB
Newer Older
1 2 3
// 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.
4 5
#include "perf_precomp.hpp"

6
namespace opencv_test {
7 8 9

CV_ENUM(BorderType, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_REFLECT_101)

10
typedef tuple<string, int, int, double, BorderType> Img_BlockSize_ApertureSize_k_BorderType_t;
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
typedef perf::TestBaseWithParam<Img_BlockSize_ApertureSize_k_BorderType_t> Img_BlockSize_ApertureSize_k_BorderType;

PERF_TEST_P(Img_BlockSize_ApertureSize_k_BorderType, cornerHarris,
            testing::Combine(
                testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
                testing::Values( 3, 5 ),
                testing::Values( 3, 5 ),
                testing::Values( 0.04, 0.1 ),
                BorderType::all()
                )
          )
{
    string filename = getDataPath(get<0>(GetParam()));
    int blockSize = get<1>(GetParam());
    int apertureSize = get<2>(GetParam());
    double k = get<3>(GetParam());
    BorderType borderType = get<4>(GetParam());

    Mat src = imread(filename, IMREAD_GRAYSCALE);
30
    ASSERT_FALSE(src.empty()) << "Unable to load source image: " << filename;
31 32 33 34 35

    Mat dst;

    TEST_CYCLE() cornerHarris(src, dst, blockSize, apertureSize, k, borderType);

Alexander Karsakov's avatar
Alexander Karsakov committed
36
    SANITY_CHECK(dst, 2e-5, ERROR_RELATIVE);
37 38
}

39
typedef tuple<string, int, int, BorderType> Img_BlockSize_ApertureSize_BorderType_t;
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
typedef perf::TestBaseWithParam<Img_BlockSize_ApertureSize_BorderType_t> Img_BlockSize_ApertureSize_BorderType;

PERF_TEST_P(Img_BlockSize_ApertureSize_BorderType, cornerEigenValsAndVecs,
            testing::Combine(
                testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
                testing::Values( 3, 5 ),
                testing::Values( 3, 5 ),
                BorderType::all()
            )
          )
{
    string filename = getDataPath(get<0>(GetParam()));
    int blockSize = get<1>(GetParam());
    int apertureSize = get<2>(GetParam());
    BorderType borderType = get<3>(GetParam());

    Mat src = imread(filename, IMREAD_GRAYSCALE);
57
    ASSERT_FALSE(src.empty()) << "Unable to load source image: " << filename;
58 59 60 61 62 63 64 65

    Mat dst;

    TEST_CYCLE() cornerEigenValsAndVecs(src, dst, blockSize, apertureSize, borderType);

    Mat l1;
    extractChannel(dst, l1, 0);

Alexander Karsakov's avatar
Alexander Karsakov committed
66
    SANITY_CHECK(l1, 2e-5, ERROR_RELATIVE);
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
}

PERF_TEST_P(Img_BlockSize_ApertureSize_BorderType, cornerMinEigenVal,
            testing::Combine(
                testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
                testing::Values( 3, 5 ),
                testing::Values( 3, 5 ),
                BorderType::all()
            )
          )
{
    string filename = getDataPath(get<0>(GetParam()));
    int blockSize = get<1>(GetParam());
    int apertureSize = get<2>(GetParam());
    BorderType borderType = get<3>(GetParam());

    Mat src = imread(filename, IMREAD_GRAYSCALE);
84
    ASSERT_FALSE(src.empty()) << "Unable to load source image: " << filename;
85 86 87 88 89

    Mat dst;

    TEST_CYCLE() cornerMinEigenVal(src, dst, blockSize, apertureSize, borderType);

Alexander Karsakov's avatar
Alexander Karsakov committed
90
    SANITY_CHECK(dst, 2e-5, ERROR_RELATIVE);
91
}
92 93

} // namespace