2011-09-06 23:30:28 +08:00
|
|
|
#include "perf_precomp.hpp"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace cv;
|
|
|
|
using namespace perf;
|
2011-12-30 00:46:16 +08:00
|
|
|
using std::tr1::make_tuple;
|
|
|
|
using std::tr1::get;
|
2011-09-06 23:30:28 +08:00
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
PERF_TEST_P(Size_MatType, sum, TYPICAL_MATS)
|
2011-09-06 23:30:28 +08:00
|
|
|
{
|
2011-12-30 00:46:16 +08:00
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int type = get<1>(GetParam());
|
2011-09-06 23:30:28 +08:00
|
|
|
|
|
|
|
Mat arr(sz, type);
|
|
|
|
Scalar s;
|
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
declare.in(arr, WARMUP_RNG).out(s);
|
2011-09-06 23:30:28 +08:00
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
TEST_CYCLE() s = sum(arr);
|
2011-09-06 23:30:28 +08:00
|
|
|
|
2011-12-28 22:59:09 +08:00
|
|
|
SANITY_CHECK(s, 1e-6, ERROR_RELATIVE);
|
2011-09-06 23:30:28 +08:00
|
|
|
}
|
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
PERF_TEST_P(Size_MatType, mean, TYPICAL_MATS)
|
2011-09-06 23:30:28 +08:00
|
|
|
{
|
2011-12-30 00:46:16 +08:00
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int type = get<1>(GetParam());
|
2011-09-06 23:30:28 +08:00
|
|
|
|
|
|
|
Mat src(sz, type);
|
|
|
|
Scalar s;
|
2012-06-15 21:04:17 +08:00
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
declare.in(src, WARMUP_RNG).out(s);
|
2012-06-15 21:04:17 +08:00
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
TEST_CYCLE() s = mean(src);
|
2012-06-15 21:04:17 +08:00
|
|
|
|
2013-07-26 01:27:35 +08:00
|
|
|
SANITY_CHECK(s, 1e-5);
|
2011-09-06 23:30:28 +08:00
|
|
|
}
|
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
PERF_TEST_P(Size_MatType, mean_mask, TYPICAL_MATS)
|
2011-09-06 23:30:28 +08:00
|
|
|
{
|
2011-12-30 00:46:16 +08:00
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int type = get<1>(GetParam());
|
2011-09-06 23:30:28 +08:00
|
|
|
|
|
|
|
Mat src(sz, type);
|
|
|
|
Mat mask = Mat::ones(src.size(), CV_8U);
|
|
|
|
Scalar s;
|
2012-06-15 21:04:17 +08:00
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
declare.in(src, WARMUP_RNG).in(mask).out(s);
|
2012-06-15 21:04:17 +08:00
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
TEST_CYCLE() s = mean(src, mask);
|
2012-06-15 21:04:17 +08:00
|
|
|
|
2013-07-26 01:27:35 +08:00
|
|
|
SANITY_CHECK(s, 5e-5);
|
2011-09-06 23:30:28 +08:00
|
|
|
}
|
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
PERF_TEST_P(Size_MatType, meanStdDev, TYPICAL_MATS)
|
2011-09-06 23:30:28 +08:00
|
|
|
{
|
2011-12-30 00:46:16 +08:00
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int matType = get<1>(GetParam());
|
2011-09-06 23:30:28 +08:00
|
|
|
|
|
|
|
Mat src(sz, matType);
|
2011-12-30 00:46:16 +08:00
|
|
|
Scalar mean;
|
|
|
|
Scalar dev;
|
2011-09-06 23:30:28 +08:00
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
declare.in(src, WARMUP_RNG).out(mean, dev);
|
2011-09-06 23:30:28 +08:00
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
TEST_CYCLE() meanStdDev(src, mean, dev);
|
2012-06-15 21:04:17 +08:00
|
|
|
|
2014-04-02 19:45:03 +08:00
|
|
|
SANITY_CHECK(mean, 1e-5, ERROR_RELATIVE);
|
|
|
|
SANITY_CHECK(dev, 1e-5, ERROR_RELATIVE);
|
2011-09-06 23:30:28 +08:00
|
|
|
}
|
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
PERF_TEST_P(Size_MatType, meanStdDev_mask, TYPICAL_MATS)
|
2011-09-06 23:30:28 +08:00
|
|
|
{
|
2011-12-30 00:46:16 +08:00
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int matType = get<1>(GetParam());
|
2011-09-06 23:30:28 +08:00
|
|
|
|
|
|
|
Mat src(sz, matType);
|
|
|
|
Mat mask = Mat::ones(sz, CV_8U);
|
2011-12-30 00:46:16 +08:00
|
|
|
Scalar mean;
|
|
|
|
Scalar dev;
|
2011-09-06 23:30:28 +08:00
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
declare.in(src, WARMUP_RNG).in(mask).out(mean, dev);
|
2012-06-15 21:04:17 +08:00
|
|
|
|
2011-12-30 00:46:16 +08:00
|
|
|
TEST_CYCLE() meanStdDev(src, mean, dev, mask);
|
2012-06-15 21:04:17 +08:00
|
|
|
|
2013-08-30 01:05:35 +08:00
|
|
|
SANITY_CHECK(mean, 1e-5);
|
|
|
|
SANITY_CHECK(dev, 1e-5);
|
2011-09-06 23:30:28 +08:00
|
|
|
}
|
|
|
|
|
2012-01-16 15:04:26 +08:00
|
|
|
PERF_TEST_P(Size_MatType, countNonZero, testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), testing::Values( CV_8UC1, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1 ) ))
|
2011-09-06 23:30:28 +08:00
|
|
|
{
|
2011-12-30 00:46:16 +08:00
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int matType = get<1>(GetParam());
|
2011-09-06 23:30:28 +08:00
|
|
|
|
|
|
|
Mat src(sz, matType);
|
|
|
|
int cnt = 0;
|
|
|
|
|
|
|
|
declare.in(src, WARMUP_RNG);
|
2012-06-15 21:04:17 +08:00
|
|
|
|
2013-02-06 18:53:33 +08:00
|
|
|
int runs = (sz.width <= 640) ? 8 : 1;
|
|
|
|
TEST_CYCLE_MULTIRUN(runs) cnt = countNonZero(src);
|
2012-06-15 21:04:17 +08:00
|
|
|
|
2011-09-06 23:30:28 +08:00
|
|
|
SANITY_CHECK(cnt);
|
|
|
|
}
|