Path: blob/master/modules/imgproc/perf/perf_moments.cpp
16354 views
// This file is part of OpenCV project.1// It is subject to the license terms in the LICENSE file found in the top-level directory2// of this distribution and at http://opencv.org/license.html.34// Copyright (C) 2014, Itseez, Inc., all rights reserved.5// Third party copyrights are property of their respective owners.67#include "perf_precomp.hpp"89namespace opencv_test {1011typedef tuple<Size, MatDepth, bool> MomentsParams_t;12typedef perf::TestBaseWithParam<MomentsParams_t> MomentsFixture_val;1314PERF_TEST_P(MomentsFixture_val, Moments1,15::testing::Combine(16testing::Values(TYPICAL_MAT_SIZES),17testing::Values(CV_16U, CV_16S, CV_32F, CV_64F),18testing::Bool()))19{20const MomentsParams_t params = GetParam();21const Size srcSize = get<0>(params);22const MatDepth srcDepth = get<1>(params);23const bool binaryImage = get<2>(params);2425cv::Moments m;26Mat src(srcSize, srcDepth);27declare.in(src, WARMUP_RNG);2829TEST_CYCLE() m = cv::moments(src, binaryImage);3031int len = (int)sizeof(cv::Moments) / sizeof(double);32cv::Mat mat(1, len, CV_64F, (void*)&m);33//adding 1 to moments to avoid accidental tests fail on values close to 034mat += 1;353637SANITY_CHECK_MOMENTS(m, 2e-4, ERROR_RELATIVE);38}3940} // namespace414243