From 2932beddcf5f30da75af4ee461cdc6665ab24eab Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Fri, 26 Apr 2013 17:05:59 +0400 Subject: [PATCH 1/3] switched to Input/Output Array in gpuwarping functions --- .../gpuwarping/include/opencv2/gpuwarping.hpp | 30 +-- modules/gpuwarping/src/pyramids.cpp | 30 +-- modules/gpuwarping/src/remap.cpp | 23 ++- modules/gpuwarping/src/resize.cpp | 24 ++- modules/gpuwarping/src/warp.cpp | 188 +++++++++++------- samples/gpu/cascadeclassifier.cpp | 30 ++- 6 files changed, 199 insertions(+), 126 deletions(-) diff --git a/modules/gpuwarping/include/opencv2/gpuwarping.hpp b/modules/gpuwarping/include/opencv2/gpuwarping.hpp index 18b42ce605..5b140682e3 100644 --- a/modules/gpuwarping/include/opencv2/gpuwarping.hpp +++ b/modules/gpuwarping/include/opencv2/gpuwarping.hpp @@ -54,51 +54,51 @@ namespace cv { namespace gpu { //! DST[x,y] = SRC[xmap[x,y],ymap[x,y]] //! supports only CV_32FC1 map type -CV_EXPORTS void remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap, +CV_EXPORTS void remap(InputArray src, OutputArray dst, InputArray xmap, InputArray ymap, int interpolation, int borderMode = BORDER_CONSTANT, Scalar borderValue = Scalar(), Stream& stream = Stream::Null()); //! resizes the image //! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_AREA -CV_EXPORTS void resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx=0, double fy=0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null()); +CV_EXPORTS void resize(InputArray src, OutputArray dst, Size dsize, double fx=0, double fy=0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null()); //! warps the image using affine transformation //! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC -CV_EXPORTS void warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR, +CV_EXPORTS void warpAffine(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags = INTER_LINEAR, int borderMode = BORDER_CONSTANT, Scalar borderValue = Scalar(), Stream& stream = Stream::Null()); -CV_EXPORTS void buildWarpAffineMaps(const Mat& M, bool inverse, Size dsize, GpuMat& xmap, GpuMat& ymap, Stream& stream = Stream::Null()); +CV_EXPORTS void buildWarpAffineMaps(InputArray M, bool inverse, Size dsize, OutputArray xmap, OutputArray ymap, Stream& stream = Stream::Null()); //! warps the image using perspective transformation //! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC -CV_EXPORTS void warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR, +CV_EXPORTS void warpPerspective(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags = INTER_LINEAR, int borderMode = BORDER_CONSTANT, Scalar borderValue = Scalar(), Stream& stream = Stream::Null()); -CV_EXPORTS void buildWarpPerspectiveMaps(const Mat& M, bool inverse, Size dsize, GpuMat& xmap, GpuMat& ymap, Stream& stream = Stream::Null()); +CV_EXPORTS void buildWarpPerspectiveMaps(InputArray M, bool inverse, Size dsize, OutputArray xmap, OutputArray ymap, Stream& stream = Stream::Null()); //! builds plane warping maps -CV_EXPORTS void buildWarpPlaneMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat& R, const Mat &T, float scale, - GpuMat& map_x, GpuMat& map_y, Stream& stream = Stream::Null()); +CV_EXPORTS void buildWarpPlaneMaps(Size src_size, Rect dst_roi, InputArray K, InputArray R, InputArray T, float scale, + OutputArray map_x, OutputArray map_y, Stream& stream = Stream::Null()); //! builds cylindrical warping maps -CV_EXPORTS void buildWarpCylindricalMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat& R, float scale, - GpuMat& map_x, GpuMat& map_y, Stream& stream = Stream::Null()); +CV_EXPORTS void buildWarpCylindricalMaps(Size src_size, Rect dst_roi, InputArray K, InputArray R, float scale, + OutputArray map_x, OutputArray map_y, Stream& stream = Stream::Null()); //! builds spherical warping maps -CV_EXPORTS void buildWarpSphericalMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat& R, float scale, - GpuMat& map_x, GpuMat& map_y, Stream& stream = Stream::Null()); +CV_EXPORTS void buildWarpSphericalMaps(Size src_size, Rect dst_roi, InputArray K, InputArray R, float scale, + OutputArray map_x, OutputArray map_y, Stream& stream = Stream::Null()); //! rotates an image around the origin (0,0) and then shifts it //! supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC //! supports 1, 3 or 4 channels images with CV_8U, CV_16U or CV_32F depth -CV_EXPORTS void rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift = 0, double yShift = 0, +CV_EXPORTS void rotate(InputArray src, OutputArray dst, Size dsize, double angle, double xShift = 0, double yShift = 0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null()); //! smoothes the source image and downsamples it -CV_EXPORTS void pyrDown(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null()); +CV_EXPORTS void pyrDown(InputArray src, OutputArray dst, Stream& stream = Stream::Null()); //! upsamples the source image and then smoothes it -CV_EXPORTS void pyrUp(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null()); +CV_EXPORTS void pyrUp(InputArray src, OutputArray dst, Stream& stream = Stream::Null()); class CV_EXPORTS ImagePyramid { diff --git a/modules/gpuwarping/src/pyramids.cpp b/modules/gpuwarping/src/pyramids.cpp index 19d5dcf94a..39812352d8 100644 --- a/modules/gpuwarping/src/pyramids.cpp +++ b/modules/gpuwarping/src/pyramids.cpp @@ -44,9 +44,8 @@ #if !defined HAVE_CUDA || defined(CUDA_DISABLER) -void cv::gpu::pyrDown(const GpuMat&, GpuMat&, Stream&) { throw_no_cuda(); } - -void cv::gpu::pyrUp(const GpuMat&, GpuMat&, Stream&) { throw_no_cuda(); } +void cv::gpu::pyrDown(InputArray, OutputArray, Stream&) { throw_no_cuda(); } +void cv::gpu::pyrUp(InputArray, OutputArray, Stream&) { throw_no_cuda(); } void cv::gpu::ImagePyramid::build(const GpuMat&, int, Stream&) { throw_no_cuda(); } void cv::gpu::ImagePyramid::getLayer(GpuMat&, Size, Stream&) const { throw_no_cuda(); } @@ -64,12 +63,11 @@ namespace cv { namespace gpu { namespace cudev } }}} -void cv::gpu::pyrDown(const GpuMat& src, GpuMat& dst, Stream& stream) +void cv::gpu::pyrDown(InputArray _src, OutputArray _dst, Stream& stream) { using namespace cv::gpu::cudev::imgproc; typedef void (*func_t)(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream); - static const func_t funcs[6][4] = { {pyrDown_gpu , 0 /*pyrDown_gpu*/ , pyrDown_gpu , pyrDown_gpu }, @@ -80,12 +78,15 @@ void cv::gpu::pyrDown(const GpuMat& src, GpuMat& dst, Stream& stream) {pyrDown_gpu , 0 /*pyrDown_gpu*/ , pyrDown_gpu , pyrDown_gpu } }; - CV_Assert(src.depth() <= CV_32F && src.channels() <= 4); + GpuMat src = _src.getGpuMat(); + + CV_Assert( src.depth() <= CV_32F && src.channels() <= 4 ); const func_t func = funcs[src.depth()][src.channels() - 1]; - CV_Assert(func != 0); + CV_Assert( func != 0 ); - dst.create((src.rows + 1) / 2, (src.cols + 1) / 2, src.type()); + _dst.create((src.rows + 1) / 2, (src.cols + 1) / 2, src.type()); + GpuMat dst = _dst.getGpuMat(); func(src, dst, StreamAccessor::getStream(stream)); } @@ -102,12 +103,11 @@ namespace cv { namespace gpu { namespace cudev } }}} -void cv::gpu::pyrUp(const GpuMat& src, GpuMat& dst, Stream& stream) +void cv::gpu::pyrUp(InputArray _src, OutputArray _dst, Stream& stream) { using namespace cv::gpu::cudev::imgproc; typedef void (*func_t)(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream); - static const func_t funcs[6][4] = { {pyrUp_gpu , 0 /*pyrUp_gpu*/ , pyrUp_gpu , pyrUp_gpu }, @@ -118,17 +118,19 @@ void cv::gpu::pyrUp(const GpuMat& src, GpuMat& dst, Stream& stream) {pyrUp_gpu , 0 /*pyrUp_gpu*/ , pyrUp_gpu , pyrUp_gpu } }; - CV_Assert(src.depth() <= CV_32F && src.channels() <= 4); + GpuMat src = _src.getGpuMat(); + + CV_Assert( src.depth() <= CV_32F && src.channels() <= 4 ); const func_t func = funcs[src.depth()][src.channels() - 1]; - CV_Assert(func != 0); + CV_Assert( func != 0 ); - dst.create(src.rows * 2, src.cols * 2, src.type()); + _dst.create(src.rows * 2, src.cols * 2, src.type()); + GpuMat dst = _dst.getGpuMat(); func(src, dst, StreamAccessor::getStream(stream)); } - ////////////////////////////////////////////////////////////////////////////// // ImagePyramid diff --git a/modules/gpuwarping/src/remap.cpp b/modules/gpuwarping/src/remap.cpp index 131f937638..c3d797783a 100644 --- a/modules/gpuwarping/src/remap.cpp +++ b/modules/gpuwarping/src/remap.cpp @@ -44,7 +44,7 @@ #if !defined HAVE_CUDA || defined(CUDA_DISABLER) -void cv::gpu::remap(const GpuMat&, GpuMat&, const GpuMat&, const GpuMat&, int, int, Scalar, Stream&){ throw_no_cuda(); } +void cv::gpu::remap(InputArray, OutputArray, InputArray, InputArray, int, int, Scalar, Stream&){ throw_no_cuda(); } #else // HAVE_CUDA @@ -58,13 +58,12 @@ namespace cv { namespace gpu { namespace cudev } }}} -void cv::gpu::remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap, int interpolation, int borderMode, Scalar borderValue, Stream& stream) +void cv::gpu::remap(InputArray _src, OutputArray _dst, InputArray _xmap, InputArray _ymap, int interpolation, int borderMode, Scalar borderValue, Stream& stream) { using namespace cv::gpu::cudev::imgproc; typedef void (*func_t)(PtrStepSzb src, PtrStepSzb srcWhole, int xoff, int yoff, PtrStepSzf xmap, PtrStepSzf ymap, PtrStepSzb dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, bool cc20); - static const func_t funcs[6][4] = { {remap_gpu , 0 /*remap_gpu*/ , remap_gpu , remap_gpu }, @@ -75,15 +74,21 @@ void cv::gpu::remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const Gp {remap_gpu , 0 /*remap_gpu*/ , remap_gpu , remap_gpu } }; - CV_Assert(src.depth() <= CV_32F && src.channels() <= 4); - CV_Assert(xmap.type() == CV_32F && ymap.type() == CV_32F && xmap.size() == ymap.size()); - CV_Assert(interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC); - CV_Assert(borderMode == BORDER_REFLECT101 || borderMode == BORDER_REPLICATE || borderMode == BORDER_CONSTANT || borderMode == BORDER_REFLECT || borderMode == BORDER_WRAP); + GpuMat src = _src.getGpuMat(); + GpuMat xmap = _xmap.getGpuMat(); + GpuMat ymap = _ymap.getGpuMat(); + + CV_Assert( src.depth() <= CV_32F && src.channels() <= 4 ); + CV_Assert( xmap.type() == CV_32F && ymap.type() == CV_32F && xmap.size() == ymap.size() ); + CV_Assert( interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC ); + 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); + if (!func) + CV_Error(Error::StsUnsupportedFormat, "Unsupported input type"); - dst.create(xmap.size(), src.type()); + _dst.create(xmap.size(), src.type()); + GpuMat dst = _dst.getGpuMat(); Scalar_ borderValueFloat; borderValueFloat = borderValue; diff --git a/modules/gpuwarping/src/resize.cpp b/modules/gpuwarping/src/resize.cpp index 5cb5184833..83dade2796 100644 --- a/modules/gpuwarping/src/resize.cpp +++ b/modules/gpuwarping/src/resize.cpp @@ -44,7 +44,7 @@ #if !defined HAVE_CUDA || defined(CUDA_DISABLER) -void cv::gpu::resize(const GpuMat&, GpuMat&, Size, double, double, int, Stream&) { throw_no_cuda(); } +void cv::gpu::resize(InputArray, OutputArray, Size, double, double, int, Stream&) { throw_no_cuda(); } #else // HAVE_CUDA @@ -58,30 +58,34 @@ namespace cv { namespace gpu { namespace cudev } }}} -void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, double fy, int interpolation, Stream& s) +void cv::gpu::resize(InputArray _src, OutputArray _dst, Size dsize, double fx, double fy, int interpolation, Stream& _stream) { - CV_Assert(src.depth() <= CV_32F && src.channels() <= 4); - CV_Assert(interpolation == INTER_NEAREST || interpolation == INTER_LINEAR - || interpolation == INTER_CUBIC || interpolation == INTER_AREA); - CV_Assert(!(dsize == Size()) || (fx > 0 && fy > 0)); + GpuMat src = _src.getGpuMat(); + + CV_Assert( src.depth() <= CV_32F && src.channels() <= 4 ); + CV_Assert( interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC || interpolation == INTER_AREA ); + CV_Assert( !(dsize == Size()) || (fx > 0 && fy > 0) ); if (dsize == Size()) + { dsize = Size(saturate_cast(src.cols * fx), saturate_cast(src.rows * fy)); + } else { fx = static_cast(dsize.width) / src.cols; fy = static_cast(dsize.height) / src.rows; } - if (dsize != dst.size()) - dst.create(dsize, src.type()); + + _dst.create(dsize, src.type()); + GpuMat dst = _dst.getGpuMat(); if (dsize == src.size()) { - src.copyTo(dst, s); + src.copyTo(dst, _stream); return; } - cudaStream_t stream = StreamAccessor::getStream(s); + cudaStream_t stream = StreamAccessor::getStream(_stream); Size wholeSize; Point ofs; diff --git a/modules/gpuwarping/src/warp.cpp b/modules/gpuwarping/src/warp.cpp index b3c44e5624..2775fc0847 100644 --- a/modules/gpuwarping/src/warp.cpp +++ b/modules/gpuwarping/src/warp.cpp @@ -47,17 +47,17 @@ using namespace cv::gpu; #if !defined HAVE_CUDA || defined(CUDA_DISABLER) -void cv::gpu::warpAffine(const GpuMat&, GpuMat&, const Mat&, Size, int, int, Scalar, Stream&) { throw_no_cuda(); } -void cv::gpu::buildWarpAffineMaps(const Mat&, bool, Size, GpuMat&, GpuMat&, Stream&) { throw_no_cuda(); } +void cv::gpu::warpAffine(InputArray, OutputArray, InputArray, Size, int, int, Scalar, Stream&) { throw_no_cuda(); } +void cv::gpu::buildWarpAffineMaps(InputArray, bool, Size, OutputArray, OutputArray, Stream&) { throw_no_cuda(); } -void cv::gpu::warpPerspective(const GpuMat&, GpuMat&, const Mat&, Size, int, int, Scalar, Stream&) { throw_no_cuda(); } -void cv::gpu::buildWarpPerspectiveMaps(const Mat&, bool, Size, GpuMat&, GpuMat&, Stream&) { throw_no_cuda(); } +void cv::gpu::warpPerspective(InputArray, OutputArray, InputArray, Size, int, int, Scalar, Stream&) { throw_no_cuda(); } +void cv::gpu::buildWarpPerspectiveMaps(InputArray, bool, Size, OutputArray, OutputArray, Stream&) { throw_no_cuda(); } -void cv::gpu::buildWarpPlaneMaps(Size, Rect, const Mat&, const Mat&, const Mat&, float, GpuMat&, GpuMat&, Stream&) { throw_no_cuda(); } -void cv::gpu::buildWarpCylindricalMaps(Size, Rect, const Mat&, const Mat&, float, GpuMat&, GpuMat&, Stream&) { throw_no_cuda(); } -void cv::gpu::buildWarpSphericalMaps(Size, Rect, const Mat&, const Mat&, float, GpuMat&, GpuMat&, Stream&) { throw_no_cuda(); } +void cv::gpu::buildWarpPlaneMaps(Size, Rect, InputArray, InputArray, InputArray, float, OutputArray, OutputArray, Stream&) { throw_no_cuda(); } +void cv::gpu::buildWarpCylindricalMaps(Size, Rect, InputArray, InputArray, float, OutputArray, OutputArray, Stream&) { throw_no_cuda(); } +void cv::gpu::buildWarpSphericalMaps(Size, Rect, InputArray, InputArray, float, OutputArray, OutputArray, Stream&) { throw_no_cuda(); } -void cv::gpu::rotate(const GpuMat&, GpuMat&, Size, double, double, double, int, Stream&) { throw_no_cuda(); } +void cv::gpu::rotate(InputArray, OutputArray, Size, double, double, double, int, Stream&) { throw_no_cuda(); } #else // HAVE_CUDA @@ -79,14 +79,19 @@ namespace cv { namespace gpu { namespace cudev } }}} -void cv::gpu::buildWarpAffineMaps(const Mat& M, bool inverse, Size dsize, GpuMat& xmap, GpuMat& ymap, Stream& stream) +void cv::gpu::buildWarpAffineMaps(InputArray _M, bool inverse, Size dsize, OutputArray _xmap, OutputArray _ymap, Stream& stream) { using namespace cv::gpu::cudev::imgproc; - CV_Assert(M.rows == 2 && M.cols == 3); + Mat M = _M.getMat(); - xmap.create(dsize, CV_32FC1); - ymap.create(dsize, CV_32FC1); + CV_Assert( M.rows == 2 && M.cols == 3 ); + + _xmap.create(dsize, CV_32FC1); + _ymap.create(dsize, CV_32FC1); + + GpuMat xmap = _xmap.getGpuMat(); + GpuMat ymap = _ymap.getGpuMat(); float coeffs[2 * 3]; Mat coeffsMat(2, 3, CV_32F, (void*)coeffs); @@ -103,14 +108,19 @@ void cv::gpu::buildWarpAffineMaps(const Mat& M, bool inverse, Size dsize, GpuMat buildWarpAffineMaps_gpu(coeffs, xmap, ymap, StreamAccessor::getStream(stream)); } -void cv::gpu::buildWarpPerspectiveMaps(const Mat& M, bool inverse, Size dsize, GpuMat& xmap, GpuMat& ymap, Stream& stream) +void cv::gpu::buildWarpPerspectiveMaps(InputArray _M, bool inverse, Size dsize, OutputArray _xmap, OutputArray _ymap, Stream& stream) { using namespace cv::gpu::cudev::imgproc; - CV_Assert(M.rows == 3 && M.cols == 3); + Mat M = _M.getMat(); - xmap.create(dsize, CV_32FC1); - ymap.create(dsize, CV_32FC1); + CV_Assert( M.rows == 3 && M.cols == 3 ); + + _xmap.create(dsize, CV_32FC1); + _ymap.create(dsize, CV_32FC1); + + GpuMat xmap = _xmap.getGpuMat(); + GpuMat ymap = _ymap.getGpuMat(); float coeffs[3 * 3]; Mat coeffsMat(3, 3, CV_32F, (void*)coeffs); @@ -174,17 +184,21 @@ namespace }; } -void cv::gpu::warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags, int borderMode, Scalar borderValue, Stream& s) +void cv::gpu::warpAffine(InputArray _src, OutputArray _dst, InputArray _M, Size dsize, int flags, int borderMode, Scalar borderValue, Stream& stream) { - CV_Assert(M.rows == 2 && M.cols == 3); + GpuMat src = _src.getGpuMat(); + Mat M = _M.getMat(); - int interpolation = flags & INTER_MAX; + CV_Assert( M.rows == 2 && M.cols == 3 ); - CV_Assert(src.depth() <= CV_32F && src.channels() <= 4); - CV_Assert(interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC); - CV_Assert(borderMode == BORDER_REFLECT101 || borderMode == BORDER_REPLICATE || borderMode == BORDER_CONSTANT || borderMode == BORDER_REFLECT || borderMode == BORDER_WRAP); + const int interpolation = flags & INTER_MAX; - dst.create(dsize, src.type()); + CV_Assert( src.depth() <= CV_32F && src.channels() <= 4 ); + CV_Assert( interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC ); + CV_Assert( borderMode == BORDER_REFLECT101 || borderMode == BORDER_REPLICATE || borderMode == BORDER_CONSTANT || borderMode == BORDER_REFLECT || borderMode == BORDER_WRAP ); + + _dst.create(dsize, src.type()); + GpuMat dst = _dst.getGpuMat(); Size wholeSize; Point ofs; @@ -258,7 +272,7 @@ void cv::gpu::warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsiz } }; - dst.setTo(borderValue); + dst.setTo(borderValue, stream); double coeffs[2][3]; Mat coeffsMat(2, 3, CV_64F, (void*)coeffs); @@ -267,7 +281,7 @@ void cv::gpu::warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsiz const func_t func = funcs[(flags & WARP_INVERSE_MAP) != 0][src.depth()][src.channels() - 1]; CV_Assert(func != 0); - func(src, dst, coeffs, interpolation, StreamAccessor::getStream(s)); + func(src, dst, coeffs, interpolation, StreamAccessor::getStream(stream)); } else { @@ -305,21 +319,25 @@ void cv::gpu::warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsiz borderValueFloat = borderValue; func(src, PtrStepSzb(wholeSize.height, wholeSize.width, src.datastart, src.step), ofs.x, ofs.y, coeffs, - dst, interpolation, borderMode, borderValueFloat.val, StreamAccessor::getStream(s), deviceSupports(FEATURE_SET_COMPUTE_20)); + dst, interpolation, borderMode, borderValueFloat.val, StreamAccessor::getStream(stream), deviceSupports(FEATURE_SET_COMPUTE_20)); } } -void cv::gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags, int borderMode, Scalar borderValue, Stream& s) +void cv::gpu::warpPerspective(InputArray _src, OutputArray _dst, InputArray _M, Size dsize, int flags, int borderMode, Scalar borderValue, Stream& stream) { - CV_Assert(M.rows == 3 && M.cols == 3); + GpuMat src = _src.getGpuMat(); + Mat M = _M.getMat(); - int interpolation = flags & INTER_MAX; + CV_Assert( M.rows == 3 && M.cols == 3 ); - CV_Assert(src.depth() <= CV_32F && src.channels() <= 4); - CV_Assert(interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC); - CV_Assert(borderMode == BORDER_REFLECT101 || borderMode == BORDER_REPLICATE || borderMode == BORDER_CONSTANT || borderMode == BORDER_REFLECT || borderMode == BORDER_WRAP); + const int interpolation = flags & INTER_MAX; - dst.create(dsize, src.type()); + CV_Assert( src.depth() <= CV_32F && src.channels() <= 4 ); + CV_Assert( interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC ); + CV_Assert( borderMode == BORDER_REFLECT101 || borderMode == BORDER_REPLICATE || borderMode == BORDER_CONSTANT || borderMode == BORDER_REFLECT || borderMode == BORDER_WRAP) ; + + _dst.create(dsize, src.type()); + GpuMat dst = _dst.getGpuMat(); Size wholeSize; Point ofs; @@ -393,7 +411,7 @@ void cv::gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size } }; - dst.setTo(borderValue); + dst.setTo(borderValue, stream); double coeffs[3][3]; Mat coeffsMat(3, 3, CV_64F, (void*)coeffs); @@ -402,7 +420,7 @@ void cv::gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size const func_t func = funcs[(flags & WARP_INVERSE_MAP) != 0][src.depth()][src.channels() - 1]; CV_Assert(func != 0); - func(src, dst, coeffs, interpolation, StreamAccessor::getStream(s)); + func(src, dst, coeffs, interpolation, StreamAccessor::getStream(stream)); } else { @@ -440,7 +458,7 @@ void cv::gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size borderValueFloat = borderValue; func(src, PtrStepSzb(wholeSize.height, wholeSize.width, src.datastart, src.step), ofs.x, ofs.y, coeffs, - dst, interpolation, borderMode, borderValueFloat.val, StreamAccessor::getStream(s), deviceSupports(FEATURE_SET_COMPUTE_20)); + dst, interpolation, borderMode, borderValueFloat.val, StreamAccessor::getStream(stream), deviceSupports(FEATURE_SET_COMPUTE_20)); } } @@ -457,23 +475,30 @@ namespace cv { namespace gpu { namespace cudev } }}} -void cv::gpu::buildWarpPlaneMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat& R, const Mat &T, - float scale, GpuMat& map_x, GpuMat& map_y, Stream& stream) +void cv::gpu::buildWarpPlaneMaps(Size src_size, Rect dst_roi, InputArray _K, InputArray _R, InputArray _T, + float scale, OutputArray _map_x, OutputArray _map_y, Stream& stream) { - (void)src_size; - using namespace ::cv::gpu::cudev::imgproc; + (void) src_size; - CV_Assert(K.size() == Size(3,3) && K.type() == CV_32F); - CV_Assert(R.size() == Size(3,3) && R.type() == CV_32F); - CV_Assert((T.size() == Size(3,1) || T.size() == Size(1,3)) && T.type() == CV_32F && T.isContinuous()); + Mat K = _K.getMat(); + Mat R = _R.getMat(); + Mat T = _T.getMat(); + + CV_Assert( K.size() == Size(3,3) && K.type() == CV_32FC1 ); + CV_Assert( R.size() == Size(3,3) && R.type() == CV_32FC1 ); + CV_Assert( (T.size() == Size(3,1) || T.size() == Size(1,3)) && T.type() == CV_32FC1 && T.isContinuous() ); Mat K_Rinv = K * R.t(); Mat R_Kinv = R * K.inv(); - CV_Assert(K_Rinv.isContinuous()); - CV_Assert(R_Kinv.isContinuous()); + CV_Assert( K_Rinv.isContinuous() ); + CV_Assert( R_Kinv.isContinuous() ); + + _map_x.create(dst_roi.size(), CV_32FC1); + _map_y.create(dst_roi.size(), CV_32FC1); + + GpuMat map_x = _map_x.getGpuMat(); + GpuMat map_y = _map_y.getGpuMat(); - map_x.create(dst_roi.size(), CV_32F); - map_y.create(dst_roi.size(), CV_32F); cudev::imgproc::buildWarpPlaneMaps(dst_roi.tl().x, dst_roi.tl().y, map_x, map_y, K_Rinv.ptr(), R_Kinv.ptr(), T.ptr(), scale, StreamAccessor::getStream(stream)); } @@ -491,22 +516,28 @@ namespace cv { namespace gpu { namespace cudev } }}} -void cv::gpu::buildWarpCylindricalMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat& R, float scale, - GpuMat& map_x, GpuMat& map_y, Stream& stream) +void cv::gpu::buildWarpCylindricalMaps(Size src_size, Rect dst_roi, InputArray _K, InputArray _R, float scale, + OutputArray _map_x, OutputArray _map_y, Stream& stream) { - (void)src_size; - using namespace ::cv::gpu::cudev::imgproc; + (void) src_size; - CV_Assert(K.size() == Size(3,3) && K.type() == CV_32F); - CV_Assert(R.size() == Size(3,3) && R.type() == CV_32F); + Mat K = _K.getMat(); + Mat R = _R.getMat(); + + CV_Assert( K.size() == Size(3,3) && K.type() == CV_32FC1 ); + CV_Assert( R.size() == Size(3,3) && R.type() == CV_32FC1 ); Mat K_Rinv = K * R.t(); Mat R_Kinv = R * K.inv(); - CV_Assert(K_Rinv.isContinuous()); - CV_Assert(R_Kinv.isContinuous()); + CV_Assert( K_Rinv.isContinuous() ); + CV_Assert( R_Kinv.isContinuous() ); + + _map_x.create(dst_roi.size(), CV_32FC1); + _map_y.create(dst_roi.size(), CV_32FC1); + + GpuMat map_x = _map_x.getGpuMat(); + GpuMat map_y = _map_y.getGpuMat(); - map_x.create(dst_roi.size(), CV_32F); - map_y.create(dst_roi.size(), CV_32F); cudev::imgproc::buildWarpCylindricalMaps(dst_roi.tl().x, dst_roi.tl().y, map_x, map_y, K_Rinv.ptr(), R_Kinv.ptr(), scale, StreamAccessor::getStream(stream)); } @@ -524,22 +555,28 @@ namespace cv { namespace gpu { namespace cudev } }}} -void cv::gpu::buildWarpSphericalMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat& R, float scale, - GpuMat& map_x, GpuMat& map_y, Stream& stream) +void cv::gpu::buildWarpSphericalMaps(Size src_size, Rect dst_roi, InputArray _K, InputArray _R, float scale, + OutputArray _map_x, OutputArray _map_y, Stream& stream) { - (void)src_size; - using namespace ::cv::gpu::cudev::imgproc; + (void) src_size; - CV_Assert(K.size() == Size(3,3) && K.type() == CV_32F); - CV_Assert(R.size() == Size(3,3) && R.type() == CV_32F); + Mat K = _K.getMat(); + Mat R = _R.getMat(); + + CV_Assert( K.size() == Size(3,3) && K.type() == CV_32FC1 ); + CV_Assert( R.size() == Size(3,3) && R.type() == CV_32FC1 ); Mat K_Rinv = K * R.t(); Mat R_Kinv = R * K.inv(); - CV_Assert(K_Rinv.isContinuous()); - CV_Assert(R_Kinv.isContinuous()); + CV_Assert( K_Rinv.isContinuous() ); + CV_Assert( R_Kinv.isContinuous() ); + + _map_x.create(dst_roi.size(), CV_32FC1); + _map_y.create(dst_roi.size(), CV_32FC1); + + GpuMat map_x = _map_x.getGpuMat(); + GpuMat map_y = _map_y.getGpuMat(); - map_x.create(dst_roi.size(), CV_32F); - map_y.create(dst_roi.size(), CV_32F); cudev::imgproc::buildWarpSphericalMaps(dst_roi.tl().x, dst_roi.tl().y, map_x, map_y, K_Rinv.ptr(), R_Kinv.ptr(), scale, StreamAccessor::getStream(stream)); } @@ -589,10 +626,9 @@ namespace }; } -void cv::gpu::rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift, double yShift, int interpolation, Stream& stream) +void cv::gpu::rotate(InputArray _src, OutputArray _dst, Size dsize, double angle, double xShift, double yShift, int interpolation, Stream& stream) { typedef void (*func_t)(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift, double yShift, int interpolation, cudaStream_t stream); - static const func_t funcs[6][4] = { {NppRotate::call, 0, NppRotate::call, NppRotate::call}, @@ -603,12 +639,16 @@ void cv::gpu::rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, d {NppRotate::call, 0, NppRotate::call, NppRotate::call} }; - CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F); - CV_Assert(src.channels() == 1 || src.channels() == 3 || src.channels() == 4); - CV_Assert(interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC); + GpuMat src = _src.getGpuMat(); - dst.create(dsize, src.type()); - dst.setTo(Scalar::all(0)); + CV_Assert( src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F ); + CV_Assert( src.channels() == 1 || src.channels() == 3 || src.channels() == 4 ); + CV_Assert( interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC ); + + _dst.create(dsize, src.type()); + GpuMat dst = _dst.getGpuMat(); + + dst.setTo(Scalar::all(0), stream); funcs[src.depth()][src.channels() - 1](src, dst, dsize, angle, xShift, yShift, interpolation, StreamAccessor::getStream(stream)); } diff --git a/samples/gpu/cascadeclassifier.cpp b/samples/gpu/cascadeclassifier.cpp index 271e7dca85..942a964d5a 100644 --- a/samples/gpu/cascadeclassifier.cpp +++ b/samples/gpu/cascadeclassifier.cpp @@ -24,12 +24,11 @@ static void help() } -template -void convertAndResize(const T& src, T& gray, T& resized, double scale) +static void convertAndResize(const Mat& src, Mat& gray, Mat& resized, double scale) { if (src.channels() == 3) { - cvtColor( src, gray, COLOR_BGR2GRAY ); + cv::cvtColor( src, gray, COLOR_BGR2GRAY ); } else { @@ -40,7 +39,30 @@ void convertAndResize(const T& src, T& gray, T& resized, double scale) if (scale != 1) { - resize(gray, resized, sz); + cv::resize(gray, resized, sz); + } + else + { + resized = gray; + } +} + +static void convertAndResize(const GpuMat& src, GpuMat& gray, GpuMat& resized, double scale) +{ + if (src.channels() == 3) + { + gpu::cvtColor( src, gray, COLOR_BGR2GRAY ); + } + else + { + gray = src; + } + + Size sz(cvRound(gray.cols * scale), cvRound(gray.rows * scale)); + + if (scale != 1) + { + gpu::resize(gray, resized, sz); } else { From 6d6ff268872bc3e650af6e264a66fcce5fbc62cd Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Fri, 26 Apr 2013 17:18:56 +0400 Subject: [PATCH 2/3] refactored gpu::ImagePyramid (converted it to abstract interface) --- .../gpuwarping/include/opencv2/gpuwarping.hpp | 26 +-- modules/gpuwarping/perf/perf_warping.cpp | 43 +---- modules/gpuwarping/src/pyramids.cpp | 172 ++++++++++-------- 3 files changed, 105 insertions(+), 136 deletions(-) diff --git a/modules/gpuwarping/include/opencv2/gpuwarping.hpp b/modules/gpuwarping/include/opencv2/gpuwarping.hpp index 5b140682e3..ed17464ec4 100644 --- a/modules/gpuwarping/include/opencv2/gpuwarping.hpp +++ b/modules/gpuwarping/include/opencv2/gpuwarping.hpp @@ -100,32 +100,14 @@ CV_EXPORTS void pyrDown(InputArray src, OutputArray dst, Stream& stream = Stream //! upsamples the source image and then smoothes it CV_EXPORTS void pyrUp(InputArray src, OutputArray dst, Stream& stream = Stream::Null()); -class CV_EXPORTS ImagePyramid +class CV_EXPORTS ImagePyramid : public Algorithm { public: - inline ImagePyramid() : nLayers_(0) {} - inline ImagePyramid(const GpuMat& img, int nLayers, Stream& stream = Stream::Null()) - { - build(img, nLayers, stream); - } - - void build(const GpuMat& img, int nLayers, Stream& stream = Stream::Null()); - - void getLayer(GpuMat& outImg, Size outRoi, Stream& stream = Stream::Null()) const; - - inline void release() - { - layer0_.release(); - pyramid_.clear(); - nLayers_ = 0; - } - -private: - GpuMat layer0_; - std::vector pyramid_; - int nLayers_; + virtual void getLayer(OutputArray outImg, Size outRoi, Stream& stream = Stream::Null()) const = 0; }; +CV_EXPORTS Ptr createImagePyramid(InputArray img, int nLayers = -1, Stream& stream = Stream::Null()); + }} // namespace cv { namespace gpu { #endif /* __OPENCV_GPUWARPING_HPP__ */ diff --git a/modules/gpuwarping/perf/perf_warping.cpp b/modules/gpuwarping/perf/perf_warping.cpp index fd555cbe56..266475bb0c 100644 --- a/modules/gpuwarping/perf/perf_warping.cpp +++ b/modules/gpuwarping/perf/perf_warping.cpp @@ -515,45 +515,6 @@ PERF_TEST_P(Sz_Depth_Cn, PyrUp, } } -////////////////////////////////////////////////////////////////////// -// ImagePyramidBuild - -PERF_TEST_P(Sz_Depth_Cn, ImagePyramidBuild, - Combine(GPU_TYPICAL_MAT_SIZES, - Values(CV_8U, CV_16U, CV_32F), - GPU_CHANNELS_1_3_4)) -{ - const cv::Size size = GET_PARAM(0); - const int depth = GET_PARAM(1); - const int channels = GET_PARAM(2); - - const int type = CV_MAKE_TYPE(depth, channels); - - cv::Mat src(size, type); - declare.in(src, WARMUP_RNG); - - const int nLayers = 5; - const cv::Size dstSize(size.width / 2 + 10, size.height / 2 + 10); - - if (PERF_RUN_GPU()) - { - const cv::gpu::GpuMat d_src(src); - - cv::gpu::ImagePyramid d_pyr; - - TEST_CYCLE() d_pyr.build(d_src, nLayers); - - cv::gpu::GpuMat dst; - d_pyr.getLayer(dst, dstSize); - - GPU_SANITY_CHECK(dst); - } - else - { - FAIL_NO_CPU(); - } -} - ////////////////////////////////////////////////////////////////////// // ImagePyramidGetLayer @@ -579,9 +540,9 @@ PERF_TEST_P(Sz_Depth_Cn, ImagePyramidGetLayer, const cv::gpu::GpuMat d_src(src); cv::gpu::GpuMat dst; - cv::gpu::ImagePyramid d_pyr(d_src, nLayers); + cv::Ptr d_pyr = cv::gpu::createImagePyramid(d_src, nLayers); - TEST_CYCLE() d_pyr.getLayer(dst, dstSize); + TEST_CYCLE() d_pyr->getLayer(dst, dstSize); GPU_SANITY_CHECK(dst); } diff --git a/modules/gpuwarping/src/pyramids.cpp b/modules/gpuwarping/src/pyramids.cpp index 39812352d8..577ed85677 100644 --- a/modules/gpuwarping/src/pyramids.cpp +++ b/modules/gpuwarping/src/pyramids.cpp @@ -42,13 +42,15 @@ #include "precomp.hpp" +using namespace cv; +using namespace cv::gpu; + #if !defined HAVE_CUDA || defined(CUDA_DISABLER) void cv::gpu::pyrDown(InputArray, OutputArray, Stream&) { throw_no_cuda(); } void cv::gpu::pyrUp(InputArray, OutputArray, Stream&) { throw_no_cuda(); } -void cv::gpu::ImagePyramid::build(const GpuMat&, int, Stream&) { throw_no_cuda(); } -void cv::gpu::ImagePyramid::getLayer(GpuMat&, Size, Stream&) const { throw_no_cuda(); } +Ptr cv::gpu::createImagePyramid(InputArray, int, Stream&) { throw_no_cuda(); return Ptr(); } #else // HAVE_CUDA @@ -134,84 +136,108 @@ void cv::gpu::pyrUp(InputArray _src, OutputArray _dst, Stream& stream) ////////////////////////////////////////////////////////////////////////////// // ImagePyramid -void cv::gpu::ImagePyramid::build(const GpuMat& img, int numLayers, Stream& stream) +#ifdef HAVE_OPENCV_GPULEGACY + +namespace +{ + class ImagePyramidImpl : public ImagePyramid + { + public: + ImagePyramidImpl(InputArray img, int nLayers, Stream& stream); + + void getLayer(OutputArray outImg, Size outRoi, Stream& stream = Stream::Null()) const; + + private: + GpuMat layer0_; + std::vector pyramid_; + int nLayers_; + }; + + ImagePyramidImpl::ImagePyramidImpl(InputArray _img, int numLayers, Stream& stream) + { + GpuMat img = _img.getGpuMat(); + + CV_Assert( img.depth() <= CV_32F && img.channels() <= 4 ); + + img.copyTo(layer0_, stream); + + Size szLastLayer = img.size(); + nLayers_ = 1; + + if (numLayers <= 0) + numLayers = 255; // it will cut-off when any of the dimensions goes 1 + + pyramid_.resize(numLayers); + + for (int i = 0; i < numLayers - 1; ++i) + { + Size szCurLayer(szLastLayer.width / 2, szLastLayer.height / 2); + + if (szCurLayer.width == 0 || szCurLayer.height == 0) + break; + + ensureSizeIsEnough(szCurLayer, img.type(), pyramid_[i]); + nLayers_++; + + const GpuMat& prevLayer = i == 0 ? layer0_ : pyramid_[i - 1]; + + cudev::pyramid::downsampleX2(prevLayer, pyramid_[i], img.depth(), img.channels(), StreamAccessor::getStream(stream)); + + szLastLayer = szCurLayer; + } + } + + void ImagePyramidImpl::getLayer(OutputArray _outImg, Size outRoi, Stream& stream) const + { + CV_Assert( outRoi.width <= layer0_.cols && outRoi.height <= layer0_.rows && outRoi.width > 0 && outRoi.height > 0 ); + + ensureSizeIsEnough(outRoi, layer0_.type(), _outImg); + GpuMat outImg = _outImg.getGpuMat(); + + if (outRoi.width == layer0_.cols && outRoi.height == layer0_.rows) + { + layer0_.copyTo(outImg, stream); + return; + } + + float lastScale = 1.0f; + float curScale; + GpuMat lastLayer = layer0_; + GpuMat curLayer; + + for (int i = 0; i < nLayers_ - 1; ++i) + { + curScale = lastScale * 0.5f; + curLayer = pyramid_[i]; + + if (outRoi.width == curLayer.cols && outRoi.height == curLayer.rows) + { + curLayer.copyTo(outImg, stream); + } + + if (outRoi.width >= curLayer.cols && outRoi.height >= curLayer.rows) + break; + + lastScale = curScale; + lastLayer = curLayer; + } + + cudev::pyramid::interpolateFrom1(lastLayer, outImg, outImg.depth(), outImg.channels(), StreamAccessor::getStream(stream)); + } +} + +#endif + +Ptr cv::gpu::createImagePyramid(InputArray img, int nLayers, Stream& stream) { #ifndef HAVE_OPENCV_GPULEGACY (void) img; (void) numLayers; (void) stream; throw_no_cuda(); + return Ptr(); #else - CV_Assert(img.depth() <= CV_32F && img.channels() <= 4); - - layer0_ = img; - Size szLastLayer = img.size(); - nLayers_ = 1; - - if (numLayers <= 0) - numLayers = 255; //it will cut-off when any of the dimensions goes 1 - - pyramid_.resize(numLayers); - - for (int i = 0; i < numLayers - 1; ++i) - { - Size szCurLayer(szLastLayer.width / 2, szLastLayer.height / 2); - - if (szCurLayer.width == 0 || szCurLayer.height == 0) - break; - - ensureSizeIsEnough(szCurLayer, img.type(), pyramid_[i]); - nLayers_++; - - const GpuMat& prevLayer = i == 0 ? layer0_ : pyramid_[i - 1]; - - cudev::pyramid::downsampleX2(prevLayer, pyramid_[i], img.depth(), img.channels(), StreamAccessor::getStream(stream)); - - szLastLayer = szCurLayer; - } -#endif -} - -void cv::gpu::ImagePyramid::getLayer(GpuMat& outImg, Size outRoi, Stream& stream) const -{ -#ifndef HAVE_OPENCV_GPULEGACY - (void) outImg; - (void) outRoi; - (void) stream; - throw_no_cuda(); -#else - CV_Assert(outRoi.width <= layer0_.cols && outRoi.height <= layer0_.rows && outRoi.width > 0 && outRoi.height > 0); - - ensureSizeIsEnough(outRoi, layer0_.type(), outImg); - - if (outRoi.width == layer0_.cols && outRoi.height == layer0_.rows) - { - layer0_.copyTo(outImg, stream); - } - - float lastScale = 1.0f; - float curScale; - GpuMat lastLayer = layer0_; - GpuMat curLayer; - - for (int i = 0; i < nLayers_ - 1; ++i) - { - curScale = lastScale * 0.5f; - curLayer = pyramid_[i]; - - if (outRoi.width == curLayer.cols && outRoi.height == curLayer.rows) - { - curLayer.copyTo(outImg, stream); - } - - if (outRoi.width >= curLayer.cols && outRoi.height >= curLayer.rows) - break; - - lastScale = curScale; - lastLayer = curLayer; - } - - cudev::pyramid::interpolateFrom1(lastLayer, outImg, outImg.depth(), outImg.channels(), StreamAccessor::getStream(stream)); + return new ImagePyramidImpl(img, nLayers, stream); #endif } From 0d9e3cfa37974ae0050cb3510aab76256889097b Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Fri, 26 Apr 2013 17:23:49 +0400 Subject: [PATCH 3/3] updated documentation --- modules/gpuwarping/doc/warping.rst | 78 +++++++++++++++--------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/modules/gpuwarping/doc/warping.rst b/modules/gpuwarping/doc/warping.rst index b2c95e2b02..5c88eb772b 100644 --- a/modules/gpuwarping/doc/warping.rst +++ b/modules/gpuwarping/doc/warping.rst @@ -9,7 +9,7 @@ gpu::remap -------------- Applies a generic geometrical transformation to an image. -.. ocv:function:: void gpu::remap( const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap, int interpolation, int borderMode=BORDER_CONSTANT, Scalar borderValue=Scalar(), Stream& stream=Stream::Null() ) +.. ocv:function:: void gpu::remap(InputArray src, OutputArray dst, InputArray xmap, InputArray ymap, int interpolation, int borderMode = BORDER_CONSTANT, Scalar borderValue = Scalar(), Stream& stream = Stream::Null()) :param src: Source image. @@ -43,7 +43,7 @@ gpu::resize --------------- Resizes an image. -.. ocv:function:: void gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx=0, double fy=0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null()) +.. ocv:function:: void gpu::resize(InputArray src, OutputArray dst, Size dsize, double fx=0, double fy=0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null()) :param src: Source image. @@ -80,7 +80,7 @@ gpu::warpAffine ------------------- Applies an affine transformation to an image. -.. ocv:function:: void gpu::warpAffine( const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, Scalar borderValue=Scalar(), Stream& stream=Stream::Null() ) +.. ocv:function:: void gpu::warpAffine(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags = INTER_LINEAR, int borderMode = BORDER_CONSTANT, Scalar borderValue = Scalar(), Stream& stream = Stream::Null()) :param src: Source image. ``CV_8U`` , ``CV_16U`` , ``CV_32S`` , or ``CV_32F`` depth and 1, 3, or 4 channels are supported. @@ -102,7 +102,7 @@ gpu::buildWarpAffineMaps ------------------------ Builds transformation maps for affine transformation. -.. ocv:function:: void gpu::buildWarpAffineMaps(const Mat& M, bool inverse, Size dsize, GpuMat& xmap, GpuMat& ymap, Stream& stream = Stream::Null()) +.. ocv:function:: void gpu::buildWarpAffineMaps(InputArray M, bool inverse, Size dsize, OutputArray xmap, OutputArray ymap, Stream& stream = Stream::Null()) :param M: *2x3* transformation matrix. @@ -124,7 +124,7 @@ gpu::warpPerspective ------------------------ Applies a perspective transformation to an image. -.. ocv:function:: void gpu::warpPerspective( const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, Scalar borderValue=Scalar(), Stream& stream=Stream::Null() ) +.. ocv:function:: void gpu::warpPerspective(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags = INTER_LINEAR, int borderMode = BORDER_CONSTANT, Scalar borderValue = Scalar(), Stream& stream = Stream::Null()) :param src: Source image. ``CV_8U`` , ``CV_16U`` , ``CV_32S`` , or ``CV_32F`` depth and 1, 3, or 4 channels are supported. @@ -146,7 +146,7 @@ gpu::buildWarpPerspectiveMaps ----------------------------- Builds transformation maps for perspective transformation. -.. ocv:function:: void gpu::buildWarpAffineMaps(const Mat& M, bool inverse, Size dsize, GpuMat& xmap, GpuMat& ymap, Stream& stream = Stream::Null()) +.. ocv:function:: void gpu::buildWarpAffineMaps(InputArray M, bool inverse, Size dsize, OutputArray xmap, OutputArray ymap, Stream& stream = Stream::Null()) :param M: *3x3* transformation matrix. @@ -164,11 +164,41 @@ Builds transformation maps for perspective transformation. +gpu::buildWarpPlaneMaps +----------------------- +Builds plane warping maps. + +.. ocv:function:: void gpu::buildWarpPlaneMaps(Size src_size, Rect dst_roi, InputArray K, InputArray R, InputArray T, float scale, OutputArray map_x, OutputArray map_y, Stream& stream = Stream::Null()) + + :param stream: Stream for the asynchronous version. + + + +gpu::buildWarpCylindricalMaps +----------------------------- +Builds cylindrical warping maps. + +.. ocv:function:: void gpu::buildWarpCylindricalMaps(Size src_size, Rect dst_roi, InputArray K, InputArray R, float scale, OutputArray map_x, OutputArray map_y, Stream& stream = Stream::Null()) + + :param stream: Stream for the asynchronous version. + + + +gpu::buildWarpSphericalMaps +--------------------------- +Builds spherical warping maps. + +.. ocv:function:: void gpu::buildWarpSphericalMaps(Size src_size, Rect dst_roi, InputArray K, InputArray R, float scale, OutputArray map_x, OutputArray map_y, Stream& stream = Stream::Null()) + + :param stream: Stream for the asynchronous version. + + + gpu::rotate --------------- Rotates an image around the origin (0,0) and then shifts it. -.. ocv:function:: void gpu::rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift = 0, double yShift = 0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null()) +.. ocv:function:: void gpu::rotate(InputArray src, OutputArray dst, Size dsize, double angle, double xShift = 0, double yShift = 0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null()) :param src: Source image. Supports 1, 3 or 4 channels images with ``CV_8U`` , ``CV_16U`` or ``CV_32F`` depth. @@ -190,41 +220,11 @@ Rotates an image around the origin (0,0) and then shifts it. -gpu::buildWarpPlaneMaps ------------------------ -Builds plane warping maps. - -.. ocv:function:: void gpu::buildWarpPlaneMaps( Size src_size, Rect dst_roi, const Mat & K, const Mat& R, const Mat & T, float scale, GpuMat& map_x, GpuMat& map_y, Stream& stream=Stream::Null() ) - - :param stream: Stream for the asynchronous version. - - - -gpu::buildWarpCylindricalMaps ------------------------------ -Builds cylindrical warping maps. - -.. ocv:function:: void gpu::buildWarpCylindricalMaps( Size src_size, Rect dst_roi, const Mat & K, const Mat& R, float scale, GpuMat& map_x, GpuMat& map_y, Stream& stream=Stream::Null() ) - - :param stream: Stream for the asynchronous version. - - - -gpu::buildWarpSphericalMaps ---------------------------- -Builds spherical warping maps. - -.. ocv:function:: void gpu::buildWarpSphericalMaps( Size src_size, Rect dst_roi, const Mat & K, const Mat& R, float scale, GpuMat& map_x, GpuMat& map_y, Stream& stream=Stream::Null() ) - - :param stream: Stream for the asynchronous version. - - - gpu::pyrDown ------------------- Smoothes an image and downsamples it. -.. ocv:function:: void gpu::pyrDown(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null()) +.. ocv:function:: void gpu::pyrDown(InputArray src, OutputArray dst, Stream& stream = Stream::Null()) :param src: Source image. @@ -240,7 +240,7 @@ gpu::pyrUp ------------------- Upsamples an image and then smoothes it. -.. ocv:function:: void gpu::pyrUp(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null()) +.. ocv:function:: void gpu::pyrUp(InputArray src, OutputArray dst, Stream& stream = Stream::Null()) :param src: Source image.