Commit 1c9f4e7c authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

fixed gpu::meanStdDev and gpu::norm under CUDA 4.0

fixed compilation under Win64
parent 7ec77593
......@@ -596,11 +596,11 @@ bool cv::gpu::CudaMem::canMapHostMemory()
namespace
{
int alignUp(int what, int alignment)
size_t alignUpStep(size_t what, size_t alignment)
{
int alignMask = alignment-1;
int inverseAlignMask = ~alignMask;
int res = (what + alignMask) & inverseAlignMask;
size_t alignMask = alignment-1;
size_t inverseAlignMask = ~alignMask;
size_t res = (what + alignMask) & inverseAlignMask;
return res;
}
}
......@@ -626,7 +626,7 @@ void cv::gpu::CudaMem::create(int _rows, int _cols, int _type, int _alloc_type)
{
cudaDeviceProp prop;
cudaSafeCall( cudaGetDeviceProperties(&prop, getDevice()) );
step = alignUp(step, prop.textureAlignment);
step = alignUpStep(step, prop.textureAlignment);
}
int64 _nettosize = (int64)step*rows;
size_t nettosize = (size_t)_nettosize;
......
......@@ -78,9 +78,28 @@ void cv::gpu::meanStdDev(const GpuMat& src, Scalar& mean, Scalar& stddev)
sz.width = src.cols;
sz.height = src.rows;
#if NPP_VERSION_MAJOR >= 4
GpuMat d_buf(1, 2, CV_64F);
nppSafeCall( nppiMean_StdDev_8u_C1R(src.ptr<Npp8u>(), src.step, sz, d_buf.ptr<double>(), d_buf.ptr<double>() + 1) );
cudaSafeCall( cudaThreadSynchronize() );
double buf[2];
Mat _buf(1, 2, CV_64F, buf);
d_buf.download(_buf);
mean[0] = buf[0];
stddev[0] = buf[1];
#else
nppSafeCall( nppiMean_StdDev_8u_C1R(src.ptr<Npp8u>(), src.step, sz, mean.val, stddev.val) );
cudaSafeCall( cudaThreadSynchronize() );
#endif
}
......@@ -131,14 +150,32 @@ double cv::gpu::norm(const GpuMat& src1, const GpuMat& src2, int normType)
sz.height = src1.rows;
int funcIdx = normType >> 1;
#if NPP_VERSION_MAJOR >= 4
GpuMat d_buf(1, 1, CV_64F);
nppSafeCall( npp_norm_diff_func[funcIdx](src1.ptr<Npp8u>(), src1.step,
src2.ptr<Npp8u>(), src2.step,
sz, d_buf.ptr<double>()) );
cudaSafeCall( cudaThreadSynchronize() );
double retVal;
Mat _buf(1, 1, CV_64F, &retVal);
d_buf.download(_buf);
#else
double retVal;
nppSafeCall( npp_norm_diff_func[funcIdx](src1.ptr<Npp8u>(), src1.step,
src2.ptr<Npp8u>(), src2.step,
sz, &retVal) );
cudaSafeCall( cudaThreadSynchronize() );
#endif
return retVal;
}
......
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