used new device layer in math per element operations
This commit is contained in:
@@ -451,270 +451,6 @@ void cv::cuda::absdiff(InputArray src1, InputArray src2, OutputArray dst, Stream
|
||||
arithm_op(src1, src2, dst, noArray(), 1.0, -1, stream, absDiffMat, absDiffScalar);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// abs
|
||||
|
||||
namespace arithm
|
||||
{
|
||||
template <typename T>
|
||||
void absMat(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
|
||||
}
|
||||
|
||||
void cv::cuda::abs(InputArray _src, OutputArray _dst, Stream& stream)
|
||||
{
|
||||
using namespace arithm;
|
||||
|
||||
typedef void (*func_t)(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
|
||||
static const func_t funcs[] =
|
||||
{
|
||||
absMat<unsigned char>,
|
||||
absMat<signed char>,
|
||||
absMat<unsigned short>,
|
||||
absMat<short>,
|
||||
absMat<int>,
|
||||
absMat<float>,
|
||||
absMat<double>
|
||||
};
|
||||
|
||||
GpuMat src = _src.getGpuMat();
|
||||
|
||||
const int depth = src.depth();
|
||||
|
||||
CV_Assert( depth <= CV_64F );
|
||||
CV_Assert( src.channels() == 1 );
|
||||
|
||||
if (depth == CV_64F)
|
||||
{
|
||||
if (!deviceSupports(NATIVE_DOUBLE))
|
||||
CV_Error(cv::Error::StsUnsupportedFormat, "The device doesn't support double");
|
||||
}
|
||||
|
||||
_dst.create(src.size(), src.type());
|
||||
GpuMat dst = _dst.getGpuMat();
|
||||
|
||||
funcs[depth](src, dst, StreamAccessor::getStream(stream));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// sqr
|
||||
|
||||
namespace arithm
|
||||
{
|
||||
template <typename T>
|
||||
void sqrMat(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
|
||||
}
|
||||
|
||||
void cv::cuda::sqr(InputArray _src, OutputArray _dst, Stream& stream)
|
||||
{
|
||||
using namespace arithm;
|
||||
|
||||
typedef void (*func_t)(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
|
||||
static const func_t funcs[] =
|
||||
{
|
||||
sqrMat<unsigned char>,
|
||||
sqrMat<signed char>,
|
||||
sqrMat<unsigned short>,
|
||||
sqrMat<short>,
|
||||
sqrMat<int>,
|
||||
sqrMat<float>,
|
||||
sqrMat<double>
|
||||
};
|
||||
|
||||
GpuMat src = _src.getGpuMat();
|
||||
|
||||
const int depth = src.depth();
|
||||
|
||||
CV_Assert( depth <= CV_64F );
|
||||
CV_Assert( src.channels() == 1 );
|
||||
|
||||
if (depth == CV_64F)
|
||||
{
|
||||
if (!deviceSupports(NATIVE_DOUBLE))
|
||||
CV_Error(cv::Error::StsUnsupportedFormat, "The device doesn't support double");
|
||||
}
|
||||
|
||||
_dst.create(src.size(), src.type());
|
||||
GpuMat dst = _dst.getGpuMat();
|
||||
|
||||
funcs[depth](src, dst, StreamAccessor::getStream(stream));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// sqrt
|
||||
|
||||
namespace arithm
|
||||
{
|
||||
template <typename T>
|
||||
void sqrtMat(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
|
||||
}
|
||||
|
||||
void cv::cuda::sqrt(InputArray _src, OutputArray _dst, Stream& stream)
|
||||
{
|
||||
using namespace arithm;
|
||||
|
||||
typedef void (*func_t)(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
|
||||
static const func_t funcs[] =
|
||||
{
|
||||
sqrtMat<unsigned char>,
|
||||
sqrtMat<signed char>,
|
||||
sqrtMat<unsigned short>,
|
||||
sqrtMat<short>,
|
||||
sqrtMat<int>,
|
||||
sqrtMat<float>,
|
||||
sqrtMat<double>
|
||||
};
|
||||
|
||||
GpuMat src = _src.getGpuMat();
|
||||
|
||||
const int depth = src.depth();
|
||||
|
||||
CV_Assert( depth <= CV_64F );
|
||||
CV_Assert( src.channels() == 1 );
|
||||
|
||||
if (depth == CV_64F)
|
||||
{
|
||||
if (!deviceSupports(NATIVE_DOUBLE))
|
||||
CV_Error(cv::Error::StsUnsupportedFormat, "The device doesn't support double");
|
||||
}
|
||||
|
||||
_dst.create(src.size(), src.type());
|
||||
GpuMat dst = _dst.getGpuMat();
|
||||
|
||||
funcs[depth](src, dst, StreamAccessor::getStream(stream));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// exp
|
||||
|
||||
namespace arithm
|
||||
{
|
||||
template <typename T>
|
||||
void expMat(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
|
||||
}
|
||||
|
||||
void cv::cuda::exp(InputArray _src, OutputArray _dst, Stream& stream)
|
||||
{
|
||||
using namespace arithm;
|
||||
|
||||
typedef void (*func_t)(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
|
||||
static const func_t funcs[] =
|
||||
{
|
||||
expMat<unsigned char>,
|
||||
expMat<signed char>,
|
||||
expMat<unsigned short>,
|
||||
expMat<short>,
|
||||
expMat<int>,
|
||||
expMat<float>,
|
||||
expMat<double>
|
||||
};
|
||||
|
||||
GpuMat src = _src.getGpuMat();
|
||||
|
||||
const int depth = src.depth();
|
||||
|
||||
CV_Assert( depth <= CV_64F );
|
||||
CV_Assert( src.channels() == 1 );
|
||||
|
||||
if (depth == CV_64F)
|
||||
{
|
||||
if (!deviceSupports(NATIVE_DOUBLE))
|
||||
CV_Error(cv::Error::StsUnsupportedFormat, "The device doesn't support double");
|
||||
}
|
||||
|
||||
_dst.create(src.size(), src.type());
|
||||
GpuMat dst = _dst.getGpuMat();
|
||||
|
||||
funcs[depth](src, dst, StreamAccessor::getStream(stream));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// log
|
||||
|
||||
namespace arithm
|
||||
{
|
||||
template <typename T>
|
||||
void logMat(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
|
||||
}
|
||||
|
||||
void cv::cuda::log(InputArray _src, OutputArray _dst, Stream& stream)
|
||||
{
|
||||
using namespace arithm;
|
||||
|
||||
typedef void (*func_t)(PtrStepSzb src, PtrStepSzb dst, cudaStream_t stream);
|
||||
static const func_t funcs[] =
|
||||
{
|
||||
logMat<unsigned char>,
|
||||
logMat<signed char>,
|
||||
logMat<unsigned short>,
|
||||
logMat<short>,
|
||||
logMat<int>,
|
||||
logMat<float>,
|
||||
logMat<double>
|
||||
};
|
||||
|
||||
GpuMat src = _src.getGpuMat();
|
||||
|
||||
const int depth = src.depth();
|
||||
|
||||
CV_Assert( depth <= CV_64F );
|
||||
CV_Assert( src.channels() == 1 );
|
||||
|
||||
if (depth == CV_64F)
|
||||
{
|
||||
if (!deviceSupports(NATIVE_DOUBLE))
|
||||
CV_Error(cv::Error::StsUnsupportedFormat, "The device doesn't support double");
|
||||
}
|
||||
|
||||
_dst.create(src.size(), src.type());
|
||||
GpuMat dst = _dst.getGpuMat();
|
||||
|
||||
funcs[depth](src, dst, StreamAccessor::getStream(stream));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// pow
|
||||
|
||||
namespace arithm
|
||||
{
|
||||
template<typename T> void pow(PtrStepSzb src, double power, PtrStepSzb dst, cudaStream_t stream);
|
||||
}
|
||||
|
||||
void cv::cuda::pow(InputArray _src, double power, OutputArray _dst, Stream& stream)
|
||||
{
|
||||
typedef void (*func_t)(PtrStepSzb src, double power, PtrStepSzb dst, cudaStream_t stream);
|
||||
static const func_t funcs[] =
|
||||
{
|
||||
arithm::pow<unsigned char>,
|
||||
arithm::pow<signed char>,
|
||||
arithm::pow<unsigned short>,
|
||||
arithm::pow<short>,
|
||||
arithm::pow<int>,
|
||||
arithm::pow<float>,
|
||||
arithm::pow<double>
|
||||
};
|
||||
|
||||
GpuMat src = _src.getGpuMat();
|
||||
|
||||
const int depth = src.depth();
|
||||
const int cn = src.channels();
|
||||
|
||||
CV_Assert(depth <= CV_64F);
|
||||
|
||||
if (depth == CV_64F)
|
||||
{
|
||||
if (!deviceSupports(NATIVE_DOUBLE))
|
||||
CV_Error(cv::Error::StsUnsupportedFormat, "The device doesn't support double");
|
||||
}
|
||||
|
||||
_dst.create(src.size(), src.type());
|
||||
GpuMat dst = _dst.getGpuMat();
|
||||
|
||||
PtrStepSzb src_(src.rows, src.cols * cn, src.data, src.step);
|
||||
PtrStepSzb dst_(src.rows, src.cols * cn, dst.data, dst.step);
|
||||
|
||||
funcs[depth](src_, power, dst_, StreamAccessor::getStream(stream));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// compare
|
||||
|
||||
|
Reference in New Issue
Block a user