mirror of
https://github.com/opencv/opencv.git
synced 2024-12-18 11:28:02 +08:00
imgproc_gpu - minor refactoring
This commit is contained in:
parent
2d36ba2175
commit
d352db7ec4
@ -64,6 +64,7 @@ namespace cv
|
|||||||
CV_EXPORTS int getNumberOfSMs(int device);
|
CV_EXPORTS int getNumberOfSMs(int device);
|
||||||
|
|
||||||
//////////////////////////////// GpuMat ////////////////////////////////
|
//////////////////////////////// GpuMat ////////////////////////////////
|
||||||
|
class CudaStrem;
|
||||||
|
|
||||||
//! Smart pointer for GPU memory with reference counting. Its interface is mostly similar with cv::Mat.
|
//! Smart pointer for GPU memory with reference counting. Its interface is mostly similar with cv::Mat.
|
||||||
class CV_EXPORTS GpuMat
|
class CV_EXPORTS GpuMat
|
||||||
|
@ -64,22 +64,25 @@ namespace imgproc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace cv { namespace gpu { namespace impl {
|
namespace cv { namespace gpu { namespace impl
|
||||||
extern "C" void remap_gpu(const DevMem2D& src, const DevMem2D_<float>& xmap, const DevMem2D_<float>& ymap, DevMem2D dst, size_t width, size_t height)
|
{
|
||||||
|
using namespace imgproc;
|
||||||
|
|
||||||
|
extern "C" void remap_gpu(const DevMem2D& src, const DevMem2D_<float>& xmap, const DevMem2D_<float>& ymap, DevMem2D dst)
|
||||||
{
|
{
|
||||||
dim3 block(16, 16, 1);
|
dim3 block(16, 16, 1);
|
||||||
dim3 grid(1, 1, 1);
|
dim3 grid(1, 1, 1);
|
||||||
grid.x = divUp( width, block.x);
|
grid.x = divUp(dst.cols, block.x);
|
||||||
grid.y = divUp(height, block.y);
|
grid.y = divUp(dst.rows, block.y);
|
||||||
|
|
||||||
::imgproc::tex.filterMode = cudaFilterModeLinear;
|
tex.filterMode = cudaFilterModeLinear;
|
||||||
::imgproc::tex.addressMode[0] = ::imgproc::tex.addressMode[1] = cudaAddressModeWrap;
|
tex.addressMode[0] = tex.addressMode[1] = cudaAddressModeWrap;
|
||||||
cudaChannelFormatDesc desc = cudaCreateChannelDesc<unsigned char>();
|
cudaChannelFormatDesc desc = cudaCreateChannelDesc<unsigned char>();
|
||||||
cudaSafeCall( cudaBindTexture2D(0, ::imgproc::tex, src.ptr, desc, width, height, src.step) );
|
cudaSafeCall( cudaBindTexture2D(0, tex, src.ptr, desc, dst.cols, dst.rows, src.step) );
|
||||||
|
|
||||||
::imgproc::kernel_remap<<<grid, block>>>(xmap.ptr, ymap.ptr, xmap.step, dst.ptr, dst.step, width, height);
|
kernel_remap<<<grid, block>>>(xmap.ptr, ymap.ptr, xmap.step, dst.ptr, dst.step, dst.cols, dst.rows);
|
||||||
|
|
||||||
cudaSafeCall( cudaThreadSynchronize() );
|
cudaSafeCall( cudaThreadSynchronize() );
|
||||||
cudaSafeCall( cudaUnbindTexture(::imgproc::tex) );
|
cudaSafeCall( cudaUnbindTexture(tex) );
|
||||||
}
|
}
|
||||||
}}}
|
}}}
|
@ -47,29 +47,27 @@ using namespace cv::gpu;
|
|||||||
|
|
||||||
#if !defined (HAVE_CUDA)
|
#if !defined (HAVE_CUDA)
|
||||||
|
|
||||||
namespace cv
|
cv::gpu::remap(const GpuMat& /*src*/, const GpuMat& /*xmap*/, const GpuMat& /*ymap*/, GpuMat& /*dst*/) { throw_nogpu(); }
|
||||||
{
|
|
||||||
namespace gpu
|
|
||||||
{
|
|
||||||
remap(const GpuMat& /*src*/, const GpuMat& /*xmap*/, const GpuMat& /*ymap*/, GpuMat& /*dst*/) { throw_nogpu(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* !defined (HAVE_CUDA) */
|
#else /* !defined (HAVE_CUDA) */
|
||||||
|
|
||||||
namespace cv { namespace gpu { namespace impl {
|
namespace cv { namespace gpu
|
||||||
extern "C" void remap_gpu(const DevMem2D& src, const DevMem2D_<float>& xmap, const DevMem2D_<float>& ymap, DevMem2D dst, size_t width, size_t height);
|
{
|
||||||
}}}
|
namespace impl
|
||||||
|
{
|
||||||
|
extern "C" void remap_gpu(const DevMem2D& src, const DevMem2D_<float>& xmap, const DevMem2D_<float>& ymap, DevMem2D dst);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
|
||||||
void cv::gpu::remap(const GpuMat& src, const GpuMat& xmap, const GpuMat& ymap, GpuMat& dst)
|
void cv::gpu::remap(const GpuMat& src, const GpuMat& xmap, const GpuMat& ymap, GpuMat& dst)
|
||||||
{
|
{
|
||||||
CV_Assert((!xmap.data || xmap.size() == ymap.size()));
|
CV_DbgAssert(xmap.data && xmap.cols == ymap.cols && xmap.rows == ymap.rows);
|
||||||
dst.create(xmap.size(), src.type());
|
CV_Assert(xmap.type() == CV_32F && ymap.type() == CV_32F);
|
||||||
CV_Assert(dst.data != src.data );
|
|
||||||
|
|
||||||
impl::remap_gpu(src, xmap, ymap, dst, dst.cols, dst.rows);
|
dst.create(xmap.size(), src.type());
|
||||||
|
CV_Assert(dst.data != src.data);
|
||||||
|
|
||||||
|
impl::remap_gpu(src, xmap, ymap, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !defined (HAVE_CUDA) */
|
#endif /* !defined (HAVE_CUDA) */
|
Loading…
Reference in New Issue
Block a user