Commit 44ffa420 authored by mlyashko's avatar mlyashko

replaced factors computation by precomputed values, added kernel for

binary mode
parent acebfcd2
...@@ -369,11 +369,16 @@ Moments::Moments( double _m00, double _m10, double _m01, double _m20, double _m1 ...@@ -369,11 +369,16 @@ Moments::Moments( double _m00, double _m10, double _m01, double _m20, double _m1
#ifdef HAVE_OPENCL #ifdef HAVE_OPENCL
static bool ocl_moments( InputArray _src, Moments& m) static bool ocl_moments( InputArray _src, Moments& m, bool binary)
{ {
const int TILE_SIZE = 32; const int TILE_SIZE = 32;
const int K = 10; const int K = 10;
ocl::Kernel k("moments", ocl::imgproc::moments_oclsrc, format("-D TILE_SIZE=%d", TILE_SIZE));
ocl::Kernel k = ocl::Kernel("moments", ocl::imgproc::moments_oclsrc,
format("-D TILE_SIZE=%d%s",
TILE_SIZE,
binary ? " -D OP_MOMENTS_BINARY" : ""));
if( k.empty() ) if( k.empty() )
return false; return false;
...@@ -451,8 +456,8 @@ cv::Moments cv::moments( InputArray _src, bool binary ) ...@@ -451,8 +456,8 @@ cv::Moments cv::moments( InputArray _src, bool binary )
return m; return m;
#ifdef HAVE_OPENCL #ifdef HAVE_OPENCL
if( !(ocl::useOpenCL() && type == CV_8UC1 && !binary && if( !(ocl::useOpenCL() && type == CV_8UC1 &&
_src.isUMat() && ocl_moments(_src, m)) ) _src.isUMat() && ocl_moments(_src, m, binary)) )
#endif #endif
{ {
Mat mat = _src.getMat(); Mat mat = _src.getMat();
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment