Blame view

3rdparty/opencv-4.5.4/modules/core/src/stat.hpp 1.23 KB
f4334277   Hu Chunming   提交3rdparty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  // This file is part of OpenCV project.
  // It is subject to the license terms in the LICENSE file found in the top-level directory
  // of this distribution and at http://opencv.org/license.html
  
  
  #ifndef SRC_STAT_HPP
  #define SRC_STAT_HPP
  
  #include "opencv2/core/mat.hpp"
  
  namespace cv {
  
  #ifdef HAVE_OPENCL
  
  enum { OCL_OP_SUM = 0, OCL_OP_SUM_ABS =  1, OCL_OP_SUM_SQR = 2 };
  bool ocl_sum( InputArray _src, Scalar & res, int sum_op, InputArray _mask = noArray(),
                       InputArray _src2 = noArray(), bool calc2 = false, const Scalar & res2 = Scalar() );
  bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int* minLoc, int* maxLoc, InputArray _mask,
                             int ddepth = -1, bool absValues = false, InputArray _src2 = noArray(), double * maxVal2 = NULL);
  
  template <typename T> Scalar ocl_part_sum(Mat m)
  {
      CV_Assert(m.rows == 1);
  
      Scalar s = Scalar::all(0);
      int cn = m.channels();
      const T * const ptr = m.ptr<T>(0);
  
      for (int x = 0, w = m.cols * cn; x < w; )
          for (int c = 0; c < cn; ++c, ++x)
              s[c] += ptr[x];
  
      return s;
  }
  
  #endif
  
  typedef int (*SumFunc)(const uchar*, const uchar* mask, uchar*, int, int);
  SumFunc getSumFunc(int depth);
  
  }
  
  #endif // SRC_STAT_HPP