diff --git a/modules/gpu/src/cuda/integral_image.cu b/modules/gpu/src/cuda/integral_image.cu index 558f9085dbc631544ba72825cefe3436b7560480..a34a52a313bc7315819385aa014123af3cee3e54 100644 --- a/modules/gpu/src/cuda/integral_image.cu +++ b/modules/gpu/src/cuda/integral_image.cu @@ -357,18 +357,25 @@ namespace cv { namespace gpu { namespace device #endif } - void shfl_integral_gpu(PtrStepSzb img, PtrStepSz integral, cudaStream_t stream) + void shfl_integral_gpu(const PtrStepSzb& img, PtrStepSz integral, cudaStream_t stream) { { // each thread handles 16 values, use 1 block/row - const int block = img.cols / 16; + int block = img.cols / 16; + + // save, becouse step is actually can't be less 512 bytes + int align = img.cols % 4; + if ( align != 0) + { + block += (4 - align); + } // launch 1 block / row const int grid = img.rows; cudaSafeCall( cudaFuncSetCacheConfig(shfl_integral_horizontal, cudaFuncCachePreferL1) ); - shfl_integral_horizontal<<>>((PtrStepSz) img, (PtrStepSz) integral); + shfl_integral_horizontal<<>>((const PtrStepSz) img, (PtrStepSz) integral); cudaSafeCall( cudaGetLastError() ); } diff --git a/modules/gpu/src/imgproc.cpp b/modules/gpu/src/imgproc.cpp index 0bf9c81c2e1e86ece601f6b17cf71d37f9eb4361..81a2248fdbfd20fd979be51a266ca12711abb2ab 100644 --- a/modules/gpu/src/imgproc.cpp +++ b/modules/gpu/src/imgproc.cpp @@ -537,7 +537,7 @@ namespace cv { namespace gpu { namespace device { namespace imgproc { - void shfl_integral_gpu(PtrStepSzb img, PtrStepSz integral, cudaStream_t stream); + void shfl_integral_gpu(const PtrStepSzb& img, PtrStepSz integral, cudaStream_t stream); } }}}