switched to Input/Output Array in bilateralFilter & blendLinear
This commit is contained in:
@@ -446,15 +446,15 @@ inline void matchTemplate(InputArray image, InputArray templ, OutputArray result
|
||||
////////////////////////// Bilateral Filter ///////////////////////////
|
||||
|
||||
//! Performa bilateral filtering of passsed image
|
||||
CV_EXPORTS void bilateralFilter(const GpuMat& src, GpuMat& dst, int kernel_size, float sigma_color, float sigma_spatial,
|
||||
CV_EXPORTS void bilateralFilter(InputArray src, OutputArray dst, int kernel_size, float sigma_color, float sigma_spatial,
|
||||
int borderMode = BORDER_DEFAULT, Stream& stream = Stream::Null());
|
||||
|
||||
///////////////////////////// Blending ////////////////////////////////
|
||||
|
||||
//! performs linear blending of two images
|
||||
//! to avoid accuracy errors sum of weigths shouldn't be very close to zero
|
||||
CV_EXPORTS void blendLinear(const GpuMat& img1, const GpuMat& img2, const GpuMat& weights1, const GpuMat& weights2,
|
||||
GpuMat& result, Stream& stream = Stream::Null());
|
||||
CV_EXPORTS void blendLinear(InputArray img1, InputArray img2, InputArray weights1, InputArray weights2,
|
||||
OutputArray result, Stream& stream = Stream::Null());
|
||||
|
||||
}} // namespace cv { namespace gpu {
|
||||
|
||||
|
@@ -47,7 +47,7 @@ using namespace cv::gpu;
|
||||
|
||||
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
|
||||
|
||||
void cv::gpu::bilateralFilter(const GpuMat&, GpuMat&, int, float, float, int, Stream&) { throw_no_cuda(); }
|
||||
void cv::gpu::bilateralFilter(InputArray, OutputArray, int, float, float, int, Stream&) { throw_no_cuda(); }
|
||||
|
||||
#else
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace cv { namespace gpu { namespace cudev
|
||||
}
|
||||
}}}
|
||||
|
||||
void cv::gpu::bilateralFilter(const GpuMat& src, GpuMat& dst, int kernel_size, float sigma_color, float sigma_spatial, int borderMode, Stream& s)
|
||||
void cv::gpu::bilateralFilter(InputArray _src, OutputArray _dst, int kernel_size, float sigma_color, float sigma_spatial, int borderMode, Stream& stream)
|
||||
{
|
||||
using cv::gpu::cudev::imgproc::bilateral_filter_gpu;
|
||||
|
||||
@@ -79,18 +79,21 @@ void cv::gpu::bilateralFilter(const GpuMat& src, GpuMat& dst, int kernel_size, f
|
||||
sigma_color = (sigma_color <= 0 ) ? 1 : sigma_color;
|
||||
sigma_spatial = (sigma_spatial <= 0 ) ? 1 : sigma_spatial;
|
||||
|
||||
|
||||
int radius = (kernel_size <= 0) ? cvRound(sigma_spatial*1.5) : kernel_size/2;
|
||||
kernel_size = std::max(radius, 1)*2 + 1;
|
||||
|
||||
CV_Assert(src.depth() <= CV_32F && src.channels() <= 4);
|
||||
GpuMat src = _src.getGpuMat();
|
||||
|
||||
CV_Assert( src.depth() <= CV_32F && src.channels() <= 4 );
|
||||
CV_Assert( borderMode == BORDER_REFLECT101 || borderMode == BORDER_REPLICATE || borderMode == BORDER_CONSTANT || borderMode == BORDER_REFLECT || borderMode == BORDER_WRAP );
|
||||
|
||||
const func_t func = funcs[src.depth()][src.channels() - 1];
|
||||
CV_Assert(func != 0);
|
||||
CV_Assert( func != 0 );
|
||||
|
||||
CV_Assert(borderMode == BORDER_REFLECT101 || borderMode == BORDER_REPLICATE || borderMode == BORDER_CONSTANT || borderMode == BORDER_REFLECT || borderMode == BORDER_WRAP);
|
||||
_dst.create(src.size(), src.type());
|
||||
GpuMat dst = _dst.getGpuMat();
|
||||
|
||||
dst.create(src.size(), src.type());
|
||||
func(src, dst, kernel_size, sigma_spatial, sigma_color, borderMode, StreamAccessor::getStream(s));
|
||||
func(src, dst, kernel_size, sigma_spatial, sigma_color, borderMode, StreamAccessor::getStream(stream));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -47,7 +47,7 @@ using namespace cv::gpu;
|
||||
|
||||
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
|
||||
|
||||
void cv::gpu::blendLinear(const GpuMat&, const GpuMat&, const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_no_cuda(); }
|
||||
void cv::gpu::blendLinear(InputArray, InputArray, InputArray, InputArray, OutputArray, Stream&) { throw_no_cuda(); }
|
||||
|
||||
#else
|
||||
|
||||
@@ -67,21 +67,28 @@ namespace cv { namespace gpu { namespace cudev
|
||||
|
||||
using namespace ::cv::gpu::cudev::blend;
|
||||
|
||||
void cv::gpu::blendLinear(const GpuMat& img1, const GpuMat& img2, const GpuMat& weights1, const GpuMat& weights2,
|
||||
GpuMat& result, Stream& stream)
|
||||
void cv::gpu::blendLinear(InputArray _img1, InputArray _img2, InputArray _weights1, InputArray _weights2,
|
||||
OutputArray _result, Stream& stream)
|
||||
{
|
||||
CV_Assert(img1.size() == img2.size());
|
||||
CV_Assert(img1.type() == img2.type());
|
||||
CV_Assert(weights1.size() == img1.size());
|
||||
CV_Assert(weights2.size() == img2.size());
|
||||
CV_Assert(weights1.type() == CV_32F);
|
||||
CV_Assert(weights2.type() == CV_32F);
|
||||
GpuMat img1 = _img1.getGpuMat();
|
||||
GpuMat img2 = _img2.getGpuMat();
|
||||
|
||||
GpuMat weights1 = _weights1.getGpuMat();
|
||||
GpuMat weights2 = _weights2.getGpuMat();
|
||||
|
||||
CV_Assert( img1.size() == img2.size() );
|
||||
CV_Assert( img1.type() == img2.type() );
|
||||
CV_Assert( weights1.size() == img1.size() );
|
||||
CV_Assert( weights2.size() == img2.size() );
|
||||
CV_Assert( weights1.type() == CV_32FC1 );
|
||||
CV_Assert( weights2.type() == CV_32FC1 );
|
||||
|
||||
const Size size = img1.size();
|
||||
const int depth = img1.depth();
|
||||
const int cn = img1.channels();
|
||||
|
||||
result.create(size, CV_MAKE_TYPE(depth, cn));
|
||||
_result.create(size, CV_MAKE_TYPE(depth, cn));
|
||||
GpuMat result = _result.getGpuMat();
|
||||
|
||||
switch (depth)
|
||||
{
|
||||
|
Reference in New Issue
Block a user