• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "perf_precomp.hpp"
2 
3 using namespace std;
4 using namespace cv;
5 using namespace perf;
6 using std::tr1::make_tuple;
7 using std::tr1::get;
8 
9 template <typename T>
CvRoundMat(const cv::Mat & src,cv::Mat & dst)10 static void CvRoundMat(const cv::Mat & src, cv::Mat & dst)
11 {
12     for (int y = 0; y < dst.rows; ++y)
13     {
14         const T * sptr = src.ptr<T>(y);
15         int * dptr = dst.ptr<int>(y);
16 
17         for (int x = 0; x < dst.cols; ++x)
18             dptr[x] = cvRound(sptr[x]);
19     }
20 }
21 
PERF_TEST_P(Size_MatType,CvRound_Float,testing::Combine (testing::Values (TYPICAL_MAT_SIZES),testing::Values (CV_32FC1,CV_64FC1)))22 PERF_TEST_P(Size_MatType, CvRound_Float,
23             testing::Combine(testing::Values(TYPICAL_MAT_SIZES),
24                              testing::Values(CV_32FC1, CV_64FC1)))
25 {
26     Size size = get<0>(GetParam());
27     int type = get<1>(GetParam()), depth = CV_MAT_DEPTH(type);
28 
29     cv::Mat src(size, type), dst(size, CV_32SC1);
30 
31     declare.in(src, WARMUP_RNG).out(dst);
32 
33     if (depth == CV_32F)
34     {
35         TEST_CYCLE()
36             CvRoundMat<float>(src, dst);
37     }
38     else if (depth == CV_64F)
39     {
40         TEST_CYCLE()
41             CvRoundMat<double>(src, dst);
42     }
43 
44     SANITY_CHECK_NOTHING();
45 }
46