fix device pointer alignmen in sft-based integral integration

This commit is contained in:
marina.kolpakova 2012-09-28 14:04:43 +04:00
parent ed6885dd8b
commit c6e741196a

View File

@ -548,12 +548,16 @@ void cv::gpu::integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer, S
cudaStream_t stream = StreamAccessor::getStream(s); cudaStream_t stream = StreamAccessor::getStream(s);
DeviceInfo info; DeviceInfo info;
cv::Size whole;
cv::Point offset;
src.locateROI(whole, offset);
if (info.supports(WARP_SHUFFLE_FUNCTIONS) ) if (info.supports(WARP_SHUFFLE_FUNCTIONS) )
{ {
GpuMat srcAlligned; GpuMat srcAlligned;
if (src.cols % 16 == 0 && src.rows % 8 == 0) if (src.cols % 16 == 0 && src.rows % 8 == 0 && offset.x % 16 == 0 && offset.y % 8 == 0)
srcAlligned = src; srcAlligned = src;
else else
{ {
@ -575,19 +579,18 @@ void cv::gpu::integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer, S
srcAlligned = buffer; srcAlligned = buffer;
} }
sum.create(srcAlligned.rows + 1, srcAlligned.cols + 1, CV_32SC1); sum.create(srcAlligned.rows + 1, srcAlligned.cols + 4, CV_32SC1);
if (s) if (s)
s.enqueueMemSet(sum, Scalar::all(0)); s.enqueueMemSet(sum, Scalar::all(0));
else else
sum.setTo(Scalar::all(0)); sum.setTo(Scalar::all(0));
GpuMat inner = sum(Rect(1, 1, srcAlligned.cols, srcAlligned.rows)); GpuMat inner = sum(Rect(4, 1, srcAlligned.cols, srcAlligned.rows));
cv::gpu::device::imgproc::shfl_integral_gpu(srcAlligned, inner, stream); cv::gpu::device::imgproc::shfl_integral_gpu(srcAlligned, inner, stream);
if (srcAlligned.data != src.data) sum = sum(Rect(3, 0, src.cols + 1, src.rows + 1));
sum = sum(Rect(0, 0, src.cols + 1, src.rows + 1));
} }
else else
{ {