1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
|
#include "perf_precomp.hpp"
using namespace std;
using namespace cv;
using namespace perf;
using std::tr1::make_tuple;
using std::tr1::get;
CV_FLAGS(NormType, NORM_INF, NORM_L1, NORM_L2, NORM_TYPE_MASK, NORM_RELATIVE, NORM_MINMAX)
typedef std::tr1::tuple<Size, MatType, NormType> Size_MatType_NormType_t;
typedef perf::TestBaseWithParam<Size_MatType_NormType_t> Size_MatType_NormType;
PERF_TEST_P(Size_MatType_NormType, norm,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::Values(TYPICAL_MAT_TYPES),
testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2)
)
)
{
Size sz = get<0>(GetParam());
int matType = get<1>(GetParam());
int normType = get<2>(GetParam());
Mat src(sz, matType);
double n;
declare.in(src, WARMUP_RNG);
TEST_CYCLE() n = norm(src, normType);
SANITY_CHECK(n, 1e-6, ERROR_RELATIVE);
}
PERF_TEST_P(Size_MatType_NormType, norm_mask,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::Values(TYPICAL_MAT_TYPES),
testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2)
)
)
{
Size sz = get<0>(GetParam());
int matType = get<1>(GetParam());
int normType = get<2>(GetParam());
Mat src(sz, matType);
Mat mask = Mat::ones(sz, CV_8U);
double n;
declare.in(src, WARMUP_RNG).in(mask);
TEST_CYCLE() n = norm(src, normType, mask);
SANITY_CHECK(n, 1e-6, ERROR_RELATIVE);
}
PERF_TEST_P(Size_MatType_NormType, norm2,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::Values(TYPICAL_MAT_TYPES),
testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2, (int)(NORM_RELATIVE+NORM_INF), (int)(NORM_RELATIVE+NORM_L1), (int)(NORM_RELATIVE+NORM_L2))
)
)
{
Size sz = get<0>(GetParam());
int matType = get<1>(GetParam());
int normType = get<2>(GetParam());
Mat src1(sz, matType);
Mat src2(sz, matType);
double n;
declare.in(src1, src2, WARMUP_RNG);
TEST_CYCLE() n = norm(src1, src2, normType);
SANITY_CHECK(n, 1e-5, ERROR_RELATIVE);
}
PERF_TEST_P(Size_MatType_NormType, norm2_mask,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::Values(TYPICAL_MAT_TYPES),
testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2, (int)(NORM_RELATIVE|NORM_INF), (int)(NORM_RELATIVE|NORM_L1), (int)(NORM_RELATIVE|NORM_L2))
)
)
{
Size sz = get<0>(GetParam());
int matType = get<1>(GetParam());
int normType = get<2>(GetParam());
Mat src1(sz, matType);
Mat src2(sz, matType);
Mat mask = Mat::ones(sz, CV_8U);
double n;
declare.in(src1, src2, WARMUP_RNG).in(mask);
TEST_CYCLE() n = norm(src1, src2, normType, mask);
SANITY_CHECK(n, 1e-5, ERROR_RELATIVE);
}
PERF_TEST_P(Size_MatType_NormType, normalize,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::Values(TYPICAL_MAT_TYPES),
testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2)
)
)
{
Size sz = get<0>(GetParam());
int matType = get<1>(GetParam());
int normType = get<2>(GetParam());
Mat src(sz, matType);
Mat dst(sz, matType);
double alpha = 100.;
if(normType==NORM_L1) alpha = (double)src.total() * src.channels();
if(normType==NORM_L2) alpha = (double)src.total()/10;
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() normalize(src, dst, alpha, 0., normType);
SANITY_CHECK(dst, 1e-6);
}
PERF_TEST_P(Size_MatType_NormType, normalize_mask,
testing::Combine(
testing::Values(::perf::szVGA, ::perf::sz1080p),
testing::Values(TYPICAL_MAT_TYPES),
testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2)
)
)
{
Size sz = get<0>(GetParam());
int matType = get<1>(GetParam());
int normType = get<2>(GetParam());
Mat src(sz, matType);
Mat dst(sz, matType);
Mat mask = Mat::ones(sz, CV_8U);
double alpha = 100.;
if(normType==NORM_L1) alpha = (double)src.total() * src.channels();
if(normType==NORM_L2) alpha = (double)src.total()/10;
declare.in(src, WARMUP_RNG).in(mask).out(dst);
declare.time(100);
TEST_CYCLE() normalize(src, dst, alpha, 0., normType, -1, mask);
SANITY_CHECK(dst, 1e-6);
}
PERF_TEST_P(Size_MatType_NormType, normalize_32f,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::Values(TYPICAL_MAT_TYPES),
testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2)
)
)
{
Size sz = get<0>(GetParam());
int matType = get<1>(GetParam());
int normType = get<2>(GetParam());
Mat src(sz, matType);
Mat dst(sz, CV_32F);
double alpha = 100.;
if(normType==NORM_L1) alpha = (double)src.total() * src.channels();
if(normType==NORM_L2) alpha = (double)src.total()/10;
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() normalize(src, dst, alpha, 0., normType, CV_32F);
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
}
PERF_TEST_P( Size_MatType, normalize_minmax, TYPICAL_MATS )
{
Size sz = get<0>(GetParam());
int matType = get<1>(GetParam());
Mat src(sz, matType);
Mat dst(sz, matType);
declare.in(src, WARMUP_RNG).out(dst);
declare.time(30);
TEST_CYCLE() normalize(src, dst, 20., 100., NORM_MINMAX);
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
}
|