2010-09-09 23:34:16 +08:00
|
|
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
|
|
//
|
|
|
|
// By downloading, copying, installing or using the software you agree to this license.
|
|
|
|
// If you do not agree to this license, do not download, install,
|
|
|
|
// copy or use the software.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// License Agreement
|
|
|
|
// For Open Source Computer Vision Library
|
|
|
|
//
|
|
|
|
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
|
|
|
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
|
|
|
// Third party copyrights are property of their respective owners.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
// are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistribution's of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
//
|
|
|
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other GpuMaterials provided with the distribution.
|
|
|
|
//
|
|
|
|
// * The name of the copyright holders may not be used to endorse or promote products
|
|
|
|
// derived from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// This software is provided by the copyright holders and contributors "as is" and
|
|
|
|
// any express or bpied warranties, including, but not limited to, the bpied
|
|
|
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
|
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
|
|
// indirect, incidental, special, exemplary, or consequential damages
|
|
|
|
// (including, but not limited to, procurement of substitute goods or services;
|
|
|
|
// loss of use, data, or profits; or business interruption) however caused
|
|
|
|
// and on any theory of liability, whether in contract, strict liability,
|
|
|
|
// or tort (including negligence or otherwise) arising in any way out of
|
|
|
|
// the use of this software, even if advised of the possibility of such damage.
|
|
|
|
//
|
|
|
|
//M*/
|
|
|
|
|
|
|
|
#include "precomp.hpp"
|
|
|
|
|
|
|
|
using namespace cv;
|
|
|
|
using namespace cv::gpu;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#if !defined (HAVE_CUDA)
|
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
void cv::gpu::transpose(const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }
|
|
|
|
void cv::gpu::flip(const GpuMat&, GpuMat&, int, Stream&) { throw_nogpu(); }
|
|
|
|
void cv::gpu::LUT(const GpuMat&, const Mat&, GpuMat&, Stream&) { throw_nogpu(); }
|
|
|
|
void cv::gpu::exp(const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }
|
|
|
|
void cv::gpu::log(const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }
|
|
|
|
void cv::gpu::magnitude(const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }
|
|
|
|
void cv::gpu::magnitudeSqr(const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }
|
|
|
|
void cv::gpu::magnitude(const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }
|
|
|
|
void cv::gpu::magnitudeSqr(const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }
|
|
|
|
void cv::gpu::phase(const GpuMat&, const GpuMat&, GpuMat&, bool, Stream&) { throw_nogpu(); }
|
|
|
|
void cv::gpu::cartToPolar(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, bool, Stream&) { throw_nogpu(); }
|
|
|
|
void cv::gpu::polarToCart(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, bool, Stream&) { throw_nogpu(); }
|
2010-09-15 16:26:18 +08:00
|
|
|
|
2010-09-09 23:34:16 +08:00
|
|
|
#else /* !defined (HAVE_CUDA) */
|
|
|
|
|
2010-09-22 18:58:01 +08:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// transpose
|
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
void cv::gpu::transpose(const GpuMat& src, GpuMat& dst, Stream& s)
|
2010-09-13 22:30:09 +08:00
|
|
|
{
|
2010-12-21 22:02:09 +08:00
|
|
|
CV_Assert(src.elemSize() == 1 || src.elemSize() == 4 || src.elemSize() == 8);
|
2010-09-13 22:30:09 +08:00
|
|
|
|
|
|
|
dst.create( src.cols, src.rows, src.type() );
|
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
cudaStream_t stream = StreamAccessor::getStream(s);
|
|
|
|
|
2010-12-21 22:02:09 +08:00
|
|
|
if (src.elemSize() == 1)
|
2010-12-01 15:00:50 +08:00
|
|
|
{
|
2011-05-31 16:31:10 +08:00
|
|
|
NppStreamHandler h(stream);
|
|
|
|
|
2010-12-01 15:00:50 +08:00
|
|
|
NppiSize sz;
|
|
|
|
sz.width = src.cols;
|
|
|
|
sz.height = src.rows;
|
2010-09-13 22:30:09 +08:00
|
|
|
|
2011-08-08 19:28:14 +08:00
|
|
|
nppSafeCall( nppiTranspose_8u_C1R(src.ptr<Npp8u>(), static_cast<int>(src.step),
|
|
|
|
dst.ptr<Npp8u>(), static_cast<int>(dst.step), sz) );
|
2010-12-01 15:00:50 +08:00
|
|
|
}
|
2010-12-21 22:02:09 +08:00
|
|
|
else if (src.elemSize() == 4)
|
2010-12-01 15:00:50 +08:00
|
|
|
{
|
2011-05-31 16:31:10 +08:00
|
|
|
NppStStreamHandler h(stream);
|
|
|
|
|
2011-02-04 23:15:25 +08:00
|
|
|
NcvSize32u sz;
|
2010-12-21 22:02:09 +08:00
|
|
|
sz.width = src.cols;
|
|
|
|
sz.height = src.rows;
|
|
|
|
|
2011-10-19 17:53:22 +08:00
|
|
|
ncvSafeCall( nppiStTranspose_32u_C1R(const_cast<Ncv32u*>(src.ptr<Ncv32u>()), static_cast<int>(src.step),
|
2011-08-08 19:28:14 +08:00
|
|
|
dst.ptr<Ncv32u>(), static_cast<int>(dst.step), sz) );
|
2010-12-21 22:02:09 +08:00
|
|
|
}
|
|
|
|
else // if (src.elemSize() == 8)
|
|
|
|
{
|
2011-05-31 16:31:10 +08:00
|
|
|
NppStStreamHandler h(stream);
|
|
|
|
|
2011-02-04 23:15:25 +08:00
|
|
|
NcvSize32u sz;
|
2010-12-21 22:02:09 +08:00
|
|
|
sz.width = src.cols;
|
|
|
|
sz.height = src.rows;
|
|
|
|
|
2011-10-19 17:53:22 +08:00
|
|
|
ncvSafeCall( nppiStTranspose_64u_C1R(const_cast<Ncv64u*>(src.ptr<Ncv64u>()), static_cast<int>(src.step),
|
2011-08-08 19:28:14 +08:00
|
|
|
dst.ptr<Ncv64u>(), static_cast<int>(dst.step), sz) );
|
2010-12-01 15:00:50 +08:00
|
|
|
}
|
2011-01-24 18:32:57 +08:00
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
if (stream == 0)
|
|
|
|
cudaSafeCall( cudaDeviceSynchronize() );
|
2010-09-13 22:30:09 +08:00
|
|
|
}
|
|
|
|
|
2010-09-22 18:58:01 +08:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// flip
|
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
void cv::gpu::flip(const GpuMat& src, GpuMat& dst, int flipCode, Stream& s)
|
2010-09-15 16:26:18 +08:00
|
|
|
{
|
|
|
|
CV_Assert(src.type() == CV_8UC1 || src.type() == CV_8UC4);
|
|
|
|
|
|
|
|
dst.create( src.size(), src.type() );
|
|
|
|
|
|
|
|
NppiSize sz;
|
|
|
|
sz.width = src.cols;
|
|
|
|
sz.height = src.rows;
|
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
cudaStream_t stream = StreamAccessor::getStream(s);
|
|
|
|
|
|
|
|
NppStreamHandler h(stream);
|
|
|
|
|
2010-09-20 18:34:46 +08:00
|
|
|
if (src.type() == CV_8UC1)
|
2010-09-15 16:26:18 +08:00
|
|
|
{
|
2011-08-08 19:28:14 +08:00
|
|
|
nppSafeCall( nppiMirror_8u_C1R(src.ptr<Npp8u>(), static_cast<int>(src.step),
|
|
|
|
dst.ptr<Npp8u>(), static_cast<int>(dst.step), sz,
|
2010-09-15 22:34:41 +08:00
|
|
|
(flipCode == 0 ? NPP_HORIZONTAL_AXIS : (flipCode > 0 ? NPP_VERTICAL_AXIS : NPP_BOTH_AXIS))) );
|
2010-09-15 16:26:18 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-08-08 19:28:14 +08:00
|
|
|
nppSafeCall( nppiMirror_8u_C4R(src.ptr<Npp8u>(), static_cast<int>(src.step),
|
|
|
|
dst.ptr<Npp8u>(), static_cast<int>(dst.step), sz,
|
2010-09-15 22:34:41 +08:00
|
|
|
(flipCode == 0 ? NPP_HORIZONTAL_AXIS : (flipCode > 0 ? NPP_VERTICAL_AXIS : NPP_BOTH_AXIS))) );
|
2010-09-15 16:26:18 +08:00
|
|
|
}
|
2011-01-24 18:32:57 +08:00
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
if (stream == 0)
|
|
|
|
cudaSafeCall( cudaDeviceSynchronize() );
|
2010-09-15 16:26:18 +08:00
|
|
|
}
|
|
|
|
|
2010-09-22 18:58:01 +08:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// LUT
|
2010-09-15 16:26:18 +08:00
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
void cv::gpu::LUT(const GpuMat& src, const Mat& lut, GpuMat& dst, Stream& s)
|
2010-09-22 18:58:01 +08:00
|
|
|
{
|
|
|
|
class LevelsInit
|
2010-09-15 20:47:59 +08:00
|
|
|
{
|
2010-09-22 18:58:01 +08:00
|
|
|
public:
|
|
|
|
Npp32s pLevels[256];
|
2010-09-27 17:37:43 +08:00
|
|
|
const Npp32s* pLevels3[3];
|
|
|
|
int nValues3[3];
|
2010-09-15 20:47:59 +08:00
|
|
|
|
2010-09-22 18:58:01 +08:00
|
|
|
LevelsInit()
|
2010-09-27 17:37:43 +08:00
|
|
|
{
|
|
|
|
nValues3[0] = nValues3[1] = nValues3[2] = 256;
|
2010-09-22 18:58:01 +08:00
|
|
|
for (int i = 0; i < 256; ++i)
|
|
|
|
pLevels[i] = i;
|
2010-09-27 17:37:43 +08:00
|
|
|
pLevels3[0] = pLevels3[1] = pLevels3[2] = pLevels;
|
2010-09-15 20:47:59 +08:00
|
|
|
}
|
2010-09-22 18:58:01 +08:00
|
|
|
};
|
|
|
|
static LevelsInit lvls;
|
2010-09-15 20:47:59 +08:00
|
|
|
|
2010-09-22 18:58:01 +08:00
|
|
|
int cn = src.channels();
|
2010-09-15 20:47:59 +08:00
|
|
|
|
2010-09-27 17:37:43 +08:00
|
|
|
CV_Assert(src.type() == CV_8UC1 || src.type() == CV_8UC3);
|
|
|
|
CV_Assert(lut.depth() == CV_8U && (lut.channels() == 1 || lut.channels() == cn) && lut.rows * lut.cols == 256 && lut.isContinuous());
|
2010-09-15 20:47:59 +08:00
|
|
|
|
2010-09-27 17:37:43 +08:00
|
|
|
dst.create(src.size(), CV_MAKETYPE(lut.depth(), cn));
|
2010-09-15 20:47:59 +08:00
|
|
|
|
2010-09-22 18:58:01 +08:00
|
|
|
NppiSize sz;
|
|
|
|
sz.height = src.rows;
|
|
|
|
sz.width = src.cols;
|
2010-11-08 17:55:10 +08:00
|
|
|
|
2010-09-27 17:37:43 +08:00
|
|
|
Mat nppLut;
|
|
|
|
lut.convertTo(nppLut, CV_32S);
|
2010-09-15 20:47:59 +08:00
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
cudaStream_t stream = StreamAccessor::getStream(s);
|
|
|
|
|
|
|
|
NppStreamHandler h(stream);
|
|
|
|
|
2010-09-27 17:37:43 +08:00
|
|
|
if (src.type() == CV_8UC1)
|
|
|
|
{
|
2011-08-08 19:28:14 +08:00
|
|
|
nppSafeCall( nppiLUT_Linear_8u_C1R(src.ptr<Npp8u>(), static_cast<int>(src.step),
|
|
|
|
dst.ptr<Npp8u>(), static_cast<int>(dst.step), sz, nppLut.ptr<Npp32s>(), lvls.pLevels, 256) );
|
2010-09-27 17:37:43 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Mat nppLut3[3];
|
|
|
|
const Npp32s* pValues3[3];
|
|
|
|
if (nppLut.channels() == 1)
|
|
|
|
pValues3[0] = pValues3[1] = pValues3[2] = nppLut.ptr<Npp32s>();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cv::split(nppLut, nppLut3);
|
|
|
|
pValues3[0] = nppLut3[0].ptr<Npp32s>();
|
2010-11-08 17:55:10 +08:00
|
|
|
pValues3[1] = nppLut3[1].ptr<Npp32s>();
|
2010-09-27 17:37:43 +08:00
|
|
|
pValues3[2] = nppLut3[2].ptr<Npp32s>();
|
|
|
|
}
|
2011-08-08 19:28:14 +08:00
|
|
|
nppSafeCall( nppiLUT_Linear_8u_C3R(src.ptr<Npp8u>(), static_cast<int>(src.step),
|
|
|
|
dst.ptr<Npp8u>(), static_cast<int>(dst.step), sz, pValues3, lvls.pLevels3, lvls.nValues3) );
|
2010-09-27 17:37:43 +08:00
|
|
|
}
|
2011-01-24 18:32:57 +08:00
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
if (stream == 0)
|
|
|
|
cudaSafeCall( cudaDeviceSynchronize() );
|
2010-09-15 20:47:59 +08:00
|
|
|
}
|
|
|
|
|
2010-09-27 20:44:57 +08:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// exp
|
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
void cv::gpu::exp(const GpuMat& src, GpuMat& dst, Stream& s)
|
2010-09-27 20:44:57 +08:00
|
|
|
{
|
|
|
|
CV_Assert(src.type() == CV_32FC1);
|
|
|
|
|
|
|
|
dst.create(src.size(), src.type());
|
|
|
|
|
|
|
|
NppiSize sz;
|
|
|
|
sz.width = src.cols;
|
|
|
|
sz.height = src.rows;
|
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
cudaStream_t stream = StreamAccessor::getStream(s);
|
|
|
|
|
|
|
|
NppStreamHandler h(stream);
|
|
|
|
|
2011-08-08 19:28:14 +08:00
|
|
|
nppSafeCall( nppiExp_32f_C1R(src.ptr<Npp32f>(), static_cast<int>(src.step), dst.ptr<Npp32f>(), static_cast<int>(dst.step), sz) );
|
2011-01-24 18:32:57 +08:00
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
if (stream == 0)
|
|
|
|
cudaSafeCall( cudaDeviceSynchronize() );
|
2010-09-27 20:44:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// log
|
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
void cv::gpu::log(const GpuMat& src, GpuMat& dst, Stream& s)
|
2010-09-27 20:44:57 +08:00
|
|
|
{
|
|
|
|
CV_Assert(src.type() == CV_32FC1);
|
|
|
|
|
|
|
|
dst.create(src.size(), src.type());
|
|
|
|
|
|
|
|
NppiSize sz;
|
|
|
|
sz.width = src.cols;
|
|
|
|
sz.height = src.rows;
|
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
cudaStream_t stream = StreamAccessor::getStream(s);
|
|
|
|
|
|
|
|
NppStreamHandler h(stream);
|
|
|
|
|
2011-08-08 19:28:14 +08:00
|
|
|
nppSafeCall( nppiLn_32f_C1R(src.ptr<Npp32f>(), static_cast<int>(src.step), dst.ptr<Npp32f>(), static_cast<int>(dst.step), sz) );
|
2011-01-24 18:32:57 +08:00
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
if (stream == 0)
|
|
|
|
cudaSafeCall( cudaDeviceSynchronize() );
|
2010-09-27 20:44:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
2010-10-18 19:12:14 +08:00
|
|
|
// NPP magnitide
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
typedef NppStatus (*nppMagnitude_t)(const Npp32fc* pSrc, int nSrcStep, Npp32f* pDst, int nDstStep, NppiSize oSizeROI);
|
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
inline void npp_magnitude(const GpuMat& src, GpuMat& dst, nppMagnitude_t func, cudaStream_t stream)
|
2010-10-18 19:12:14 +08:00
|
|
|
{
|
|
|
|
CV_Assert(src.type() == CV_32FC2);
|
|
|
|
|
|
|
|
dst.create(src.size(), CV_32FC1);
|
|
|
|
|
|
|
|
NppiSize sz;
|
|
|
|
sz.width = src.cols;
|
|
|
|
sz.height = src.rows;
|
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
NppStreamHandler h(stream);
|
|
|
|
|
2011-08-08 19:28:14 +08:00
|
|
|
nppSafeCall( func(src.ptr<Npp32fc>(), static_cast<int>(src.step), dst.ptr<Npp32f>(), static_cast<int>(dst.step), sz) );
|
2011-01-24 18:32:57 +08:00
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
if (stream == 0)
|
|
|
|
cudaSafeCall( cudaDeviceSynchronize() );
|
2010-10-18 19:12:14 +08:00
|
|
|
}
|
|
|
|
}
|
2010-09-27 20:44:57 +08:00
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
void cv::gpu::magnitude(const GpuMat& src, GpuMat& dst, Stream& stream)
|
2010-09-27 22:10:19 +08:00
|
|
|
{
|
2011-05-31 16:31:10 +08:00
|
|
|
::npp_magnitude(src, dst, nppiMagnitude_32fc32f_C1R, StreamAccessor::getStream(stream));
|
2010-10-18 19:12:14 +08:00
|
|
|
}
|
2010-09-27 22:10:19 +08:00
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
void cv::gpu::magnitudeSqr(const GpuMat& src, GpuMat& dst, Stream& stream)
|
2010-10-18 19:12:14 +08:00
|
|
|
{
|
2011-05-31 16:31:10 +08:00
|
|
|
::npp_magnitude(src, dst, nppiMagnitudeSqr_32fc32f_C1R, StreamAccessor::getStream(stream));
|
2010-10-18 19:12:14 +08:00
|
|
|
}
|
2010-09-27 22:10:19 +08:00
|
|
|
|
2010-10-18 19:12:14 +08:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// Polar <-> Cart
|
2010-09-27 22:10:19 +08:00
|
|
|
|
2010-11-08 17:55:10 +08:00
|
|
|
namespace cv { namespace gpu { namespace mathfunc
|
2010-10-18 19:12:14 +08:00
|
|
|
{
|
|
|
|
void cartToPolar_gpu(const DevMem2Df& x, const DevMem2Df& y, const DevMem2Df& mag, bool magSqr, const DevMem2Df& angle, bool angleInDegrees, cudaStream_t stream);
|
|
|
|
void polarToCart_gpu(const DevMem2Df& mag, const DevMem2Df& angle, const DevMem2Df& x, const DevMem2Df& y, bool angleInDegrees, cudaStream_t stream);
|
|
|
|
}}}
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
2010-10-26 13:44:50 +08:00
|
|
|
inline void cartToPolar_caller(const GpuMat& x, const GpuMat& y, GpuMat* mag, bool magSqr, GpuMat* angle, bool angleInDegrees, cudaStream_t stream)
|
2010-10-18 19:12:14 +08:00
|
|
|
{
|
|
|
|
CV_DbgAssert(x.size() == y.size() && x.type() == y.type());
|
|
|
|
CV_Assert(x.depth() == CV_32F);
|
|
|
|
|
2010-10-26 13:44:50 +08:00
|
|
|
if (mag)
|
|
|
|
mag->create(x.size(), x.type());
|
|
|
|
if (angle)
|
|
|
|
angle->create(x.size(), x.type());
|
2010-10-18 19:12:14 +08:00
|
|
|
|
|
|
|
GpuMat x1cn = x.reshape(1);
|
|
|
|
GpuMat y1cn = y.reshape(1);
|
2010-10-26 13:44:50 +08:00
|
|
|
GpuMat mag1cn = mag ? mag->reshape(1) : GpuMat();
|
|
|
|
GpuMat angle1cn = angle ? angle->reshape(1) : GpuMat();
|
2010-10-18 19:12:14 +08:00
|
|
|
|
|
|
|
mathfunc::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)
|
|
|
|
{
|
|
|
|
CV_DbgAssert((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);
|
|
|
|
GpuMat y1cn = y.reshape(1);
|
|
|
|
|
|
|
|
mathfunc::polarToCart_gpu(mag1cn, angle1cn, x1cn, y1cn, angleInDegrees, stream);
|
|
|
|
}
|
2010-09-27 22:10:19 +08:00
|
|
|
}
|
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
void cv::gpu::magnitude(const GpuMat& x, const GpuMat& y, GpuMat& dst, Stream& stream)
|
2010-10-18 19:12:14 +08:00
|
|
|
{
|
2010-10-26 13:44:50 +08:00
|
|
|
::cartToPolar_caller(x, y, &dst, false, 0, false, StreamAccessor::getStream(stream));
|
2010-10-18 19:12:14 +08:00
|
|
|
}
|
2010-09-27 20:44:57 +08:00
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
void cv::gpu::magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& dst, Stream& stream)
|
2010-10-13 20:52:39 +08:00
|
|
|
{
|
2010-10-26 13:44:50 +08:00
|
|
|
::cartToPolar_caller(x, y, &dst, true, 0, false, StreamAccessor::getStream(stream));
|
2010-10-18 19:12:14 +08:00
|
|
|
}
|
2010-10-13 20:52:39 +08:00
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
void cv::gpu::phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees, Stream& stream)
|
2010-11-08 17:55:10 +08:00
|
|
|
{
|
2010-10-26 13:44:50 +08:00
|
|
|
::cartToPolar_caller(x, y, 0, false, &angle, angleInDegrees, StreamAccessor::getStream(stream));
|
2010-10-18 19:12:14 +08:00
|
|
|
}
|
2010-10-13 20:52:39 +08:00
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
void cv::gpu::cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& mag, GpuMat& angle, bool angleInDegrees, Stream& stream)
|
2010-10-13 20:52:39 +08:00
|
|
|
{
|
2010-10-26 13:44:50 +08:00
|
|
|
::cartToPolar_caller(x, y, &mag, false, &angle, angleInDegrees, StreamAccessor::getStream(stream));
|
2010-10-18 19:12:14 +08:00
|
|
|
}
|
2010-10-13 20:52:39 +08:00
|
|
|
|
2011-05-31 16:31:10 +08:00
|
|
|
void cv::gpu::polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees, Stream& stream)
|
2010-10-18 19:12:14 +08:00
|
|
|
{
|
|
|
|
::polarToCart_caller(magnitude, angle, x, y, angleInDegrees, StreamAccessor::getStream(stream));
|
2010-10-13 20:52:39 +08:00
|
|
|
}
|
|
|
|
|
2010-11-19 18:19:35 +08:00
|
|
|
|
2010-10-18 19:12:14 +08:00
|
|
|
#endif /* !defined (HAVE_CUDA) */
|