Path: blob/master/modules/core/perf/perf_cvround.cpp
16354 views
#include "perf_precomp.hpp"12namespace opencv_test3{4using namespace perf;56template <typename T>7static void CvRoundMat(const cv::Mat & src, cv::Mat & dst)8{9for (int y = 0; y < dst.rows; ++y)10{11const T * sptr = src.ptr<T>(y);12int * dptr = dst.ptr<int>(y);1314for (int x = 0; x < dst.cols; ++x)15dptr[x] = cvRound(sptr[x]);16}17}1819PERF_TEST_P(Size_MatType, CvRound_Float,20testing::Combine(testing::Values(TYPICAL_MAT_SIZES),21testing::Values(CV_32FC1, CV_64FC1)))22{23Size size = get<0>(GetParam());24int type = get<1>(GetParam()), depth = CV_MAT_DEPTH(type);2526cv::Mat src(size, type), dst(size, CV_32SC1);2728declare.in(src, WARMUP_RNG).out(dst);2930if (depth == CV_32F)31{32TEST_CYCLE()33CvRoundMat<float>(src, dst);34}35else if (depth == CV_64F)36{37TEST_CYCLE()38CvRoundMat<double>(src, dst);39}4041SANITY_CHECK_NOTHING();42}4344} // namespace454647