mirror of
https://github.com/opencv/opencv.git
synced 2024-11-26 04:00:30 +08:00
added cv::pow to T-API
This commit is contained in:
parent
997ec60839
commit
3e586f42a0
@ -1955,9 +1955,40 @@ static IPowFunc ipowTab[] =
|
|||||||
(IPowFunc)iPow32s, (IPowFunc)iPow32f, (IPowFunc)iPow64f, 0
|
(IPowFunc)iPow32s, (IPowFunc)iPow32f, (IPowFunc)iPow64f, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool ocl_pow(InputArray _src, double power, OutputArray _dst)
|
||||||
|
{
|
||||||
|
int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||||
|
bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0;
|
||||||
|
|
||||||
|
if ( !(_src.dims() <= 2 && (depth == CV_32F || depth == CV_64F)) ||
|
||||||
|
(depth == CV_64F && !doubleSupport) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
UMat src = _src.getUMat();
|
||||||
|
_dst.create(src.size(), type);
|
||||||
|
UMat dst = _dst.getUMat();
|
||||||
|
|
||||||
|
ocl::Kernel k("KF", ocl::core::arithm_oclsrc,
|
||||||
|
format("-D dstT=%s -D OP_POW -D UNARY_OP%s", ocl::typeToStr(CV_MAKE_TYPE(depth, 1)),
|
||||||
|
doubleSupport ? "-D DOUBLE_SUPPORT" : ""));
|
||||||
|
|
||||||
|
ocl::KernelArg srcarg = ocl::KernelArg::ReadOnlyNoSize(src),
|
||||||
|
dstarg = ocl::KernelArg::WriteOnly(dst, cn);
|
||||||
|
|
||||||
|
if (depth == CV_32F)
|
||||||
|
k.args(srcarg, dstarg, (float)power);
|
||||||
|
else
|
||||||
|
k.args(srcarg, dstarg, power);
|
||||||
|
|
||||||
|
size_t globalsize[2] = { dst.cols * cn, dst.rows };
|
||||||
|
return k.run(2, globalsize, NULL, false);
|
||||||
|
}
|
||||||
|
|
||||||
void pow( InputArray _src, double power, OutputArray _dst )
|
void pow( InputArray _src, double power, OutputArray _dst )
|
||||||
{
|
{
|
||||||
|
if (ocl::useOpenCL() && _dst.isUMat() && ocl_pow(_src, power, _dst))
|
||||||
|
return;
|
||||||
|
|
||||||
Mat src = _src.getMat();
|
Mat src = _src.getMat();
|
||||||
int type = src.type(), depth = src.depth(), cn = src.channels();
|
int type = src.type(), depth = src.depth(), cn = src.channels();
|
||||||
|
|
||||||
|
@ -171,6 +171,9 @@
|
|||||||
#elif defined OP_EXP
|
#elif defined OP_EXP
|
||||||
#define PROCESS_ELEM dstelem = exp(srcelem1)
|
#define PROCESS_ELEM dstelem = exp(srcelem1)
|
||||||
|
|
||||||
|
#elif defined OP_POW
|
||||||
|
#define PROCESS_ELEM dstelem = pow(srcelem1, srcelem2)
|
||||||
|
|
||||||
#elif defined OP_SQRT
|
#elif defined OP_SQRT
|
||||||
#define PROCESS_ELEM dstelem = sqrt(srcelem1)
|
#define PROCESS_ELEM dstelem = sqrt(srcelem1)
|
||||||
|
|
||||||
@ -198,7 +201,7 @@ dstelem = v > (dstT)(0) ? log(v) : log(-v)
|
|||||||
#undef srcelem2
|
#undef srcelem2
|
||||||
#if defined OP_AND || defined OP_OR || defined OP_XOR || defined OP_ADD || defined OP_SAT_ADD || \
|
#if defined OP_AND || defined OP_OR || defined OP_XOR || defined OP_ADD || defined OP_SAT_ADD || \
|
||||||
defined OP_SUB || defined OP_SAT_SUB || defined OP_RSUB || defined OP_SAT_RSUB || \
|
defined OP_SUB || defined OP_SAT_SUB || defined OP_RSUB || defined OP_SAT_RSUB || \
|
||||||
defined OP_ABSDIFF || defined OP_CMP || defined OP_MIN || defined OP_MAX
|
defined OP_ABSDIFF || defined OP_CMP || defined OP_MIN || defined OP_MAX || defined OP_POW
|
||||||
#undef EXTRA_PARAMS
|
#undef EXTRA_PARAMS
|
||||||
#define EXTRA_PARAMS , workT srcelem2
|
#define EXTRA_PARAMS , workT srcelem2
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user