ocl: fix Canny for Intel devices
authorAlexander Alekhin <alexander.alekhin@intel.com>
Tue, 9 Aug 2016 09:48:06 +0000 (12:48 +0300)
committerAlexander Alekhin <alexander.alekhin@intel.com>
Tue, 9 Aug 2016 09:48:06 +0000 (12:48 +0300)
There is an issue with processing of abs(short) function for
negative argument.

Affected OpenCL devices:
- iGPU: Intel(R) HD Graphics 520 (OpenCL 2.0 )
- CPU: Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz (OpenCL 2.0 (Build 10094))

modules/imgproc/src/opencl/canny.cl

index 584cf9e..1388504 100644 (file)
@@ -260,7 +260,7 @@ __kernel void stage1_with_sobel(__global const uchar *src, int src_step, int src
 #ifdef L2GRAD
 #define dist(x, y) ((int)(x) * (x) + (int)(y) * (y))
 #else
-#define dist(x, y) (abs(x) + abs(y))
+#define dist(x, y) (abs((int)(x)) + abs((int)(y)))
 #endif
 
 __constant int prev[4][2] = {