switched to Input/Output Array in cart<->polar operations
This commit is contained in:
parent
0a83817ace
commit
58c4d0eaeb
@ -134,6 +134,34 @@ static inline void scaleAdd(InputArray src1, double alpha, InputArray src2, Outp
|
||||
//! applies fixed threshold to the image
|
||||
CV_EXPORTS double threshold(InputArray src, OutputArray dst, double thresh, double maxval, int type, Stream& stream = Stream::Null());
|
||||
|
||||
//! computes magnitude of complex (x(i).re, x(i).im) vector
|
||||
//! supports only CV_32FC2 type
|
||||
CV_EXPORTS void magnitude(InputArray xy, OutputArray magnitude, Stream& stream = Stream::Null());
|
||||
|
||||
//! computes squared magnitude of complex (x(i).re, x(i).im) vector
|
||||
//! supports only CV_32FC2 type
|
||||
CV_EXPORTS void magnitudeSqr(InputArray xy, OutputArray magnitude, Stream& stream = Stream::Null());
|
||||
|
||||
//! computes magnitude of each (x(i), y(i)) vector
|
||||
//! supports only floating-point source
|
||||
CV_EXPORTS void magnitude(InputArray x, InputArray y, OutputArray magnitude, Stream& stream = Stream::Null());
|
||||
|
||||
//! computes squared magnitude of each (x(i), y(i)) vector
|
||||
//! supports only floating-point source
|
||||
CV_EXPORTS void magnitudeSqr(InputArray x, InputArray y, OutputArray magnitude, Stream& stream = Stream::Null());
|
||||
|
||||
//! computes angle of each (x(i), y(i)) vector
|
||||
//! supports only floating-point source
|
||||
CV_EXPORTS void phase(InputArray x, InputArray y, OutputArray angle, bool angleInDegrees = false, Stream& stream = Stream::Null());
|
||||
|
||||
//! converts Cartesian coordinates to polar
|
||||
//! supports only floating-point source
|
||||
CV_EXPORTS void cartToPolar(InputArray x, InputArray y, OutputArray magnitude, OutputArray angle, bool angleInDegrees = false, Stream& stream = Stream::Null());
|
||||
|
||||
//! converts polar coordinates to Cartesian
|
||||
//! supports only floating-point source
|
||||
CV_EXPORTS void polarToCart(InputArray magnitude, InputArray angle, OutputArray x, OutputArray y, bool angleInDegrees = false, Stream& stream = Stream::Null());
|
||||
|
||||
//! implements generalized matrix product algorithm GEMM from BLAS
|
||||
CV_EXPORTS void gemm(const GpuMat& src1, const GpuMat& src2, double alpha,
|
||||
const GpuMat& src3, double beta, GpuMat& dst, int flags = 0, Stream& stream = Stream::Null());
|
||||
@ -163,34 +191,6 @@ CV_EXPORTS void split(const GpuMat& src, GpuMat* dst, Stream& stream = Stream::N
|
||||
//! copies each plane of a multi-channel array to a dedicated array
|
||||
CV_EXPORTS void split(const GpuMat& src, std::vector<GpuMat>& dst, Stream& stream = Stream::Null());
|
||||
|
||||
//! computes magnitude of complex (x(i).re, x(i).im) vector
|
||||
//! supports only CV_32FC2 type
|
||||
CV_EXPORTS void magnitude(const GpuMat& xy, GpuMat& magnitude, Stream& stream = Stream::Null());
|
||||
|
||||
//! computes squared magnitude of complex (x(i).re, x(i).im) vector
|
||||
//! supports only CV_32FC2 type
|
||||
CV_EXPORTS void magnitudeSqr(const GpuMat& xy, GpuMat& magnitude, Stream& stream = Stream::Null());
|
||||
|
||||
//! computes magnitude of each (x(i), y(i)) vector
|
||||
//! supports only floating-point source
|
||||
CV_EXPORTS void magnitude(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, Stream& stream = Stream::Null());
|
||||
|
||||
//! computes squared magnitude of each (x(i), y(i)) vector
|
||||
//! supports only floating-point source
|
||||
CV_EXPORTS void magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, Stream& stream = Stream::Null());
|
||||
|
||||
//! computes angle (angle(i)) of each (x(i), y(i)) vector
|
||||
//! supports only floating-point source
|
||||
CV_EXPORTS void phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees = false, Stream& stream = Stream::Null());
|
||||
|
||||
//! converts Cartesian coordinates to polar
|
||||
//! supports only floating-point source
|
||||
CV_EXPORTS void cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, GpuMat& angle, bool angleInDegrees = false, Stream& stream = Stream::Null());
|
||||
|
||||
//! converts polar coordinates to Cartesian
|
||||
//! supports only floating-point source
|
||||
CV_EXPORTS void polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees = false, Stream& stream = Stream::Null());
|
||||
|
||||
//! scales and shifts array elements so that either the specified norm (alpha) or the minimum (alpha) and maximum (beta) array values get the specified values
|
||||
CV_EXPORTS void normalize(const GpuMat& src, GpuMat& dst, double alpha = 1, double beta = 0,
|
||||
int norm_type = NORM_L2, int dtype = -1, const GpuMat& mask = GpuMat());
|
||||
|
@ -77,17 +77,13 @@ void cv::gpu::addWeighted(InputArray, double, InputArray, double, double, Output
|
||||
|
||||
double cv::gpu::threshold(InputArray, OutputArray, double, double, int, Stream&) {throw_no_cuda(); return 0.0;}
|
||||
|
||||
void cv::gpu::magnitude(const GpuMat&, GpuMat&, Stream&) { throw_no_cuda(); }
|
||||
void cv::gpu::magnitude(const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_no_cuda(); }
|
||||
|
||||
void cv::gpu::magnitudeSqr(const GpuMat&, GpuMat&, Stream&) { throw_no_cuda(); }
|
||||
void cv::gpu::magnitudeSqr(const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_no_cuda(); }
|
||||
|
||||
void cv::gpu::phase(const GpuMat&, const GpuMat&, GpuMat&, bool, Stream&) { throw_no_cuda(); }
|
||||
|
||||
void cv::gpu::cartToPolar(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, bool, Stream&) { throw_no_cuda(); }
|
||||
|
||||
void cv::gpu::polarToCart(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, bool, Stream&) { throw_no_cuda(); }
|
||||
void cv::gpu::magnitude(InputArray, OutputArray, Stream&) { throw_no_cuda(); }
|
||||
void cv::gpu::magnitude(InputArray, InputArray, OutputArray, Stream&) { throw_no_cuda(); }
|
||||
void cv::gpu::magnitudeSqr(InputArray, OutputArray, Stream&) { throw_no_cuda(); }
|
||||
void cv::gpu::magnitudeSqr(InputArray, InputArray, OutputArray, Stream&) { throw_no_cuda(); }
|
||||
void cv::gpu::phase(InputArray, InputArray, OutputArray, bool, Stream&) { throw_no_cuda(); }
|
||||
void cv::gpu::cartToPolar(InputArray, InputArray, OutputArray, OutputArray, bool, Stream&) { throw_no_cuda(); }
|
||||
void cv::gpu::polarToCart(InputArray, InputArray, OutputArray, OutputArray, bool, Stream&) { throw_no_cuda(); }
|
||||
|
||||
#else
|
||||
|
||||
@ -3005,12 +3001,10 @@ namespace
|
||||
{
|
||||
typedef NppStatus (*nppMagnitude_t)(const Npp32fc* pSrc, int nSrcStep, Npp32f* pDst, int nDstStep, NppiSize oSizeROI);
|
||||
|
||||
inline void npp_magnitude(const GpuMat& src, GpuMat& dst, nppMagnitude_t func, cudaStream_t stream)
|
||||
void npp_magnitude(const GpuMat& src, GpuMat& dst, nppMagnitude_t func, cudaStream_t stream)
|
||||
{
|
||||
CV_Assert(src.type() == CV_32FC2);
|
||||
|
||||
dst.create(src.size(), CV_32FC1);
|
||||
|
||||
NppiSize sz;
|
||||
sz.width = src.cols;
|
||||
sz.height = src.rows;
|
||||
@ -3024,13 +3018,23 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void cv::gpu::magnitude(const GpuMat& src, GpuMat& dst, Stream& stream)
|
||||
void cv::gpu::magnitude(InputArray _src, OutputArray _dst, Stream& stream)
|
||||
{
|
||||
GpuMat src = _src.getGpuMat();
|
||||
|
||||
_dst.create(src.size(), CV_32FC1);
|
||||
GpuMat dst = _dst.getGpuMat();
|
||||
|
||||
npp_magnitude(src, dst, nppiMagnitude_32fc32f_C1R, StreamAccessor::getStream(stream));
|
||||
}
|
||||
|
||||
void cv::gpu::magnitudeSqr(const GpuMat& src, GpuMat& dst, Stream& stream)
|
||||
void cv::gpu::magnitudeSqr(InputArray _src, OutputArray _dst, Stream& stream)
|
||||
{
|
||||
GpuMat src = _src.getGpuMat();
|
||||
|
||||
_dst.create(src.size(), CV_32FC1);
|
||||
GpuMat dst = _dst.getGpuMat();
|
||||
|
||||
npp_magnitude(src, dst, nppiMagnitudeSqr_32fc32f_C1R, StreamAccessor::getStream(stream));
|
||||
}
|
||||
|
||||
@ -3048,18 +3052,13 @@ namespace cv { namespace gpu { namespace cudev
|
||||
|
||||
namespace
|
||||
{
|
||||
inline void cartToPolar_caller(const GpuMat& x, const GpuMat& y, GpuMat* mag, bool magSqr, GpuMat* angle, bool angleInDegrees, cudaStream_t stream)
|
||||
void cartToPolar_caller(const GpuMat& x, const GpuMat& y, GpuMat* mag, bool magSqr, GpuMat* angle, bool angleInDegrees, cudaStream_t stream)
|
||||
{
|
||||
using namespace ::cv::gpu::cudev::mathfunc;
|
||||
|
||||
CV_Assert(x.size() == y.size() && x.type() == y.type());
|
||||
CV_Assert(x.depth() == CV_32F);
|
||||
|
||||
if (mag)
|
||||
mag->create(x.size(), x.type());
|
||||
if (angle)
|
||||
angle->create(x.size(), x.type());
|
||||
|
||||
GpuMat x1cn = x.reshape(1);
|
||||
GpuMat y1cn = y.reshape(1);
|
||||
GpuMat mag1cn = mag ? mag->reshape(1) : GpuMat();
|
||||
@ -3068,16 +3067,13 @@ namespace
|
||||
cartToPolar_gpu(x1cn, y1cn, mag1cn, magSqr, angle1cn, angleInDegrees, stream);
|
||||
}
|
||||
|
||||
inline void polarToCart_caller(const GpuMat& mag, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees, cudaStream_t stream)
|
||||
void polarToCart_caller(const GpuMat& mag, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees, cudaStream_t stream)
|
||||
{
|
||||
using namespace ::cv::gpu::cudev::mathfunc;
|
||||
|
||||
CV_Assert((mag.empty() || mag.size() == angle.size()) && mag.type() == angle.type());
|
||||
CV_Assert(mag.depth() == CV_32F);
|
||||
|
||||
x.create(mag.size(), mag.type());
|
||||
y.create(mag.size(), mag.type());
|
||||
|
||||
GpuMat mag1cn = mag.reshape(1);
|
||||
GpuMat angle1cn = angle.reshape(1);
|
||||
GpuMat x1cn = x.reshape(1);
|
||||
@ -3087,29 +3083,65 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void cv::gpu::magnitude(const GpuMat& x, const GpuMat& y, GpuMat& dst, Stream& stream)
|
||||
void cv::gpu::magnitude(InputArray _x, InputArray _y, OutputArray _dst, Stream& stream)
|
||||
{
|
||||
GpuMat x = _x.getGpuMat();
|
||||
GpuMat y = _y.getGpuMat();
|
||||
|
||||
_dst.create(x.size(), CV_32FC1);
|
||||
GpuMat dst = _dst.getGpuMat();
|
||||
|
||||
cartToPolar_caller(x, y, &dst, false, 0, false, StreamAccessor::getStream(stream));
|
||||
}
|
||||
|
||||
void cv::gpu::magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& dst, Stream& stream)
|
||||
void cv::gpu::magnitudeSqr(InputArray _x, InputArray _y, OutputArray _dst, Stream& stream)
|
||||
{
|
||||
GpuMat x = _x.getGpuMat();
|
||||
GpuMat y = _y.getGpuMat();
|
||||
|
||||
_dst.create(x.size(), CV_32FC1);
|
||||
GpuMat dst = _dst.getGpuMat();
|
||||
|
||||
cartToPolar_caller(x, y, &dst, true, 0, false, StreamAccessor::getStream(stream));
|
||||
}
|
||||
|
||||
void cv::gpu::phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees, Stream& stream)
|
||||
void cv::gpu::phase(InputArray _x, InputArray _y, OutputArray _dst, bool angleInDegrees, Stream& stream)
|
||||
{
|
||||
cartToPolar_caller(x, y, 0, false, &angle, angleInDegrees, StreamAccessor::getStream(stream));
|
||||
GpuMat x = _x.getGpuMat();
|
||||
GpuMat y = _y.getGpuMat();
|
||||
|
||||
_dst.create(x.size(), CV_32FC1);
|
||||
GpuMat dst = _dst.getGpuMat();
|
||||
|
||||
cartToPolar_caller(x, y, 0, false, &dst, angleInDegrees, StreamAccessor::getStream(stream));
|
||||
}
|
||||
|
||||
void cv::gpu::cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& mag, GpuMat& angle, bool angleInDegrees, Stream& stream)
|
||||
void cv::gpu::cartToPolar(InputArray _x, InputArray _y, OutputArray _mag, OutputArray _angle, bool angleInDegrees, Stream& stream)
|
||||
{
|
||||
GpuMat x = _x.getGpuMat();
|
||||
GpuMat y = _y.getGpuMat();
|
||||
|
||||
_mag.create(x.size(), CV_32FC1);
|
||||
GpuMat mag = _mag.getGpuMat();
|
||||
|
||||
_angle.create(x.size(), CV_32FC1);
|
||||
GpuMat angle = _angle.getGpuMat();
|
||||
|
||||
cartToPolar_caller(x, y, &mag, false, &angle, angleInDegrees, StreamAccessor::getStream(stream));
|
||||
}
|
||||
|
||||
void cv::gpu::polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees, Stream& stream)
|
||||
void cv::gpu::polarToCart(InputArray _mag, InputArray _angle, OutputArray _x, OutputArray _y, bool angleInDegrees, Stream& stream)
|
||||
{
|
||||
polarToCart_caller(magnitude, angle, x, y, angleInDegrees, StreamAccessor::getStream(stream));
|
||||
GpuMat mag = _mag.getGpuMat();
|
||||
GpuMat angle = _angle.getGpuMat();
|
||||
|
||||
_x.create(mag.size(), CV_32FC1);
|
||||
GpuMat x = _x.getGpuMat();
|
||||
|
||||
_y.create(mag.size(), CV_32FC1);
|
||||
GpuMat y = _y.getGpuMat();
|
||||
|
||||
polarToCart_caller(mag, angle, x, y, angleInDegrees, StreamAccessor::getStream(stream));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user