Commit dafd4da0 authored by Ilya Lavrenov's avatar Ilya Lavrenov

removed ocl::minMax_buf, updated doc (operation on matrices)

parent 88419f89
...@@ -3,6 +3,16 @@ Matrix Reductions ...@@ -3,6 +3,16 @@ Matrix Reductions
.. highlight:: cpp .. highlight:: cpp
ocl::absSum
---------------
Returns the sum of absolute values for matrix elements.
.. ocv:function:: Scalar ocl::absSum(const oclMat &m)
:param m: The Source image of all depth.
Counts the abs sum of matrix elements for each channel. Supports all data types.
ocl::countNonZero ocl::countNonZero
--------------------- ---------------------
Returns the number of non-zero elements in src Returns the number of non-zero elements in src
...@@ -11,7 +21,7 @@ Returns the number of non-zero elements in src ...@@ -11,7 +21,7 @@ Returns the number of non-zero elements in src
:param src: Single-channel array :param src: Single-channel array
Counts non-zero array elements. Counts non-zero array elements. Supports all data types.
ocl::minMax ocl::minMax
------------------ ------------------
...@@ -49,32 +59,22 @@ Returns void ...@@ -49,32 +59,22 @@ Returns void
The functions minMaxLoc find minimum and maximum element values and their positions. The extremums are searched across the whole array, or, if mask is not an empty array, in the specified array region. The functions do not work with multi-channel arrays. The functions minMaxLoc find minimum and maximum element values and their positions. The extremums are searched across the whole array, or, if mask is not an empty array, in the specified array region. The functions do not work with multi-channel arrays.
ocl::Sum ocl::sqrSum
------------------ ------------------
Returns the sum of matrix elements for each channel Returns the squared sum of matrix elements for each channel
.. ocv:function:: Scalar ocl::sum(const oclMat &m)
:param m: The Source image of all depth.
Counts the sum of matrix elements for each channel.
ocl::absSum
---------------
Returns the sum of absolute values for matrix elements.
.. ocv:function:: Scalar ocl::absSum(const oclMat &m) .. ocv:function:: Scalar ocl::sqrSum(const oclMat &m)
:param m: The Source image of all depth. :param m: The Source image of all depth.
Counts the abs sum of matrix elements for each channel. Counts the squared sum of matrix elements for each channel. Supports all data types.
ocl::sqrSum ocl::sum
------------------ ------------------
Returns the squared sum of matrix elements for each channel Returns the sum of matrix elements for each channel
.. ocv:function:: Scalar ocl::sqrSum(const oclMat &m) .. ocv:function:: Scalar ocl::sum(const oclMat &m)
:param m: The Source image of all depth. :param m: The Source image of all depth.
Counts the squared sum of matrix elements for each channel. Counts the sum of matrix elements for each channel.
This diff is collapsed.
...@@ -410,6 +410,7 @@ namespace cv ...@@ -410,6 +410,7 @@ namespace cv
////////////////////////////// Arithmetics /////////////////////////////////// ////////////////////////////// Arithmetics ///////////////////////////////////
//! adds one matrix to another with scale (dst = src1 * alpha + src2 * beta + gama) //! adds one matrix to another with scale (dst = src1 * alpha + src2 * beta + gama)
// supports all data types
CV_EXPORTS void addWeighted(const oclMat &src1, double alpha, const oclMat &src2, double beta, double gama, oclMat &dst); CV_EXPORTS void addWeighted(const oclMat &src1, double alpha, const oclMat &src2, double beta, double gama, oclMat &dst);
//! adds one matrix to another (dst = src1 + src2) //! adds one matrix to another (dst = src1 + src2)
...@@ -456,17 +457,17 @@ namespace cv ...@@ -456,17 +457,17 @@ namespace cv
CV_EXPORTS void absdiff(const oclMat &src1, const Scalar &s, oclMat &dst); CV_EXPORTS void absdiff(const oclMat &src1, const Scalar &s, oclMat &dst);
//! computes mean value and standard deviation of all or selected array elements //! computes mean value and standard deviation of all or selected array elements
// supports except CV_32F,CV_64F // supports all data types
CV_EXPORTS void meanStdDev(const oclMat &mtx, Scalar &mean, Scalar &stddev); CV_EXPORTS void meanStdDev(const oclMat &mtx, Scalar &mean, Scalar &stddev);
//! computes norm of array //! computes norm of array
// supports NORM_INF, NORM_L1, NORM_L2 // supports NORM_INF, NORM_L1, NORM_L2
// supports only CV_8UC1 type // supports all data types
CV_EXPORTS double norm(const oclMat &src1, int normType = NORM_L2); CV_EXPORTS double norm(const oclMat &src1, int normType = NORM_L2);
//! computes norm of the difference between two arrays //! computes norm of the difference between two arrays
// supports NORM_INF, NORM_L1, NORM_L2 // supports NORM_INF, NORM_L1, NORM_L2
// supports only CV_8UC1 type // supports all data types
CV_EXPORTS double norm(const oclMat &src1, const oclMat &src2, int normType = NORM_L2); CV_EXPORTS double norm(const oclMat &src1, const oclMat &src2, int normType = NORM_L2);
//! reverses the order of the rows, columns or both in a matrix //! reverses the order of the rows, columns or both in a matrix
...@@ -474,7 +475,6 @@ namespace cv ...@@ -474,7 +475,6 @@ namespace cv
CV_EXPORTS void flip(const oclMat &src, oclMat &dst, int flipCode); CV_EXPORTS void flip(const oclMat &src, oclMat &dst, int flipCode);
//! computes sum of array elements //! computes sum of array elements
// disabled until fix crash
// support all types // support all types
CV_EXPORTS Scalar sum(const oclMat &m); CV_EXPORTS Scalar sum(const oclMat &m);
CV_EXPORTS Scalar absSum(const oclMat &m); CV_EXPORTS Scalar absSum(const oclMat &m);
...@@ -483,7 +483,6 @@ namespace cv ...@@ -483,7 +483,6 @@ namespace cv
//! finds global minimum and maximum array elements and returns their values //! finds global minimum and maximum array elements and returns their values
// support all C1 types // support all C1 types
CV_EXPORTS void minMax(const oclMat &src, double *minVal, double *maxVal = 0, const oclMat &mask = oclMat()); CV_EXPORTS void minMax(const oclMat &src, double *minVal, double *maxVal = 0, const oclMat &mask = oclMat());
CV_EXPORTS void minMax_buf(const oclMat &src, double *minVal, double *maxVal, const oclMat &mask, oclMat& buf);
//! finds global minimum and maximum array elements and returns their values with locations //! finds global minimum and maximum array elements and returns their values with locations
// support all C1 types // support all C1 types
...@@ -582,7 +581,7 @@ namespace cv ...@@ -582,7 +581,7 @@ namespace cv
// support only CV_32FC1 type // support only CV_32FC1 type
CV_EXPORTS void convolve(const oclMat &image, const oclMat &temp1, oclMat &result); CV_EXPORTS void convolve(const oclMat &image, const oclMat &temp1, oclMat &result);
CV_EXPORTS void cvtColor(const oclMat &src, oclMat &dst, int code , int dcn = 0); CV_EXPORTS void cvtColor(const oclMat &src, oclMat &dst, int code, int dcn = 0);
//! initializes a scaled identity matrix //! initializes a scaled identity matrix
CV_EXPORTS void setIdentity(oclMat& src, const Scalar & val = Scalar(1)); CV_EXPORTS void setIdentity(oclMat& src, const Scalar & val = Scalar(1));
......
...@@ -521,13 +521,13 @@ static void arithmetic_minMax_run(const oclMat &src, const oclMat & mask, cl_mem ...@@ -521,13 +521,13 @@ static void arithmetic_minMax_run(const oclMat &src, const oclMat & mask, cl_mem
} }
template <typename T, typename WT> template <typename T, typename WT>
void arithmetic_minMax(const oclMat &src, double *minVal, double *maxVal, void arithmetic_minMax(const oclMat &src, double *minVal, double *maxVal, const oclMat &mask)
const oclMat &mask, oclMat &buf)
{ {
size_t groupnum = src.clCxt->computeUnits(); size_t groupnum = src.clCxt->computeUnits();
CV_Assert(groupnum != 0); CV_Assert(groupnum != 0);
int dbsize = groupnum * 2 * src.elemSize(); int dbsize = groupnum * 2 * src.elemSize();
oclMat buf;
ensureSizeIsEnough(1, dbsize, CV_8UC1, buf); ensureSizeIsEnough(1, dbsize, CV_8UC1, buf);
cl_mem buf_data = reinterpret_cast<cl_mem>(buf.data); cl_mem buf_data = reinterpret_cast<cl_mem>(buf.data);
...@@ -549,15 +549,9 @@ void arithmetic_minMax(const oclMat &src, double *minVal, double *maxVal, ...@@ -549,15 +549,9 @@ void arithmetic_minMax(const oclMat &src, double *minVal, double *maxVal,
} }
} }
void cv::ocl::minMax(const oclMat &src, double *minVal, double *maxVal, const oclMat &mask) typedef void (*minMaxFunc)(const oclMat &src, double *minVal, double *maxVal, const oclMat &mask);
{
oclMat buf;
minMax_buf(src, minVal, maxVal, mask, buf);
}
typedef void (*minMaxFunc)(const oclMat &src, double *minVal, double *maxVal, const oclMat &mask, oclMat &buf);
void cv::ocl::minMax_buf(const oclMat &src, double *minVal, double *maxVal, const oclMat &mask, oclMat &buf) void cv::ocl::minMax(const oclMat &src, double *minVal, double *maxVal, const oclMat &mask)
{ {
CV_Assert(src.channels() == 1); CV_Assert(src.channels() == 1);
CV_Assert(src.size() == mask.size() || mask.empty()); CV_Assert(src.size() == mask.size() || mask.empty());
...@@ -571,7 +565,7 @@ void cv::ocl::minMax_buf(const oclMat &src, double *minVal, double *maxVal, cons ...@@ -571,7 +565,7 @@ void cv::ocl::minMax_buf(const oclMat &src, double *minVal, double *maxVal, cons
CV_Error(CV_GpuNotSupported, "Selected device doesn't support double"); CV_Error(CV_GpuNotSupported, "Selected device doesn't support double");
} }
static minMaxFunc functab[8] = static minMaxFunc functab[] =
{ {
arithmetic_minMax<uchar, int>, arithmetic_minMax<uchar, int>,
arithmetic_minMax<char, int>, arithmetic_minMax<char, int>,
...@@ -583,9 +577,10 @@ void cv::ocl::minMax_buf(const oclMat &src, double *minVal, double *maxVal, cons ...@@ -583,9 +577,10 @@ void cv::ocl::minMax_buf(const oclMat &src, double *minVal, double *maxVal, cons
0 0
}; };
minMaxFunc func; minMaxFunc func = functab[src.depth()];
func = functab[src.depth()]; CV_Assert(func != 0);
func(src, minVal, maxVal, mask, buf);
func(src, minVal, maxVal, mask);
} }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
......
...@@ -221,7 +221,7 @@ void cv::ocl::GoodFeaturesToTrackDetector_OCL::operator ()(const oclMat& image, ...@@ -221,7 +221,7 @@ void cv::ocl::GoodFeaturesToTrackDetector_OCL::operator ()(const oclMat& image,
cornerMinEigenVal_dxdy(image, eig_, Dx_, Dy_, blockSize, 3); cornerMinEigenVal_dxdy(image, eig_, Dx_, Dy_, blockSize, 3);
double maxVal = 0; double maxVal = 0;
minMax_buf(eig_, 0, &maxVal, oclMat(), minMaxbuf_); minMax(eig_, NULL, &maxVal);
ensureSizeIsEnough(1, std::max(1000, static_cast<int>(image.size().area() * 0.05)), CV_32FC2, tmpCorners_); ensureSizeIsEnough(1, std::max(1000, static_cast<int>(image.size().area() * 0.05)), CV_32FC2, tmpCorners_);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment