Merge pull request #3561 from jet47:cuda-arithm-refactoring

This commit is contained in:
Vadim Pisarevsky
2015-01-15 11:44:35 +00:00
34 changed files with 1404 additions and 713 deletions

View File

@@ -80,6 +80,16 @@
namespace cv { namespace cuda {
CV_EXPORTS cv::String getNppErrorMessage(int code);
CV_EXPORTS cv::String getCudaDriverApiErrorMessage(int code);
CV_EXPORTS GpuMat getInputMat(InputArray _src, Stream& stream);
CV_EXPORTS GpuMat getOutputMat(OutputArray _dst, int rows, int cols, int type, Stream& stream);
static inline GpuMat getOutputMat(OutputArray _dst, Size size, int type, Stream& stream)
{
return getOutputMat(_dst, size.height, size.width, type, stream);
}
CV_EXPORTS void syncOutput(const GpuMat& dst, OutputArray _dst, Stream& stream);
}}
#ifndef HAVE_CUDA

View File

@@ -342,6 +342,75 @@ void cv::cuda::ensureSizeIsEnough(int rows, int cols, int type, OutputArray arr)
}
}
GpuMat cv::cuda::getInputMat(InputArray _src, Stream& stream)
{
GpuMat src;
#ifndef HAVE_CUDA
(void) _src;
(void) stream;
throw_no_cuda();
#else
if (_src.kind() == _InputArray::CUDA_GPU_MAT)
{
src = _src.getGpuMat();
}
else if (!_src.empty())
{
BufferPool pool(stream);
src = pool.getBuffer(_src.size(), _src.type());
src.upload(_src, stream);
}
#endif
return src;
}
GpuMat cv::cuda::getOutputMat(OutputArray _dst, int rows, int cols, int type, Stream& stream)
{
GpuMat dst;
#ifndef HAVE_CUDA
(void) _dst;
(void) rows;
(void) cols;
(void) type;
(void) stream;
throw_no_cuda();
#else
if (_dst.kind() == _InputArray::CUDA_GPU_MAT)
{
_dst.create(rows, cols, type);
dst = _dst.getGpuMat();
}
else
{
BufferPool pool(stream);
dst = pool.getBuffer(rows, cols, type);
}
#endif
return dst;
}
void cv::cuda::syncOutput(const GpuMat& dst, OutputArray _dst, Stream& stream)
{
#ifndef HAVE_CUDA
(void) dst;
(void) _dst;
(void) stream;
throw_no_cuda();
#else
if (_dst.kind() != _InputArray::CUDA_GPU_MAT)
{
if (stream)
dst.download(_dst, stream);
else
dst.download(_dst);
}
#endif
}
#ifndef HAVE_CUDA
GpuMat::Allocator* cv::cuda::GpuMat::defaultAllocator()