added absSum function
This commit is contained in:
@@ -52,6 +52,8 @@ double cv::gpu::norm(const GpuMat&, int) { throw_nogpu(); return 0.0; }
|
||||
double cv::gpu::norm(const GpuMat&, const GpuMat&, int) { throw_nogpu(); return 0.0; }
|
||||
Scalar cv::gpu::sum(const GpuMat&) { throw_nogpu(); return Scalar(); }
|
||||
Scalar cv::gpu::sum(const GpuMat&, GpuMat&) { throw_nogpu(); return Scalar(); }
|
||||
Scalar cv::gpu::absSum(const GpuMat&) { throw_nogpu(); return Scalar(); }
|
||||
Scalar cv::gpu::absSum(const GpuMat&, GpuMat&) { throw_nogpu(); return Scalar(); }
|
||||
Scalar cv::gpu::sqrSum(const GpuMat&) { throw_nogpu(); return Scalar(); }
|
||||
Scalar cv::gpu::sqrSum(const GpuMat&, GpuMat&) { throw_nogpu(); return Scalar(); }
|
||||
void cv::gpu::minMax(const GpuMat&, double*, double*, const GpuMat&) { throw_nogpu(); }
|
||||
@@ -128,6 +130,12 @@ namespace cv { namespace gpu { namespace mathfunc
|
||||
template <typename T>
|
||||
void sumMultipassCaller(const DevMem2D src, PtrStep buf, double* sum, int cn);
|
||||
|
||||
template <typename T>
|
||||
void absSumCaller(const DevMem2D src, PtrStep buf, double* sum, int cn);
|
||||
|
||||
template <typename T>
|
||||
void absSumMultipassCaller(const DevMem2D src, PtrStep buf, double* sum, int cn);
|
||||
|
||||
template <typename T>
|
||||
void sqrSumCaller(const DevMem2D src, PtrStep buf, double* sum, int cn);
|
||||
|
||||
@@ -166,7 +174,7 @@ Scalar cv::gpu::sum(const GpuMat& src, GpuMat& buf)
|
||||
|
||||
Size buf_size;
|
||||
sums::getBufSizeRequired(src.cols, src.rows, src.channels(),
|
||||
buf_size.width, buf_size.height);
|
||||
buf_size.width, buf_size.height);
|
||||
ensureSizeIsEnough(buf_size, CV_8U, buf);
|
||||
|
||||
Caller* callers = multipass_callers;
|
||||
@@ -182,6 +190,47 @@ Scalar cv::gpu::sum(const GpuMat& src, GpuMat& buf)
|
||||
}
|
||||
|
||||
|
||||
Scalar cv::gpu::absSum(const GpuMat& src)
|
||||
{
|
||||
GpuMat buf;
|
||||
return absSum(src, buf);
|
||||
}
|
||||
|
||||
|
||||
Scalar cv::gpu::absSum(const GpuMat& src, GpuMat& buf)
|
||||
{
|
||||
using namespace mathfunc;
|
||||
|
||||
typedef void (*Caller)(const DevMem2D, PtrStep, double*, int);
|
||||
|
||||
static Caller multipass_callers[7] = {
|
||||
absSumMultipassCaller<unsigned char>, absSumMultipassCaller<char>,
|
||||
absSumMultipassCaller<unsigned short>, absSumMultipassCaller<short>,
|
||||
absSumMultipassCaller<int>, absSumMultipassCaller<float>, 0 };
|
||||
|
||||
static Caller singlepass_callers[7] = {
|
||||
absSumCaller<unsigned char>, absSumCaller<char>,
|
||||
absSumCaller<unsigned short>, absSumCaller<short>,
|
||||
absSumCaller<int>, absSumCaller<float>, 0 };
|
||||
|
||||
Size buf_size;
|
||||
sums::getBufSizeRequired(src.cols, src.rows, src.channels(),
|
||||
buf_size.width, buf_size.height);
|
||||
ensureSizeIsEnough(buf_size, CV_8U, buf);
|
||||
|
||||
Caller* callers = multipass_callers;
|
||||
if (TargetArchs::builtWith(ATOMICS) && DeviceInfo().has(ATOMICS))
|
||||
callers = singlepass_callers;
|
||||
|
||||
Caller caller = callers[src.depth()];
|
||||
if (!caller) CV_Error(CV_StsBadArg, "absSum: unsupported type");
|
||||
|
||||
double result[4];
|
||||
caller(src, buf, result, src.channels());
|
||||
return Scalar(result[0], result[1], result[2], result[3]);
|
||||
}
|
||||
|
||||
|
||||
Scalar cv::gpu::sqrSum(const GpuMat& src)
|
||||
{
|
||||
GpuMat buf;
|
||||
@@ -222,6 +271,9 @@ Scalar cv::gpu::sqrSum(const GpuMat& src, GpuMat& buf)
|
||||
return Scalar(result[0], result[1], result[2], result[3]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Find min or max
|
||||
|
||||
|
Reference in New Issue
Block a user