本文整理汇总了C++中UMat::total方法的典型用法代码示例。如果您正苦于以下问题:C++ UMat::total方法的具体用法?C++ UMat::total怎么用?C++ UMat::total使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UMat
的用法示例。
在下文中一共展示了UMat::total方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sumTemplate
static bool sumTemplate(InputArray _src, UMat & result)
{
int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
int wdepth = CV_32F, wtype = CV_MAKE_TYPE(wdepth, cn);
size_t wgs = ocl::Device::getDefault().maxWorkGroupSize();
int wgs2_aligned = 1;
while (wgs2_aligned < (int)wgs)
wgs2_aligned <<= 1;
wgs2_aligned >>= 1;
char cvt[40];
ocl::Kernel k("calcSum", ocl::imgproc::match_template_oclsrc,
format("-D CALC_SUM -D T=%s -D T1=%s -D WT=%s -D cn=%d -D convertToWT=%s -D WGS=%d -D WGS2_ALIGNED=%d",
ocl::typeToStr(type), ocl::typeToStr(depth), ocl::typeToStr(wtype), cn,
ocl::convertTypeStr(depth, wdepth, cn, cvt),
(int)wgs, wgs2_aligned));
if (k.empty())
return false;
UMat src = _src.getUMat();
result.create(1, 1, CV_32FC1);
ocl::KernelArg srcarg = ocl::KernelArg::ReadOnlyNoSize(src),
resarg = ocl::KernelArg::PtrWriteOnly(result);
k.args(srcarg, src.cols, (int)src.total(), resarg);
size_t globalsize = wgs;
return k.run(1, &globalsize, &wgs, false);
}
示例2: Rect
TEST_P(UMatBasicTests, base)
{
const int align_mask = 3;
roi.x &= ~align_mask;
roi.y &= ~align_mask;
roi.width = (roi.width + align_mask) & ~align_mask;
roi &= Rect(0, 0, ua.cols, ua.rows);
if(useRoi)
{
ua = UMat(ua,roi);
}
UMat ub = ua.clone();
EXPECT_MAT_NEAR(ub,ua,0);
ASSERT_EQ(ua.channels(), cn);
ASSERT_EQ(ua.depth(), depth);
ASSERT_EQ(ua.type(), type);
ASSERT_EQ(ua.elemSize(), a.elemSize());
ASSERT_EQ(ua.elemSize1(), a.elemSize1());
ASSERT_EQ(ub.empty(), ub.cols*ub.rows == 0);
ub.release();
ASSERT_TRUE( ub.empty() );
if(useRoi && a.size() != ua.size())
{
ASSERT_EQ(ua.isSubmatrix(), true);
}
else
{
ASSERT_EQ(ua.isSubmatrix(), false);
}
int dims = randomInt(2,6);
int sz[CV_MAX_DIM];
size_t total = 1;
for(int i = 0; i<dims; i++)
{
sz[i] = randomInt(1,45);
total *= (size_t)sz[i];
}
int new_type = CV_MAKE_TYPE(randomInt(CV_8S,CV_64F),randomInt(1,4));
ub = UMat(dims, sz, new_type);
ASSERT_EQ(ub.total(), total);
}
示例3: run_func
void CV_MomentsTest::run_func()
{
CvMoments* m = (CvMoments*)test_mat[OUTPUT][0].ptr<double>();
double* others = (double*)(m + 1);
if( try_umat )
{
UMat u;
test_mat[INPUT][0].clone().copyTo(u);
OCL_TUNING_MODE_ONLY(
static double ttime = 0;
static int ncalls = 0;
moments(u, is_binary != 0);
double t = (double)getTickCount());
Moments new_m = moments(u, is_binary != 0);
OCL_TUNING_MODE_ONLY(
ttime += (double)getTickCount() - t;
ncalls++;
printf("%g\n", ttime/ncalls/u.total()));
*m = new_m;
}
else