//! 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
{
#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
}
}}}
-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);
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();
+
+ CV_Assert( M.rows == 3 && M.cols == 3 );
- xmap.create(dsize, CV_32FC1);
- ymap.create(dsize, CV_32FC1);
+ _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);
};
}
-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();
+
+ CV_Assert( M.rows == 2 && M.cols == 3 );
- int interpolation = flags & INTER_MAX;
+ const int interpolation = flags & INTER_MAX;
- 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);
+ 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());
+ _dst.create(dsize, src.type());
+ GpuMat dst = _dst.getGpuMat();
Size wholeSize;
Point ofs;
}
};
- dst.setTo(borderValue);
+ dst.setTo(borderValue, stream);
double coeffs[2][3];
Mat coeffsMat(2, 3, CV_64F, (void*)coeffs);
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
{
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;
}
};
- dst.setTo(borderValue);
+ dst.setTo(borderValue, stream);
double coeffs[3][3];
Mat coeffsMat(3, 3, CV_64F, (void*)coeffs);
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
{
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::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;
+
+ Mat K = _K.getMat();
+ Mat R = _R.getMat();
+ Mat T = _T.getMat();
- 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());
+ 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<float>(), R_Kinv.ptr<float>(),
T.ptr<float>(), scale, StreamAccessor::getStream(stream));
}
}
}}}
-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<float>(), R_Kinv.ptr<float>(), scale, StreamAccessor::getStream(stream));
}
}
}}}
-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<float>(), R_Kinv.ptr<float>(), scale, StreamAccessor::getStream(stream));
}
};
}
-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<CV_8U, nppiRotate_8u_C1R>::call, 0, NppRotate<CV_8U, nppiRotate_8u_C3R>::call, NppRotate<CV_8U, nppiRotate_8u_C4R>::call},
{NppRotate<CV_32F, nppiRotate_32f_C1R>::call, 0, NppRotate<CV_32F, nppiRotate_32f_C3R>::call, NppRotate<CV_32F, nppiRotate_32f_C4R>::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();
+
+ 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.create(dsize, src.type());
- dst.setTo(Scalar::all(0));
+ dst.setTo(Scalar::all(0), stream);
funcs[src.depth()][src.channels() - 1](src, dst, dsize, angle, xShift, yShift, interpolation, StreamAccessor::getStream(stream));
}