|
|
|
@ -41,10 +41,11 @@ |
|
|
|
|
//M*/
|
|
|
|
|
|
|
|
|
|
#include "precomp.hpp" |
|
|
|
|
#include "opencl_kernels.hpp" |
|
|
|
|
#include <climits> |
|
|
|
|
#include <limits> |
|
|
|
|
|
|
|
|
|
#include "opencl_kernels.hpp" |
|
|
|
|
|
|
|
|
|
namespace cv |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
@ -1300,8 +1301,9 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int* |
|
|
|
|
wgs2_aligned <<= 1; |
|
|
|
|
wgs2_aligned >>= 1; |
|
|
|
|
|
|
|
|
|
String opts = format("-D DEPTH_%d -D OP_MIN_MAX_LOC%s -D WGS=%d -D WGS2_ALIGNED=%d%s", |
|
|
|
|
depth, _mask.empty() ? "" : "_MASK", (int)wgs, wgs2_aligned, doubleSupport ? " -D DOUBLE_SUPPORT" : ""); |
|
|
|
|
String opts = format("-D DEPTH_%d -D srcT=%s -D OP_MIN_MAX_LOC%s -D WGS=%d -D WGS2_ALIGNED=%d%s", |
|
|
|
|
depth, ocl::typeToStr(depth), _mask.empty() ? "" : "_MASK", (int)wgs, |
|
|
|
|
wgs2_aligned, doubleSupport ? " -D DOUBLE_SUPPORT" : ""); |
|
|
|
|
|
|
|
|
|
ocl::Kernel k("reduce", ocl::core::reduce_oclsrc, opts); |
|
|
|
|
if (k.empty()) |
|
|
|
@ -1980,12 +1982,14 @@ static bool ocl_norm( InputArray _src, int normType, InputArray _mask, double & |
|
|
|
|
haveMask = _mask.kind() != _InputArray::NONE; |
|
|
|
|
|
|
|
|
|
if ( !(normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR) || |
|
|
|
|
(!doubleSupport && depth == CV_64F) || (normType == NORM_INF && haveMask && cn != 1)) |
|
|
|
|
(!doubleSupport && depth == CV_64F)) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
UMat src = _src.getUMat(); |
|
|
|
|
|
|
|
|
|
if (normType == NORM_INF) |
|
|
|
|
{ |
|
|
|
|
if (cn == 1 || !haveMask) |
|
|
|
|
{ |
|
|
|
|
UMat abssrc; |
|
|
|
|
|
|
|
|
@ -2014,6 +2018,35 @@ static bool ocl_norm( InputArray _src, int normType, InputArray _mask, double & |
|
|
|
|
|
|
|
|
|
cv::minMaxIdx(haveMask ? abssrc : abssrc.reshape(1), NULL, &result, NULL, NULL, _mask); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
int dbsize = ocl::Device::getDefault().maxComputeUnits(); |
|
|
|
|
size_t wgs = ocl::Device::getDefault().maxWorkGroupSize(); |
|
|
|
|
|
|
|
|
|
int wgs2_aligned = 1; |
|
|
|
|
while (wgs2_aligned < (int)wgs) |
|
|
|
|
wgs2_aligned <<= 1; |
|
|
|
|
wgs2_aligned >>= 1; |
|
|
|
|
|
|
|
|
|
ocl::Kernel k("reduce", ocl::core::reduce_oclsrc, |
|
|
|
|
format("-D OP_NORM_INF_MASK -D HAVE_MASK -D DEPTH_%d" |
|
|
|
|
" -D srcT=%s -D srcT1=%s -D WGS=%d -D cn=%d -D WGS2_ALIGNED=%d%s", |
|
|
|
|
depth, ocl::typeToStr(type), ocl::typeToStr(depth), |
|
|
|
|
wgs, cn, wgs2_aligned, doubleSupport ? " -D DOUBLE_SUPPORT" : "")); |
|
|
|
|
if (k.empty()) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
UMat db(1, dbsize, type), mask = _mask.getUMat(); |
|
|
|
|
k.args(ocl::KernelArg::ReadOnlyNoSize(src), src.cols, (int)src.total(), |
|
|
|
|
dbsize, ocl::KernelArg::PtrWriteOnly(db), ocl::KernelArg::ReadOnlyNoSize(mask)); |
|
|
|
|
|
|
|
|
|
size_t globalsize = dbsize * wgs; |
|
|
|
|
if (!k.run(1, &globalsize, &wgs, true)) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
minMaxIdx(db.getMat(ACCESS_READ), NULL, &result, NULL, NULL, noArray()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if (normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR) |
|
|
|
|
{ |
|
|
|
|
Scalar sc; |
|
|
|
|