Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/imgproc/perf/perf_moments.cpp
16354 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
5
// Copyright (C) 2014, Itseez, Inc., all rights reserved.
6
// Third party copyrights are property of their respective owners.
7
8
#include "perf_precomp.hpp"
9
10
namespace opencv_test {
11
12
typedef tuple<Size, MatDepth, bool> MomentsParams_t;
13
typedef perf::TestBaseWithParam<MomentsParams_t> MomentsFixture_val;
14
15
PERF_TEST_P(MomentsFixture_val, Moments1,
16
::testing::Combine(
17
testing::Values(TYPICAL_MAT_SIZES),
18
testing::Values(CV_16U, CV_16S, CV_32F, CV_64F),
19
testing::Bool()))
20
{
21
const MomentsParams_t params = GetParam();
22
const Size srcSize = get<0>(params);
23
const MatDepth srcDepth = get<1>(params);
24
const bool binaryImage = get<2>(params);
25
26
cv::Moments m;
27
Mat src(srcSize, srcDepth);
28
declare.in(src, WARMUP_RNG);
29
30
TEST_CYCLE() m = cv::moments(src, binaryImage);
31
32
int len = (int)sizeof(cv::Moments) / sizeof(double);
33
cv::Mat mat(1, len, CV_64F, (void*)&m);
34
//adding 1 to moments to avoid accidental tests fail on values close to 0
35
mat += 1;
36
37
38
SANITY_CHECK_MOMENTS(m, 2e-4, ERROR_RELATIVE);
39
}
40
41
} // namespace
42
43