ocl.hpp
Go to the documentation of this file.
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
8 //
9 //
10 // License Agreement
11 // For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
14 // Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
15 // Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
16 // Third party copyrights are property of their respective owners.
17 //
18 // Redistribution and use in source and binary forms, with or without modification,
19 // are permitted provided that the following conditions are met:
20 //
21 // * Redistribution's of source code must retain the above copyright notice,
22 // this list of conditions and the following disclaimer.
23 //
24 // * Redistribution's in binary form must reproduce the above copyright notice,
25 // this list of conditions and the following disclaimer in the documentation
26 // and/or other materials provided with the distribution.
27 //
28 // * The name of the copyright holders may not be used to endorse or promote products
29 // derived from this software without specific prior written permission.
30 //
31 // This software is provided by the copyright holders and contributors "as is" and
32 // any express or implied warranties, including, but not limited to, the implied
33 // warranties of merchantability and fitness for a particular purpose are disclaimed.
34 // In no event shall the Intel Corporation or contributors be liable for any direct,
35 // indirect, incidental, special, exemplary, or consequential damages
36 // (including, but not limited to, procurement of substitute goods or services;
37 // loss of use, data, or profits; or business interruption) however caused
38 // and on any theory of liability, whether in contract, strict liability,
39 // or tort (including negligence or otherwise) arising in any way out of
40 // the use of this software, even if advised of the possibility of such damage.
41 //
42 //M*/
43 
44 #ifndef __OPENCV_OCL_HPP__
45 #define __OPENCV_OCL_HPP__
46 
47 #include <memory>
48 #include <vector>
49 
50 #include "opencv2/core/core.hpp"
54 #include "opencv2/ml/ml.hpp"
55 
56 namespace cv
57 {
58  namespace ocl
59  {
61  {
66  //CVCL_DEVICE_TYPE_CUSTOM = (1 << 4)
67  CVCL_DEVICE_TYPE_ALL = 0xFFFFFFFF
68  };
69 
70  enum DevMemRW
71  {
75  };
76 
78  {
80  DEVICE_MEM_AHP, //alloc host pointer
81  DEVICE_MEM_UHP, //use host pointer
82  DEVICE_MEM_CHP, //copy host pointer
83  DEVICE_MEM_PM //persistent memory
84  };
85 
86  // these classes contain OpenCL runtime information
87 
88  struct PlatformInfo;
89 
90  struct DeviceInfo
91  {
92  int _id; // reserved, don't use it
93 
95  std::string deviceProfile;
96  std::string deviceVersion;
97  std::string deviceName;
98  std::string deviceVendor;
100  std::string deviceDriverVersion;
101  std::string deviceExtensions;
102 
104  std::vector<size_t> maxWorkItemSizes;
108 
111 
113  bool isUnifiedMemory; // 1 means integrated GPU, otherwise this value is 0
115 
117 
119 
120  DeviceInfo();
121  ~DeviceInfo();
122  };
123 
125  {
126  int _id; // reserved, don't use it
127 
128  std::string platformProfile;
129  std::string platformVersion;
130  std::string platformName;
131  std::string platformVendor;
132  std::string platformExtensons;
133 
136 
137  std::vector<const DeviceInfo*> devices;
138 
139  PlatformInfo();
140  ~PlatformInfo();
141  };
142 
144  typedef std::vector<const PlatformInfo*> PlatformsInfo;
145 
146  CV_EXPORTS int getOpenCLPlatforms(PlatformsInfo& platforms);
147 
148  typedef std::vector<const DeviceInfo*> DevicesInfo;
149 
150  CV_EXPORTS int getOpenCLDevices(DevicesInfo& devices, int deviceType = CVCL_DEVICE_TYPE_GPU,
151  const PlatformInfo* platform = NULL);
152 
153  // set device you want to use
154  CV_EXPORTS void setDevice(const DeviceInfo* info);
155 
156  // Initialize from OpenCL handles directly.
157  // Argument types is (pointers): cl_platform_id*, cl_context*, cl_device_id*
158  CV_EXPORTS void initializeContext(void* pClPlatform, void* pClContext, void* pClDevice);
159 
161  CV_EXPORTS void error(const char *error_string, const char *file, const int line, const char *func);
162 
164  {
169  };
170 
171  // Represents OpenCL context, interface
172  class CV_EXPORTS Context
173  {
174  protected:
175  Context() { }
176  ~Context() { }
177  public:
178  static Context* getContext();
179 
180  bool supportsFeature(FEATURE_TYPE featureType) const;
181  const DeviceInfo& getDeviceInfo() const;
182 
183  const void* getOpenCLContextPtr() const;
184  const void* getOpenCLCommandQueuePtr() const;
185  const void* getOpenCLDeviceIDPtr() const;
186  };
187 
188  inline const void *getClContextPtr()
189  {
191  }
192 
193  inline const void *getClCommandQueuePtr()
194  {
196  }
197 
198  CV_EXPORTS bool supportsFeature(FEATURE_TYPE featureType);
199 
200  CV_EXPORTS void finish();
201 
203  {
204  CACHE_NONE = 0, // do not cache OpenCL binary
205  CACHE_DEBUG = 0x1 << 0, // cache OpenCL binary when built in debug mode
206  CACHE_RELEASE = 0x1 << 1, // default behavior, only cache when built in release mode
207  CACHE_ALL = CACHE_DEBUG | CACHE_RELEASE // cache opencl binary
208  };
210  // After a program (*.cl files in opencl/ folder) is built at runtime, we allow the
211  // compiled OpenCL program to be cached to the path automatically as "path/*.clb"
212  // binary file, which will be reused when the OpenCV executable is started again.
213  //
214  // This feature is enabled by default.
215  CV_EXPORTS void setBinaryDiskCache(int mode = CACHE_RELEASE, cv::String path = "./");
216 
218  CV_EXPORTS void setBinaryPath(const char *path);
219 
221  {
222  const char* name;
223  const char* programStr;
224  const char* programHash;
225 
226  // Cache in memory by name (should be unique). Caching on disk disabled.
227  inline ProgramSource(const char* _name, const char* _programStr)
228  : name(_name), programStr(_programStr), programHash(NULL)
229  {
230  }
231 
232  // Cache in memory by name (should be unique). Caching on disk uses programHash mark.
233  inline ProgramSource(const char* _name, const char* _programStr, const char* _programHash)
234  : name(_name), programStr(_programStr), programHash(_programHash)
235  {
236  }
237  };
238 
241  CV_EXPORTS void openCLExecuteKernelInterop(Context *clCxt,
242  const cv::ocl::ProgramSource& source, string kernelName,
243  size_t globalThreads[3], size_t localThreads[3],
244  std::vector< std::pair<size_t, const void *> > &args,
245  int channels, int depth, const char *build_options);
246 
247  class CV_EXPORTS oclMatExpr;
249  class CV_EXPORTS oclMat
250  {
251  public:
253  oclMat();
255  oclMat(int rows, int cols, int type);
256  oclMat(Size size, int type);
258  oclMat(int rows, int cols, int type, const Scalar &s);
259  oclMat(Size size, int type, const Scalar &s);
261  oclMat(const oclMat &m);
262 
264  oclMat(int rows, int cols, int type, void *data, size_t step = Mat::AUTO_STEP);
265  oclMat(Size size, int type, void *data, size_t step = Mat::AUTO_STEP);
266 
268  oclMat(const oclMat &m, const Range &rowRange, const Range &colRange);
269  oclMat(const oclMat &m, const Rect &roi);
270 
272  explicit oclMat (const Mat &m);
273 
275  ~oclMat();
276 
278  oclMat &operator = (const oclMat &m);
280  oclMat &operator = (const Mat &m);
281  oclMat &operator = (const oclMatExpr& expr);
282 
284  void upload(const cv::Mat &m);
285 
286 
288  operator Mat() const;
289  void download(cv::Mat &m) const;
290 
292  operator _InputArray();
293 
295  operator _OutputArray();
296 
298  oclMat row(int y) const;
300  oclMat col(int x) const;
302  oclMat rowRange(int startrow, int endrow) const;
303  oclMat rowRange(const Range &r) const;
305  oclMat colRange(int startcol, int endcol) const;
306  oclMat colRange(const Range &r) const;
307 
309  oclMat clone() const;
310 
312  // It calls m.create(this->size(), this->type()).
313  // It supports any data type
314  void copyTo( oclMat &m, const oclMat &mask = oclMat()) const;
315 
317  void convertTo( oclMat &m, int rtype, double alpha = 1, double beta = 0 ) const;
318 
319  void assignTo( oclMat &m, int type = -1 ) const;
320 
322  oclMat& operator = (const Scalar &s);
324  oclMat& setTo(const Scalar &s, const oclMat &mask = oclMat());
326  // number of channels and/or different number of rows. see cvReshape.
327  oclMat reshape(int cn, int rows = 0) const;
328 
330  // previous data is unreferenced if needed.
331  void create(int rows, int cols, int type);
332  void create(Size size, int type);
333 
335  void createEx(int rows, int cols, int type, DevMemRW rw_type, DevMemType mem_type);
336  void createEx(Size size, int type, DevMemRW rw_type, DevMemType mem_type);
337 
339  // deallocate the data when reference counter reaches 0.
340  void release();
341 
343  void swap(oclMat &mat);
344 
346  void locateROI( Size &wholeSize, Point &ofs ) const;
348  oclMat& adjustROI( int dtop, int dbottom, int dleft, int dright );
350  // (this is a generalized form of row, rowRange etc.)
351  oclMat operator()( Range rowRange, Range colRange ) const;
352  oclMat operator()( const Rect &roi ) const;
353 
354  oclMat& operator+=( const oclMat& m );
355  oclMat& operator-=( const oclMat& m );
356  oclMat& operator*=( const oclMat& m );
357  oclMat& operator/=( const oclMat& m );
358 
360  // (i.e. when there are no gaps between successive rows).
361  // similar to CV_IS_oclMat_CONT(cvoclMat->type)
362  bool isContinuous() const;
364  // similar to CV_ELEM_SIZE(cvMat->type)
365  size_t elemSize() const;
367  size_t elemSize1() const;
369  int type() const;
372  int ocltype() const;
374  int depth() const;
376  int channels() const;
379  int oclchannels() const;
381  size_t step1() const;
383  // width == number of columns, height == number of rows
384  Size size() const;
386  bool empty() const;
387 
389  oclMat t() const;
390 
397  int flags;
399  int rows, cols;
401  size_t step;
404 
406  // when oclMatrix points to user-allocated data, the pointer is NULL
407  int *refcount;
408 
410  //datastart and dataend are not used in current version
413 
415  Context *clCxt; // TODO clCtx
416  //add offset for handle ROI, calculated in byte
417  int offset;
418  //add wholerows and wholecols for the whole matrix, datastart and dataend are no longer used
421  };
422 
423  // convert InputArray/OutputArray to oclMat references
424  CV_EXPORTS oclMat& getOclMatRef(InputArray src);
425  CV_EXPORTS oclMat& getOclMatRef(OutputArray src);
426 
429  // Support all types
430  CV_EXPORTS void merge(const oclMat *src, size_t n, oclMat &dst);
431  CV_EXPORTS void merge(const vector<oclMat> &src, oclMat &dst);
432 
434  // Support all types
435  CV_EXPORTS void split(const oclMat &src, oclMat *dst);
436  CV_EXPORTS void split(const oclMat &src, vector<oclMat> &dst);
437 
439 
441  // supports all data types
442  CV_EXPORTS void addWeighted(const oclMat &src1, double alpha, const oclMat &src2, double beta, double gama, oclMat &dst);
443 
445  // supports all data types
446  CV_EXPORTS void add(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask = oclMat());
448  // supports all data types
449  CV_EXPORTS void add(const oclMat &src1, const Scalar &s, oclMat &dst, const oclMat &mask = oclMat());
450 
452  // supports all data types
453  CV_EXPORTS void subtract(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask = oclMat());
455  // supports all data types
456  CV_EXPORTS void subtract(const oclMat &src1, const Scalar &s, oclMat &dst, const oclMat &mask = oclMat());
457 
459  // supports all data types
460  CV_EXPORTS void multiply(const oclMat &src1, const oclMat &src2, oclMat &dst, double scale = 1);
462  // supports all data types
463  CV_EXPORTS void multiply(double scalar, const oclMat &src, oclMat &dst);
464 
466  // supports all data types
467  CV_EXPORTS void divide(const oclMat &src1, const oclMat &src2, oclMat &dst, double scale = 1);
469  // supports all data types
470  CV_EXPORTS void divide(double scale, const oclMat &src1, oclMat &dst);
471 
473  // supports all data types
474  CV_EXPORTS void min(const oclMat &src1, const oclMat &src2, oclMat &dst);
475 
477  // supports all data types
478  CV_EXPORTS void max(const oclMat &src1, const oclMat &src2, oclMat &dst);
479 
481  // supports all data types
482  CV_EXPORTS void compare(const oclMat &src1, const oclMat &src2, oclMat &dst, int cmpop);
483 
485  // supports all data types
486  CV_EXPORTS void transpose(const oclMat &src, oclMat &dst);
487 
489  // supports all data types
490  CV_EXPORTS void abs(const oclMat &src, oclMat &dst);
491 
493  // supports all data types
494  CV_EXPORTS void absdiff(const oclMat &src1, const oclMat &src2, oclMat &dst);
496  // supports all data types
497  CV_EXPORTS void absdiff(const oclMat &src1, const Scalar &s, oclMat &dst);
498 
500  // supports all data types
501  CV_EXPORTS void meanStdDev(const oclMat &mtx, Scalar &mean, Scalar &stddev);
502 
504  // supports NORM_INF, NORM_L1, NORM_L2
505  // supports all data types
506  CV_EXPORTS double norm(const oclMat &src1, int normType = NORM_L2);
507 
509  // supports NORM_INF, NORM_L1, NORM_L2
510  // supports all data types
511  CV_EXPORTS double norm(const oclMat &src1, const oclMat &src2, int normType = NORM_L2);
512 
514  // supports all types
515  CV_EXPORTS void flip(const oclMat &src, oclMat &dst, int flipCode);
516 
518  // support all types
519  CV_EXPORTS Scalar sum(const oclMat &m);
520  CV_EXPORTS Scalar absSum(const oclMat &m);
521  CV_EXPORTS Scalar sqrSum(const oclMat &m);
522 
524  // support all C1 types
525  CV_EXPORTS void minMax(const oclMat &src, double *minVal, double *maxVal = 0, const oclMat &mask = oclMat());
526 
528  // support all C1 types
529  CV_EXPORTS void minMaxLoc(const oclMat &src, double *minVal, double *maxVal = 0, Point *minLoc = 0, Point *maxLoc = 0,
530  const oclMat &mask = oclMat());
531 
533  // support all types
534  CV_EXPORTS int countNonZero(const oclMat &src);
535 
537  // destination array will have the depth type as lut and the same channels number as source
538  //It supports 8UC1 8UC4 only
539  CV_EXPORTS void LUT(const oclMat &src, const oclMat &lut, oclMat &dst);
540 
542  CV_EXPORTS void calcHist(const oclMat &mat_src, oclMat &mat_hist);
544  CV_EXPORTS void equalizeHist(const oclMat &mat_src, oclMat &mat_dst);
545 
547  CV_EXPORTS Ptr<cv::CLAHE> createCLAHE(double clipLimit = 40.0, Size tileGridSize = Size(8, 8));
548 
550  // supports 8UC1 8UC4
551  CV_EXPORTS void bilateralFilter(const oclMat& src, oclMat& dst, int d, double sigmaColor, double sigmaSpace, int borderType=BORDER_DEFAULT);
552 
554  // Unlike the usual bilateral filter that uses fixed value for sigmaColor,
555  // the adaptive version calculates the local variance in he ksize neighborhood
556  // and use this as sigmaColor, for the value filtering. However, the local standard deviation is
557  // clamped to the maxSigmaColor.
558  // supports 8UC1, 8UC3
559  CV_EXPORTS void adaptiveBilateralFilter(const oclMat& src, oclMat& dst, Size ksize, double sigmaSpace, double maxSigmaColor=20.0, Point anchor = Point(-1, -1), int borderType=BORDER_DEFAULT);
560 
562  // supports only CV_32FC1, CV_64FC1 type
563  CV_EXPORTS void exp(const oclMat &src, oclMat &dst);
564 
566  // supports only CV_32FC1, CV_64FC1 type
567  CV_EXPORTS void log(const oclMat &src, oclMat &dst);
568 
570  // supports only CV_32F, CV_64F type
571  CV_EXPORTS void magnitude(const oclMat &x, const oclMat &y, oclMat &magnitude);
572 
574  // supports only CV_32F, CV_64F type
575  CV_EXPORTS void phase(const oclMat &x, const oclMat &y, oclMat &angle, bool angleInDegrees = false);
576 
578  // support only CV_32F, CV_64F type
579  CV_EXPORTS void pow(const oclMat &x, double p, oclMat &y);
580 
582  // supports only CV_32F CV_64F type
583  CV_EXPORTS void cartToPolar(const oclMat &x, const oclMat &y, oclMat &magnitude, oclMat &angle, bool angleInDegrees = false);
584 
586  // supports only CV_32F CV_64F type
587  CV_EXPORTS void polarToCart(const oclMat &magnitude, const oclMat &angle, oclMat &x, oclMat &y, bool angleInDegrees = false);
588 
590  // supports all types
591  CV_EXPORTS void bitwise_not(const oclMat &src, oclMat &dst);
592 
594  // supports all types
595  CV_EXPORTS void bitwise_or(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask = oclMat());
596  CV_EXPORTS void bitwise_or(const oclMat &src1, const Scalar &s, oclMat &dst, const oclMat &mask = oclMat());
597 
599  // supports all types
600  CV_EXPORTS void bitwise_and(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask = oclMat());
601  CV_EXPORTS void bitwise_and(const oclMat &src1, const Scalar &s, oclMat &dst, const oclMat &mask = oclMat());
602 
604  // supports all types
605  CV_EXPORTS void bitwise_xor(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask = oclMat());
606  CV_EXPORTS void bitwise_xor(const oclMat &src1, const Scalar &s, oclMat &dst, const oclMat &mask = oclMat());
607 
609  CV_EXPORTS oclMat operator ~ (const oclMat &);
610  CV_EXPORTS oclMat operator | (const oclMat &, const oclMat &);
611  CV_EXPORTS oclMat operator & (const oclMat &, const oclMat &);
612  CV_EXPORTS oclMat operator ^ (const oclMat &, const oclMat &);
613 
614 
616  CV_EXPORTS oclMatExpr operator + (const oclMat &src1, const oclMat &src2);
617  CV_EXPORTS oclMatExpr operator - (const oclMat &src1, const oclMat &src2);
618  CV_EXPORTS oclMatExpr operator * (const oclMat &src1, const oclMat &src2);
619  CV_EXPORTS oclMatExpr operator / (const oclMat &src1, const oclMat &src2);
620 
622  // support only CV_32FC1 type
623  CV_EXPORTS void convolve(const oclMat &image, const oclMat &temp1, oclMat &result);
624 
625  CV_EXPORTS void cvtColor(const oclMat &src, oclMat &dst, int code, int dcn = 0);
626 
628  CV_EXPORTS void setIdentity(oclMat& src, const Scalar & val = Scalar(1));
629 
631  CV_EXPORTS void repeat(const oclMat & src, int ny, int nx, oclMat & dst);
632 
634 
641  class CV_EXPORTS BaseRowFilter_GPU
642  {
643  public:
644  BaseRowFilter_GPU(int ksize_, int anchor_, int bordertype_) : ksize(ksize_), anchor(anchor_), bordertype(bordertype_) {}
645  virtual ~BaseRowFilter_GPU() {}
646  virtual void operator()(const oclMat &src, oclMat &dst) = 0;
647  int ksize, anchor, bordertype;
648  };
649 
656  class CV_EXPORTS BaseColumnFilter_GPU
657  {
658  public:
659  BaseColumnFilter_GPU(int ksize_, int anchor_, int bordertype_) : ksize(ksize_), anchor(anchor_), bordertype(bordertype_) {}
661  virtual void operator()(const oclMat &src, oclMat &dst) = 0;
662  int ksize, anchor, bordertype;
663  };
664 
670  class CV_EXPORTS BaseFilter_GPU
671  {
672  public:
673  BaseFilter_GPU(const Size &ksize_, const Point &anchor_, const int &borderType_)
674  : ksize(ksize_), anchor(anchor_), borderType(borderType_) {}
675  virtual ~BaseFilter_GPU() {}
676  virtual void operator()(const oclMat &src, oclMat &dst) = 0;
680  };
681 
688  class CV_EXPORTS FilterEngine_GPU
689  {
690  public:
691  virtual ~FilterEngine_GPU() {}
692 
693  virtual void apply(const oclMat &src, oclMat &dst, Rect roi = Rect(0, 0, -1, -1)) = 0;
694  };
695 
698 
700  CV_EXPORTS Ptr<BaseRowFilter_GPU> getLinearRowFilter_GPU(int srcType, int bufType, const Mat &rowKernel,
701  int anchor = -1, int bordertype = BORDER_DEFAULT);
702 
704  CV_EXPORTS Ptr<BaseColumnFilter_GPU> getLinearColumnFilter_GPU(int bufType, int dstType, const Mat &columnKernel,
705  int anchor = -1, int bordertype = BORDER_DEFAULT, double delta = 0.0);
706 
708  CV_EXPORTS Ptr<FilterEngine_GPU> createSeparableLinearFilter_GPU(int srcType, int dstType, const Mat &rowKernel,
709  const Mat &columnKernel, const Point &anchor = Point(-1, -1), double delta = 0.0, int bordertype = BORDER_DEFAULT, Size imgSize = Size(-1,-1));
710 
713  const Ptr<BaseColumnFilter_GPU> &columnFilter);
714 
716  CV_EXPORTS Ptr<FilterEngine_GPU> createGaussianFilter_GPU(int type, Size ksize, double sigma1, double sigma2 = 0, int bordertype = BORDER_DEFAULT, Size imgSize = Size(-1,-1));
717 
719  CV_EXPORTS Ptr<FilterEngine_GPU> createDerivFilter_GPU( int srcType, int dstType, int dx, int dy, int ksize, int borderType = BORDER_DEFAULT, Size imgSize = Size(-1,-1) );
720 
722  // supports only ksize = 1 and ksize = 3
723  CV_EXPORTS void Laplacian(const oclMat &src, oclMat &dst, int ddepth, int ksize = 1, double scale = 1,
724  double delta=0, int borderType=BORDER_DEFAULT);
725 
727  // dst type must be the same as source type
728  CV_EXPORTS Ptr<BaseFilter_GPU> getBoxFilter_GPU(int srcType, int dstType,
729  const Size &ksize, Point anchor = Point(-1, -1), int borderType = BORDER_DEFAULT);
730 
732  CV_EXPORTS Ptr<FilterEngine_GPU> createBoxFilter_GPU(int srcType, int dstType, const Size &ksize,
733  const Point &anchor = Point(-1, -1), int borderType = BORDER_DEFAULT);
734 
736  // supports: dst type must be the same as source type
737  CV_EXPORTS Ptr<BaseFilter_GPU> getLinearFilter_GPU(int srcType, int dstType, const Mat &kernel, const Size &ksize,
738  const Point &anchor = Point(-1, -1), int borderType = BORDER_DEFAULT);
739 
741  // supports: dst type must be the same as source type
742  CV_EXPORTS Ptr<FilterEngine_GPU> createLinearFilter_GPU(int srcType, int dstType, const Mat &kernel,
743  const Point &anchor = Point(-1, -1), int borderType = BORDER_DEFAULT);
744 
746  CV_EXPORTS void boxFilter(const oclMat &src, oclMat &dst, int ddepth, Size ksize,
747  Point anchor = Point(-1, -1), int borderType = BORDER_DEFAULT);
748 
751  // supports CV_8UC1, CV_8UC4, CV_32FC1 and CV_32FC4 types
752  // kernel must have CV_8UC1 type, one rows and cols == ksize.width * ksize.height
753  CV_EXPORTS Ptr<BaseFilter_GPU> getMorphologyFilter_GPU(int op, int type, const Mat &kernel, const Size &ksize,
754  Point anchor = Point(-1, -1));
755 
757  CV_EXPORTS Ptr<FilterEngine_GPU> createMorphologyFilter_GPU(int op, int type, const Mat &kernel,
758  const Point &anchor = Point(-1, -1), int iterations = 1);
759 
761  static inline void blur(const oclMat &src, oclMat &dst, Size ksize, Point anchor = Point(-1, -1),
762  int borderType = BORDER_CONSTANT)
763  {
764  boxFilter(src, dst, -1, ksize, anchor, borderType);
765  }
766 
768  CV_EXPORTS void filter2D(const oclMat &src, oclMat &dst, int ddepth, const Mat &kernel,
769  Point anchor = Point(-1, -1), double delta = 0.0, int borderType = BORDER_DEFAULT);
770 
772  CV_EXPORTS void sepFilter2D(const oclMat &src, oclMat &dst, int ddepth, const Mat &kernelX, const Mat &kernelY,
773  Point anchor = Point(-1, -1), double delta = 0.0, int bordertype = BORDER_DEFAULT);
774 
776  // dst.type must equalize src.type
777  // supports data type: CV_8UC1, CV_8UC4, CV_32FC1 and CV_32FC4
778  // supports border type: BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT,BORDER_REFLECT_101
779  CV_EXPORTS void Sobel(const oclMat &src, oclMat &dst, int ddepth, int dx, int dy, int ksize = 3, double scale = 1, double delta = 0.0, int bordertype = BORDER_DEFAULT);
780 
782  // dst.type must equalize src.type
783  // supports data type: CV_8UC1, CV_8UC4, CV_32FC1 and CV_32FC4
784  // supports border type: BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT,BORDER_REFLECT_101
785  CV_EXPORTS void Scharr(const oclMat &src, oclMat &dst, int ddepth, int dx, int dy, double scale = 1, double delta = 0.0, int bordertype = BORDER_DEFAULT);
786 
788  // dst.type must equalize src.type
789  // supports data type: CV_8UC1, CV_8UC4, CV_32FC1 and CV_32FC4
790  // supports border type: BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT,BORDER_REFLECT_101
791  CV_EXPORTS void GaussianBlur(const oclMat &src, oclMat &dst, Size ksize, double sigma1, double sigma2 = 0, int bordertype = BORDER_DEFAULT);
792 
794  // supports data type: CV_8UC1, CV_8UC4, CV_32FC1 and CV_32FC4
795  CV_EXPORTS void erode( const oclMat &src, oclMat &dst, const Mat &kernel, Point anchor = Point(-1, -1), int iterations = 1,
796 
797  int borderType = BORDER_CONSTANT, const Scalar &borderValue = morphologyDefaultBorderValue());
798 
799 
801  // supports data type: CV_8UC1, CV_8UC4, CV_32FC1 and CV_32FC4
802  CV_EXPORTS void dilate( const oclMat &src, oclMat &dst, const Mat &kernel, Point anchor = Point(-1, -1), int iterations = 1,
803 
804  int borderType = BORDER_CONSTANT, const Scalar &borderValue = morphologyDefaultBorderValue());
805 
806 
808  CV_EXPORTS void morphologyEx( const oclMat &src, oclMat &dst, int op, const Mat &kernel, Point anchor = Point(-1, -1), int iterations = 1,
809 
810  int borderType = BORDER_CONSTANT, const Scalar &borderValue = morphologyDefaultBorderValue());
811 
812 
815  CV_EXPORTS void meanShiftFiltering(const oclMat &src, oclMat &dst, int sp, int sr,
816  TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
817 
819  CV_EXPORTS void meanShiftProc(const oclMat &src, oclMat &dstr, oclMat &dstsp, int sp, int sr,
820  TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
821 
823  CV_EXPORTS void meanShiftSegmentation(const oclMat &src, Mat &dst, int sp, int sr, int minsize,
824  TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
825 
827  // supports CV_8UC1 and CV_32FC1 data type
828  // supports threshold type: THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV
829  CV_EXPORTS double threshold(const oclMat &src, oclMat &dst, double thresh, double maxVal, int type = THRESH_TRUNC);
830 
832  // Supports INTER_NEAREST, INTER_LINEAR
833  // supports CV_8UC1, CV_8UC4, CV_32FC1 and CV_32FC4 types
834  CV_EXPORTS void resize(const oclMat &src, oclMat &dst, Size dsize, double fx = 0, double fy = 0, int interpolation = INTER_LINEAR);
835 
837 
838  // Supports INTER_NEAREST, INTER_LINEAR.
839  // Map1 supports CV_16SC2, CV_32FC2 types.
840  // Src supports CV_8UC1, CV_8UC2, CV_8UC4.
841  CV_EXPORTS void remap(const oclMat &src, oclMat &dst, oclMat &map1, oclMat &map2, int interpolation, int bordertype, const Scalar &value = Scalar());
842 
844  // supports CV_8UC1, CV_8UC4, CV_32SC1 types
845  CV_EXPORTS void copyMakeBorder(const oclMat &src, oclMat &dst, int top, int bottom, int left, int right, int boardtype, const Scalar &value = Scalar());
846 
848  // The source 1- or 4-channel image. m should be 3 or 5, the image depth should be CV_8U or CV_32F.
849  CV_EXPORTS void medianFilter(const oclMat &src, oclMat &dst, int m);
850 
852  // Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
853  // supports CV_8UC1, CV_8UC4, CV_32FC1 and CV_32FC4 types
854  CV_EXPORTS void warpAffine(const oclMat &src, oclMat &dst, const Mat &M, Size dsize, int flags = INTER_LINEAR);
855 
857  // Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
858  // supports CV_8UC1, CV_8UC4, CV_32FC1 and CV_32FC4 types
859  CV_EXPORTS void warpPerspective(const oclMat &src, oclMat &dst, const Mat &M, Size dsize, int flags = INTER_LINEAR);
860 
862  // sum will have CV_32S type, sqsum - CV32F type
863  // supports only CV_8UC1 source type
864  CV_EXPORTS void integral(const oclMat &src, oclMat &sum, oclMat &sqsum);
865  CV_EXPORTS void integral(const oclMat &src, oclMat &sum);
866  CV_EXPORTS void cornerHarris(const oclMat &src, oclMat &dst, int blockSize, int ksize, double k, int bordertype = cv::BORDER_DEFAULT);
867  CV_EXPORTS void cornerHarris_dxdy(const oclMat &src, oclMat &dst, oclMat &Dx, oclMat &Dy,
868  int blockSize, int ksize, double k, int bordertype = cv::BORDER_DEFAULT);
869  CV_EXPORTS void cornerMinEigenVal(const oclMat &src, oclMat &dst, int blockSize, int ksize, int bordertype = cv::BORDER_DEFAULT);
870  CV_EXPORTS void cornerMinEigenVal_dxdy(const oclMat &src, oclMat &dst, oclMat &Dx, oclMat &Dy,
871  int blockSize, int ksize, int bordertype = cv::BORDER_DEFAULT);
873 
875  // supports CV_32FC1/CV_32FC2/CV_32FC4 data type
876  // supports NORM_L1 and NORM_L2 distType
877  // if indices is provided, only the indexed rows will be calculated and their results are in the same
878  // order of indices
879  CV_EXPORTS void distanceToCenters(const oclMat &src, const oclMat &centers, Mat &dists, Mat &labels, int distType = NORM_L2SQR);
880 
882  // supports CV_32FC1/CV_32FC2/CV_32FC4 data type
883  CV_EXPORTS double kmeans(const oclMat &src, int K, oclMat &bestLabels,
884  TermCriteria criteria, int attemps, int flags, oclMat &centers);
885 
886 
890 
891  class CV_EXPORTS_W OclCascadeClassifier : public cv::CascadeClassifier
892  {
893  public:
896 
897  CvSeq* oclHaarDetectObjects(oclMat &gimg, CvMemStorage *storage, double scaleFactor,
898  int minNeighbors, int flags, CvSize minSize = cvSize(0, 0), CvSize maxSize = cvSize(0, 0));
899  void detectMultiScale(oclMat &image, CV_OUT std::vector<cv::Rect>& faces,
900  double scaleFactor = 1.1, int minNeighbors = 3, int flags = 0,
901  Size minSize = Size(), Size maxSize = Size());
902  };
903 
905  {
906  public:
908  m_flags(0), initialized(false), m_scaleFactor(0), buffers(NULL) {}
909 
910  ~OclCascadeClassifierBuf() { release(); }
911 
912  void detectMultiScale(oclMat &image, CV_OUT std::vector<cv::Rect>& faces,
913  double scaleFactor = 1.1, int minNeighbors = 3, int flags = 0,
914  Size minSize = Size(), Size maxSize = Size());
915  void release();
916 
917  private:
918  void Init(const int rows, const int cols, double scaleFactor, int flags,
919  const int outputsz, const size_t localThreads[],
920  CvSize minSize, CvSize maxSize);
921  void CreateBaseBufs(const int datasize, const int totalclassifier, const int flags, const int outputsz);
922  void CreateFactorRelatedBufs(const int rows, const int cols, const int flags,
923  const double scaleFactor, const size_t localThreads[],
924  CvSize minSize, CvSize maxSize);
925  void GenResult(CV_OUT std::vector<cv::Rect>& faces, const std::vector<cv::Rect> &rectList, const std::vector<int> &rweights);
926 
927  int m_rows;
928  int m_cols;
929  int m_flags;
930  int m_loopcount;
931  int m_nodenum;
932  bool findBiggestObject;
933  bool initialized;
934  double m_scaleFactor;
935  Size m_minSize;
936  Size m_maxSize;
937  vector<CvSize> sizev;
938  vector<float> scalev;
939  oclMat gimg1, gsum, gsqsum;
940  void * buffers;
941  };
942 
943 
945  CV_EXPORTS void pyrDown(const oclMat &src, oclMat &dst);
946 
948  CV_EXPORTS void pyrUp(const oclMat &src, oclMat &dst);
949 
952  // supports only CV_8UC1 source type
953  CV_EXPORTS void blendLinear(const oclMat &img1, const oclMat &img2, const oclMat &weights1, const oclMat &weights2, oclMat &result);
954 
956  CV_EXPORTS void columnSum(const oclMat &src, oclMat &sum);
957 
959  struct CV_EXPORTS MatchTemplateBuf
960  {
962  oclMat imagef, templf;
963  std::vector<oclMat> images;
964  std::vector<oclMat> image_sums;
965  std::vector<oclMat> image_sqsums;
966  };
967 
969  // Supports TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_CCOEFF, TM_CCOEFF_NORMED for type 8UC1 and 8UC4
970  // Supports TM_SQDIFF, TM_CCORR for type 32FC1 and 32FC4
971  CV_EXPORTS void matchTemplate(const oclMat &image, const oclMat &templ, oclMat &result, int method);
972 
974  // Supports TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_CCOEFF, TM_CCOEFF_NORMED for type 8UC1 and 8UC4
975  // Supports TM_SQDIFF, TM_CCORR for type 32FC1 and 32FC4
976  CV_EXPORTS void matchTemplate(const oclMat &image, const oclMat &templ, oclMat &result, int method, MatchTemplateBuf &buf);
977 
979  struct CV_EXPORTS CannyBuf;
981  // Support CV_8UC1 only
982  CV_EXPORTS void Canny(const oclMat &image, oclMat &edges, double low_thresh, double high_thresh, int apperture_size = 3, bool L2gradient = false);
983  CV_EXPORTS void Canny(const oclMat &image, CannyBuf &buf, oclMat &edges, double low_thresh, double high_thresh, int apperture_size = 3, bool L2gradient = false);
984  CV_EXPORTS void Canny(const oclMat &dx, const oclMat &dy, oclMat &edges, double low_thresh, double high_thresh, bool L2gradient = false);
985  CV_EXPORTS void Canny(const oclMat &dx, const oclMat &dy, CannyBuf &buf, oclMat &edges, double low_thresh, double high_thresh, bool L2gradient = false);
986 
987  struct CV_EXPORTS CannyBuf
988  {
989  CannyBuf() : counter(1, 1, CV_32S) { }
991  {
992  release();
993  }
994  explicit CannyBuf(const Size &image_size, int apperture_size = 3) : counter(1, 1, CV_32S)
995  {
996  create(image_size, apperture_size);
997  }
998  CannyBuf(const oclMat &dx_, const oclMat &dy_);
999 
1000  void create(const Size &image_size, int apperture_size = 3);
1001  void release();
1002  oclMat dx, dy;
1003  oclMat dx_buf, dy_buf;
1005  oclMat trackBuf1, trackBuf2;
1008  };
1009 
1015  // support src type of CV32FC1, CV32FC2
1016  // support flags: DFT_INVERSE, DFT_REAL_OUTPUT, DFT_COMPLEX_OUTPUT, DFT_ROWS
1017  // dft_size is the size of original input, which is used for transformation from complex to real.
1018  // dft_size must be powers of 2, 3 and 5
1019  // real to complex dft requires at least v1.8 clAmdFft
1020  // real to complex dft output is not the same with cpu version
1021  // real to complex and complex to real does not support DFT_ROWS
1022  CV_EXPORTS void dft(const oclMat &src, oclMat &dst, Size dft_size = Size(), int flags = 0);
1023 
1025  // The functionality requires clAmdBlas library
1026  // only support type CV_32FC1
1027  // flag GEMM_3_T is not supported
1028  CV_EXPORTS void gemm(const oclMat &src1, const oclMat &src2, double alpha,
1029  const oclMat &src3, double beta, oclMat &dst, int flags = 0);
1030 
1032  struct CV_EXPORTS HOGDescriptor
1033  {
1034  enum { DEFAULT_WIN_SIGMA = -1 };
1035  enum { DEFAULT_NLEVELS = 64 };
1036  enum { DESCR_FORMAT_ROW_BY_ROW, DESCR_FORMAT_COL_BY_COL };
1037  HOGDescriptor(Size win_size = Size(64, 128), Size block_size = Size(16, 16),
1038  Size block_stride = Size(8, 8), Size cell_size = Size(8, 8),
1039  int nbins = 9, double win_sigma = DEFAULT_WIN_SIGMA,
1040  double threshold_L2hys = 0.2, bool gamma_correction = true,
1041  int nlevels = DEFAULT_NLEVELS);
1042 
1043  size_t getDescriptorSize() const;
1044  size_t getBlockHistogramSize() const;
1045  void setSVMDetector(const vector<float> &detector);
1046  static vector<float> getDefaultPeopleDetector();
1047  static vector<float> getPeopleDetector48x96();
1048  static vector<float> getPeopleDetector64x128();
1049  void detect(const oclMat &img, vector<Point> &found_locations,
1050  double hit_threshold = 0, Size win_stride = Size(),
1051  Size padding = Size());
1052  void detectMultiScale(const oclMat &img, vector<Rect> &found_locations,
1053  double hit_threshold = 0, Size win_stride = Size(),
1054  Size padding = Size(), double scale0 = 1.05,
1055  int group_threshold = 2);
1056  void getDescriptors(const oclMat &img, Size win_stride,
1058  int descr_format = DESCR_FORMAT_COL_BY_COL);
1063 
1064  int nbins;
1065  double win_sigma;
1068  int nlevels;
1069 
1070  protected:
1071  // initialize buffers; only need to do once in case of multiscale detection
1072  void init_buffer(const oclMat &img, Size win_stride);
1073  void computeBlockHistograms(const oclMat &img);
1074  void computeGradient(const oclMat &img, oclMat &grad, oclMat &qangle);
1075  double getWinSigma() const;
1076  bool checkDetectorSize() const;
1077 
1078  static int numPartsWithin(int size, int part_size, int stride);
1079  static Size numPartsWithin(Size size, Size part_size, Size stride);
1080 
1081  // Coefficients of the separating plane
1082  float free_coef;
1084  // Results of the last classification step
1087  // Results of the last histogram evaluation step
1089  // Gradients conputation results
1091  // scaled image
1093  // effect size of input image (might be different from original size after scaling)
1095  };
1096 
1097 
1099  /****************************************************************************************\
1100  * Distance *
1101  \****************************************************************************************/
1102  template<typename T>
1103  struct CV_EXPORTS Accumulator
1104  {
1105  typedef T Type;
1106  };
1107  template<> struct Accumulator<unsigned char>
1108  {
1109  typedef float Type;
1110  };
1111  template<> struct Accumulator<unsigned short>
1112  {
1113  typedef float Type;
1114  };
1115  template<> struct Accumulator<char>
1116  {
1117  typedef float Type;
1118  };
1119  template<> struct Accumulator<short>
1120  {
1121  typedef float Type;
1122  };
1123 
1124  /*
1125  * Manhattan distance (city block distance) functor
1126  */
1127  template<class T>
1128  struct CV_EXPORTS L1
1129  {
1130  enum { normType = NORM_L1 };
1131  typedef T ValueType;
1133 
1134  ResultType operator()( const T *a, const T *b, int size ) const
1135  {
1136  return normL1<ValueType, ResultType>(a, b, size);
1137  }
1138  };
1139 
1140  /*
1141  * Euclidean distance functor
1142  */
1143  template<class T>
1144  struct CV_EXPORTS L2
1145  {
1146  enum { normType = NORM_L2 };
1147  typedef T ValueType;
1149 
1150  ResultType operator()( const T *a, const T *b, int size ) const
1151  {
1152  return (ResultType)sqrt((double)normL2Sqr<ValueType, ResultType>(a, b, size));
1153  }
1154  };
1155 
1156  /*
1157  * Hamming distance functor - counts the bit differences between two strings - useful for the Brief descriptor
1158  * bit count of A exclusive XOR'ed with B
1159  */
1160  struct CV_EXPORTS Hamming
1161  {
1162  enum { normType = NORM_HAMMING };
1163  typedef unsigned char ValueType;
1164  typedef int ResultType;
1165 
1168  ResultType operator()( const unsigned char *a, const unsigned char *b, int size ) const
1169  {
1170  return normHamming(a, b, size);
1171  }
1172  };
1173 
1175 
1177  {
1178  public:
1179  enum DistType {L1Dist = 0, L2Dist, HammingDist};
1180  explicit BruteForceMatcher_OCL_base(DistType distType = L2Dist);
1181  // Add descriptors to train descriptor collection
1182  void add(const std::vector<oclMat> &descCollection);
1183  // Get train descriptors collection
1184  const std::vector<oclMat> &getTrainDescriptors() const;
1185  // Clear train descriptors collection
1186  void clear();
1187  // Return true if there are not train descriptors in collection
1188  bool empty() const;
1189 
1190  // Return true if the matcher supports mask in match methods
1191  bool isMaskSupported() const;
1192 
1193  // Find one best match for each query descriptor
1194  void matchSingle(const oclMat &query, const oclMat &train,
1195  oclMat &trainIdx, oclMat &distance,
1196  const oclMat &mask = oclMat());
1197 
1198  // Download trainIdx and distance and convert it to CPU vector with DMatch
1199  static void matchDownload(const oclMat &trainIdx, const oclMat &distance, std::vector<DMatch> &matches);
1200  // Convert trainIdx and distance to vector with DMatch
1201  static void matchConvert(const Mat &trainIdx, const Mat &distance, std::vector<DMatch> &matches);
1202 
1203  // Find one best match for each query descriptor
1204  void match(const oclMat &query, const oclMat &train, std::vector<DMatch> &matches, const oclMat &mask = oclMat());
1205 
1206  // Make gpu collection of trains and masks in suitable format for matchCollection function
1207  void makeGpuCollection(oclMat &trainCollection, oclMat &maskCollection, const std::vector<oclMat> &masks = std::vector<oclMat>());
1208 
1209 
1210  // Find one best match from train collection for each query descriptor
1211  void matchCollection(const oclMat &query, const oclMat &trainCollection,
1212  oclMat &trainIdx, oclMat &imgIdx, oclMat &distance,
1213  const oclMat &masks = oclMat());
1214 
1215  // Download trainIdx, imgIdx and distance and convert it to vector with DMatch
1216  static void matchDownload(const oclMat &trainIdx, const oclMat &imgIdx, const oclMat &distance, std::vector<DMatch> &matches);
1217  // Convert trainIdx, imgIdx and distance to vector with DMatch
1218  static void matchConvert(const Mat &trainIdx, const Mat &imgIdx, const Mat &distance, std::vector<DMatch> &matches);
1219 
1220  // Find one best match from train collection for each query descriptor.
1221  void match(const oclMat &query, std::vector<DMatch> &matches, const std::vector<oclMat> &masks = std::vector<oclMat>());
1222 
1223  // Find k best matches for each query descriptor (in increasing order of distances)
1224  void knnMatchSingle(const oclMat &query, const oclMat &train,
1225  oclMat &trainIdx, oclMat &distance, oclMat &allDist, int k,
1226  const oclMat &mask = oclMat());
1227 
1228  // Download trainIdx and distance and convert it to vector with DMatch
1229  // compactResult is used when mask is not empty. If compactResult is false matches
1230  // vector will have the same size as queryDescriptors rows. If compactResult is true
1231  // matches vector will not contain matches for fully masked out query descriptors.
1232  static void knnMatchDownload(const oclMat &trainIdx, const oclMat &distance,
1233  std::vector< std::vector<DMatch> > &matches, bool compactResult = false);
1234 
1235  // Convert trainIdx and distance to vector with DMatch
1236  static void knnMatchConvert(const Mat &trainIdx, const Mat &distance,
1237  std::vector< std::vector<DMatch> > &matches, bool compactResult = false);
1238 
1239  // Find k best matches for each query descriptor (in increasing order of distances).
1240  // compactResult is used when mask is not empty. If compactResult is false matches
1241  // vector will have the same size as queryDescriptors rows. If compactResult is true
1242  // matches vector will not contain matches for fully masked out query descriptors.
1243  void knnMatch(const oclMat &query, const oclMat &train,
1244  std::vector< std::vector<DMatch> > &matches, int k, const oclMat &mask = oclMat(),
1245  bool compactResult = false);
1246 
1247  // Find k best matches from train collection for each query descriptor (in increasing order of distances)
1248  void knnMatch2Collection(const oclMat &query, const oclMat &trainCollection,
1249  oclMat &trainIdx, oclMat &imgIdx, oclMat &distance,
1250  const oclMat &maskCollection = oclMat());
1251 
1252  // Download trainIdx and distance and convert it to vector with DMatch
1253  // compactResult is used when mask is not empty. If compactResult is false matches
1254  // vector will have the same size as queryDescriptors rows. If compactResult is true
1255  // matches vector will not contain matches for fully masked out query descriptors.
1256  static void knnMatch2Download(const oclMat &trainIdx, const oclMat &imgIdx, const oclMat &distance,
1257  std::vector< std::vector<DMatch> > &matches, bool compactResult = false);
1258 
1259  // Convert trainIdx and distance to vector with DMatch
1260  static void knnMatch2Convert(const Mat &trainIdx, const Mat &imgIdx, const Mat &distance,
1261  std::vector< std::vector<DMatch> > &matches, bool compactResult = false);
1262 
1263  // Find k best matches for each query descriptor (in increasing order of distances).
1264  // compactResult is used when mask is not empty. If compactResult is false matches
1265  // vector will have the same size as queryDescriptors rows. If compactResult is true
1266  // matches vector will not contain matches for fully masked out query descriptors.
1267  void knnMatch(const oclMat &query, std::vector< std::vector<DMatch> > &matches, int k,
1268  const std::vector<oclMat> &masks = std::vector<oclMat>(), bool compactResult = false);
1269 
1270  // Find best matches for each query descriptor which have distance less than maxDistance.
1271  // nMatches.at<int>(0, queryIdx) will contain matches count for queryIdx.
1272  // carefully nMatches can be greater than trainIdx.cols - it means that matcher didn't find all matches,
1273  // because it didn't have enough memory.
1274  // If trainIdx is empty, then trainIdx and distance will be created with size nQuery x max((nTrain / 100), 10),
1275  // otherwize user can pass own allocated trainIdx and distance with size nQuery x nMaxMatches
1276  // Matches doesn't sorted.
1277  void radiusMatchSingle(const oclMat &query, const oclMat &train,
1278  oclMat &trainIdx, oclMat &distance, oclMat &nMatches, float maxDistance,
1279  const oclMat &mask = oclMat());
1280 
1281  // Download trainIdx, nMatches and distance and convert it to vector with DMatch.
1282  // matches will be sorted in increasing order of distances.
1283  // compactResult is used when mask is not empty. If compactResult is false matches
1284  // vector will have the same size as queryDescriptors rows. If compactResult is true
1285  // matches vector will not contain matches for fully masked out query descriptors.
1286  static void radiusMatchDownload(const oclMat &trainIdx, const oclMat &distance, const oclMat &nMatches,
1287  std::vector< std::vector<DMatch> > &matches, bool compactResult = false);
1288  // Convert trainIdx, nMatches and distance to vector with DMatch.
1289  static void radiusMatchConvert(const Mat &trainIdx, const Mat &distance, const Mat &nMatches,
1290  std::vector< std::vector<DMatch> > &matches, bool compactResult = false);
1291  // Find best matches for each query descriptor which have distance less than maxDistance
1292  // in increasing order of distances).
1293  void radiusMatch(const oclMat &query, const oclMat &train,
1294  std::vector< std::vector<DMatch> > &matches, float maxDistance,
1295  const oclMat &mask = oclMat(), bool compactResult = false);
1296  // Find best matches for each query descriptor which have distance less than maxDistance.
1297  // If trainIdx is empty, then trainIdx and distance will be created with size nQuery x max((nQuery / 100), 10),
1298  // otherwize user can pass own allocated trainIdx and distance with size nQuery x nMaxMatches
1299  // Matches doesn't sorted.
1300  void radiusMatchCollection(const oclMat &query, oclMat &trainIdx, oclMat &imgIdx, oclMat &distance, oclMat &nMatches, float maxDistance,
1301  const std::vector<oclMat> &masks = std::vector<oclMat>());
1302  // Download trainIdx, imgIdx, nMatches and distance and convert it to vector with DMatch.
1303  // matches will be sorted in increasing order of distances.
1304  // compactResult is used when mask is not empty. If compactResult is false matches
1305  // vector will have the same size as queryDescriptors rows. If compactResult is true
1306  // matches vector will not contain matches for fully masked out query descriptors.
1307  static void radiusMatchDownload(const oclMat &trainIdx, const oclMat &imgIdx, const oclMat &distance, const oclMat &nMatches,
1308  std::vector< std::vector<DMatch> > &matches, bool compactResult = false);
1309  // Convert trainIdx, nMatches and distance to vector with DMatch.
1310  static void radiusMatchConvert(const Mat &trainIdx, const Mat &imgIdx, const Mat &distance, const Mat &nMatches,
1311  std::vector< std::vector<DMatch> > &matches, bool compactResult = false);
1312  // Find best matches from train collection for each query descriptor which have distance less than
1313  // maxDistance (in increasing order of distances).
1314  void radiusMatch(const oclMat &query, std::vector< std::vector<DMatch> > &matches, float maxDistance,
1315  const std::vector<oclMat> &masks = std::vector<oclMat>(), bool compactResult = false);
1317  private:
1318  std::vector<oclMat> trainDescCollection;
1319  };
1320 
1321  template <class Distance>
1322  class CV_EXPORTS BruteForceMatcher_OCL;
1323 
1324  template <typename T>
1326  {
1327  public:
1330  };
1331 
1332  template <typename T>
1334  {
1335  public:
1338  };
1339 
1340  template <> class CV_EXPORTS BruteForceMatcher_OCL< Hamming > : public BruteForceMatcher_OCL_base
1341  {
1342  public:
1345  };
1346 
1347  class CV_EXPORTS BFMatcher_OCL : public BruteForceMatcher_OCL_base
1348  {
1349  public:
1350  explicit BFMatcher_OCL(int norm = NORM_L2) : BruteForceMatcher_OCL_base(norm == NORM_L1 ? L1Dist : norm == NORM_L2 ? L2Dist : HammingDist) {}
1351  };
1352 
1354  {
1355  public:
1356  explicit GoodFeaturesToTrackDetector_OCL(int maxCorners = 1000, double qualityLevel = 0.01, double minDistance = 0.0,
1357  int blockSize = 3, bool useHarrisDetector = false, double harrisK = 0.04);
1358 
1360  void operator ()(const oclMat& image, oclMat& corners, const oclMat& mask = oclMat());
1362  void downloadPoints(const oclMat &points, vector<Point2f> &points_v);
1363 
1366  double minDistance;
1367 
1370  double harrisK;
1372  {
1373  Dx_.release();
1374  Dy_.release();
1375  eig_.release();
1376  minMaxbuf_.release();
1377  tmpCorners_.release();
1378  }
1379  private:
1380  oclMat Dx_;
1381  oclMat Dy_;
1382  oclMat eig_;
1383  oclMat eig_minmax_;
1384  oclMat minMaxbuf_;
1385  oclMat tmpCorners_;
1386  oclMat counter_;
1387  };
1388 
1389  inline GoodFeaturesToTrackDetector_OCL::GoodFeaturesToTrackDetector_OCL(int maxCorners_, double qualityLevel_, double minDistance_,
1390  int blockSize_, bool useHarrisDetector_, double harrisK_)
1391  {
1392  maxCorners = maxCorners_;
1393  qualityLevel = qualityLevel_;
1394  minDistance = minDistance_;
1395  blockSize = blockSize_;
1396  useHarrisDetector = useHarrisDetector_;
1397  harrisK = harrisK_;
1398  }
1399 
1401  class CV_EXPORTS PyrLKOpticalFlow
1402  {
1403  public:
1405  {
1406  winSize = Size(21, 21);
1407  maxLevel = 3;
1408  iters = 30;
1409  derivLambda = 0.5;
1410  useInitialFlow = false;
1411  minEigThreshold = 1e-4f;
1412  getMinEigenVals = false;
1413  isDeviceArch11_ = false;
1414  }
1415 
1416  void sparse(const oclMat &prevImg, const oclMat &nextImg, const oclMat &prevPts, oclMat &nextPts,
1417  oclMat &status, oclMat *err = 0);
1418  void dense(const oclMat &prevImg, const oclMat &nextImg, oclMat &u, oclMat &v, oclMat *err = 0);
1421  int iters;
1422  double derivLambda;
1427  {
1428  dx_calcBuf_.release();
1429  dy_calcBuf_.release();
1430 
1431  prevPyr_.clear();
1432  nextPyr_.clear();
1433 
1434  dx_buf_.release();
1435  dy_buf_.release();
1436  }
1437  private:
1438  void calcSharrDeriv(const oclMat &src, oclMat &dx, oclMat &dy);
1439  void buildImagePyramid(const oclMat &img0, vector<oclMat> &pyr, bool withBorder);
1440 
1441  oclMat dx_calcBuf_;
1442  oclMat dy_calcBuf_;
1443 
1444  vector<oclMat> prevPyr_;
1445  vector<oclMat> nextPyr_;
1446 
1447  oclMat dx_buf_;
1448  oclMat dy_buf_;
1449  oclMat uPyr_[2];
1450  oclMat vPyr_[2];
1451  bool isDeviceArch11_;
1452  };
1453 
1454  class CV_EXPORTS FarnebackOpticalFlow
1455  {
1456  public:
1458 
1460  double pyrScale;
1462  int winSize;
1464  int polyN;
1465  double polySigma;
1466  int flags;
1467 
1468  void operator ()(const oclMat &frame0, const oclMat &frame1, oclMat &flowx, oclMat &flowy);
1469 
1470  void releaseMemory();
1471 
1472  private:
1473  void prepareGaussian(
1474  int n, double sigma, float *g, float *xg, float *xxg,
1475  double &ig11, double &ig03, double &ig33, double &ig55);
1476 
1477  void setPolynomialExpansionConsts(int n, double sigma);
1478 
1479  void updateFlow_boxFilter(
1480  const oclMat& R0, const oclMat& R1, oclMat& flowx, oclMat &flowy,
1481  oclMat& M, oclMat &bufM, int blockSize, bool updateMatrices);
1482 
1483  void updateFlow_gaussianBlur(
1484  const oclMat& R0, const oclMat& R1, oclMat& flowx, oclMat& flowy,
1485  oclMat& M, oclMat &bufM, int blockSize, bool updateMatrices);
1486 
1487  oclMat frames_[2];
1488  oclMat pyrLevel_[2], M_, bufM_, R_[2], blurredFrame_[2];
1489  std::vector<oclMat> pyramid0_, pyramid1_;
1490  };
1491 
1494  CV_EXPORTS void buildWarpPlaneMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat &R, const Mat &T, float scale, oclMat &map_x, oclMat &map_y);
1496  CV_EXPORTS void buildWarpCylindricalMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat &R, float scale, oclMat &map_x, oclMat &map_y);
1498  CV_EXPORTS void buildWarpSphericalMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat &R, float scale, oclMat &map_x, oclMat &map_y);
1500  CV_EXPORTS void buildWarpAffineMaps(const Mat &M, bool inverse, Size dsize, oclMat &xmap, oclMat &ymap);
1501 
1503  CV_EXPORTS void buildWarpPerspectiveMaps(const Mat &M, bool inverse, Size dsize, oclMat &xmap, oclMat &ymap);
1504 
1520  CV_EXPORTS void interpolateFrames(const oclMat &frame0, const oclMat &frame1,
1521  const oclMat &fu, const oclMat &fv,
1522  const oclMat &bu, const oclMat &bv,
1523  float pos, oclMat &newFrame, oclMat &buf);
1524 
1527  CV_EXPORTS Moments ocl_moments(InputArray contour);
1531  CV_EXPORTS Moments ocl_moments(oclMat& src, bool binary);
1532 
1533  class CV_EXPORTS StereoBM_OCL
1534  {
1535  public:
1536  enum { BASIC_PRESET = 0, PREFILTER_XSOBEL = 1 };
1537 
1538  enum { DEFAULT_NDISP = 64, DEFAULT_WINSZ = 19 };
1539 
1541  StereoBM_OCL();
1543  StereoBM_OCL(int preset, int ndisparities = DEFAULT_NDISP, int winSize = DEFAULT_WINSZ);
1544 
1547  void operator() ( const oclMat &left, const oclMat &right, oclMat &disparity);
1548 
1550  // if current GPU will be faster then CPU in this algorithm.
1551  // It queries current active device.
1552  static bool checkIfGpuCallReasonable();
1553 
1554  int preset;
1555  int ndisp;
1556  int winSize;
1557 
1558  // If avergeTexThreshold == 0 => post procesing is disabled
1559  // If avergeTexThreshold != 0 then disparity is set 0 in each point (x,y) where for left image
1560  // SumOfHorizontalGradiensInWindow(x, y, winSize) < (winSize * winSize) * avergeTexThreshold
1561  // i.e. input left image is low textured.
1563  private:
1564  oclMat minSSD, leBuf, riBuf;
1565  };
1566 
1567  class CV_EXPORTS StereoBeliefPropagation
1568  {
1569  public:
1570  enum { DEFAULT_NDISP = 64 };
1571  enum { DEFAULT_ITERS = 5 };
1572  enum { DEFAULT_LEVELS = 5 };
1573  static void estimateRecommendedParams(int width, int height, int &ndisp, int &iters, int &levels);
1574  explicit StereoBeliefPropagation(int ndisp = DEFAULT_NDISP,
1575  int iters = DEFAULT_ITERS,
1576  int levels = DEFAULT_LEVELS,
1577  int msg_type = CV_16S);
1578  StereoBeliefPropagation(int ndisp, int iters, int levels,
1579  float max_data_term, float data_weight,
1580  float max_disc_term, float disc_single_jump,
1581  int msg_type = CV_32F);
1582  void operator()(const oclMat &left, const oclMat &right, oclMat &disparity);
1583  void operator()(const oclMat &data, oclMat &disparity);
1584  int ndisp;
1585  int iters;
1586  int levels;
1592  private:
1593  oclMat u, d, l, r, u2, d2, l2, r2;
1594  std::vector<oclMat> datas;
1595  oclMat out;
1596  };
1597 
1598  class CV_EXPORTS StereoConstantSpaceBP
1599  {
1600  public:
1601  enum { DEFAULT_NDISP = 128 };
1602  enum { DEFAULT_ITERS = 8 };
1603  enum { DEFAULT_LEVELS = 4 };
1604  enum { DEFAULT_NR_PLANE = 4 };
1605  static void estimateRecommendedParams(int width, int height, int &ndisp, int &iters, int &levels, int &nr_plane);
1606  explicit StereoConstantSpaceBP(
1607  int ndisp = DEFAULT_NDISP,
1608  int iters = DEFAULT_ITERS,
1609  int levels = DEFAULT_LEVELS,
1610  int nr_plane = DEFAULT_NR_PLANE,
1611  int msg_type = CV_32F);
1612  StereoConstantSpaceBP(int ndisp, int iters, int levels, int nr_plane,
1613  float max_data_term, float data_weight, float max_disc_term, float disc_single_jump,
1614  int min_disp_th = 0,
1615  int msg_type = CV_32F);
1616  void operator()(const oclMat &left, const oclMat &right, oclMat &disparity);
1617  int ndisp;
1618  int iters;
1619  int levels;
1628  private:
1629  oclMat u[2], d[2], l[2], r[2];
1630  oclMat disp_selected_pyr[2];
1631  oclMat data_cost;
1632  oclMat data_cost_selected;
1633  oclMat temp;
1634  oclMat out;
1635  };
1636 
1637  // Implementation of the Zach, Pock and Bischof Dual TV-L1 Optical Flow method
1638  //
1639  // see reference:
1640  // [1] C. Zach, T. Pock and H. Bischof, "A Duality Based Approach for Realtime TV-L1 Optical Flow".
1641  // [2] Javier Sanchez, Enric Meinhardt-Llopis and Gabriele Facciolo. "TV-L1 Optical Flow Estimation".
1642  class CV_EXPORTS OpticalFlowDual_TVL1_OCL
1643  {
1644  public:
1646 
1647  void operator ()(const oclMat& I0, const oclMat& I1, oclMat& flowx, oclMat& flowy);
1648 
1649  void collectGarbage();
1650 
1654  double tau;
1655 
1662  double lambda;
1663 
1670  double theta;
1671 
1675  int nscales;
1676 
1683  int warps;
1684 
1689  double epsilon;
1690 
1695 
1697 
1698  private:
1699  void procOneScale(const oclMat& I0, const oclMat& I1, oclMat& u1, oclMat& u2);
1700 
1701  std::vector<oclMat> I0s;
1702  std::vector<oclMat> I1s;
1703  std::vector<oclMat> u1s;
1704  std::vector<oclMat> u2s;
1705 
1706  oclMat I1x_buf;
1707  oclMat I1y_buf;
1708 
1709  oclMat I1w_buf;
1710  oclMat I1wx_buf;
1711  oclMat I1wy_buf;
1712 
1713  oclMat grad_buf;
1714  oclMat rho_c_buf;
1715 
1716  oclMat p11_buf;
1717  oclMat p12_buf;
1718  oclMat p21_buf;
1719  oclMat p22_buf;
1720 
1721  oclMat diff_buf;
1722  oclMat norm_buf;
1723  };
1724  // current supported sorting methods
1725  enum
1726  {
1727  SORT_BITONIC, // only support power-of-2 buffer size
1728  SORT_SELECTION, // cannot sort duplicate keys
1730  SORT_RADIX // only support signed int/float keys(CV_32S/CV_32F)
1731  };
1733  //
1734  // The element unit in the values to be sorted is determined from the data type,
1735  // i.e., a CV_32FC2 input {a1a2, b1b2} will be considered as two elements, regardless its
1736  // matrix dimension.
1737  // both keys and values will be sorted inplace
1738  // Key needs to be single channel oclMat.
1739  //
1740  // Example:
1741  // input -
1742  // keys = {2, 3, 1} (CV_8UC1)
1743  // values = {10,5, 4,3, 6,2} (CV_8UC2)
1744  // sortByKey(keys, values, SORT_SELECTION, false);
1745  // output -
1746  // keys = {1, 2, 3} (CV_8UC1)
1747  // values = {6,2, 10,5, 4,3} (CV_8UC2)
1748  CV_EXPORTS void sortByKey(oclMat& keys, oclMat& values, int method, bool isGreaterThan = false);
1750  class CV_EXPORTS BackgroundSubtractor
1751  {
1752  public:
1754  virtual ~BackgroundSubtractor();
1756  virtual void operator()(const oclMat& image, oclMat& fgmask, float learningRate);
1757 
1759  virtual void getBackgroundImage(oclMat& backgroundImage) const = 0;
1760  };
1770  class CV_EXPORTS MOG: public cv::ocl::BackgroundSubtractor
1771  {
1772  public:
1774  MOG(int nmixtures = -1);
1775 
1777  void initialize(Size frameSize, int frameType);
1778 
1780  void operator()(const oclMat& frame, oclMat& fgmask, float learningRate = 0.f);
1781 
1783  void getBackgroundImage(oclMat& backgroundImage) const;
1784 
1786  void release();
1787 
1788  int history;
1791  float noiseSigma;
1792 
1793  private:
1794  int nmixtures_;
1795 
1796  Size frameSize_;
1797  int frameType_;
1798  int nframes_;
1799 
1800  oclMat weight_;
1801  oclMat sortKey_;
1802  oclMat mean_;
1803  oclMat var_;
1804  };
1805 
1813  class CV_EXPORTS MOG2: public cv::ocl::BackgroundSubtractor
1814  {
1815  public:
1817  MOG2(int nmixtures = -1);
1818 
1820  void initialize(Size frameSize, int frameType);
1821 
1823  void operator()(const oclMat& frame, oclMat& fgmask, float learningRate = -1.0f);
1824 
1826  void getBackgroundImage(oclMat& backgroundImage) const;
1827 
1829  void release();
1830 
1831  // parameters
1832  // you should call initialize after parameters changes
1833 
1834  int history;
1835 
1839  // threshold on the squared Mahalanobis distance to decide if it is well described
1840  // by the background model or not. Related to Cthr from the paper.
1841  // This does not influence the update of the background. A typical value could be 4 sigma
1842  // and that is varThreshold=4*4=16; Corresponds to Tb in the paper.
1843 
1845  // less important parameters - things you might change but be carefull
1847 
1849  // corresponds to fTB=1-cf from the paper
1850  // TB - threshold when the component becomes significant enough to be included into
1851  // the background model. It is the TB=1-cf from the paper. So I use cf=0.1 => TB=0.
1852  // For alpha=0.001 it means that the mode should exist for approximately 105 frames before
1853  // it is considered foreground
1854  // float noiseSigma;
1856 
1857  //correspondts to Tg - threshold on the squared Mahalan. dist. to decide
1858  //when a sample is close to the existing components. If it is not close
1859  //to any a new component will be generated. I use 3 sigma => Tg=3*3=9.
1860  //Smaller Tg leads to more generated components and higher Tg might make
1861  //lead to small number of components but they can grow too large
1862  float fVarInit;
1863  float fVarMin;
1864  float fVarMax;
1865 
1866  //initial variance for the newly generated components.
1867  //It will will influence the speed of adaptation. A good guess should be made.
1868  //A simple way is to estimate the typical standard deviation from the images.
1869  //I used here 10 as a reasonable value
1870  // min and max can be used to further control the variance
1871  float fCT; //CT - complexity reduction prior
1872  //this is related to the number of samples needed to accept that a component
1873  //actually exists. We use CT=0.05 of all the samples. By setting CT=0 you get
1874  //the standard Stauffer&Grimson algorithm (maybe not exact but very similar)
1875 
1876  //shadow detection parameters
1877  bool bShadowDetection; //default 1 - do shadow detection
1878  unsigned char nShadowDetection; //do shadow detection - insert this value as the detection result - 127 default value
1879  float fTau;
1880  // Tau - shadow threshold. The shadow is detected if the pixel is darker
1881  //version of the background. Tau is a threshold on how much darker the shadow can be.
1882  //Tau= 0.5 means that if pixel is more than 2 times darker then it is not shadow
1883  //See: Prati,Mikic,Trivedi,Cucchiarra,"Detecting Moving Shadows...",IEEE PAMI,2003.
1884 
1885  private:
1886  int nmixtures_;
1887 
1888  Size frameSize_;
1889  int frameType_;
1890  int nframes_;
1891 
1892  oclMat weight_;
1893  oclMat variance_;
1894  oclMat mean_;
1895 
1896  oclMat bgmodelUsedModes_; //keep track of number of modes per pixel
1897  };
1898 
1899  /*!***************Kalman Filter*************!*/
1900  class CV_EXPORTS KalmanFilter
1901  {
1902  public:
1903  KalmanFilter();
1905  KalmanFilter(int dynamParams, int measureParams, int controlParams=0, int type=CV_32F);
1907  void init(int dynamParams, int measureParams, int controlParams=0, int type=CV_32F);
1908 
1909  const oclMat& predict(const oclMat& control=oclMat());
1910  const oclMat& correct(const oclMat& measurement);
1911 
1922  private:
1923  oclMat temp1;
1924  oclMat temp2;
1925  oclMat temp3;
1926  oclMat temp4;
1927  oclMat temp5;
1928  };
1929 
1930  /*!***************K Nearest Neighbour*************!*/
1931  class CV_EXPORTS KNearestNeighbour: public CvKNearest
1932  {
1933  public:
1935  ~KNearestNeighbour();
1936 
1937  bool train(const Mat& trainData, Mat& labels, Mat& sampleIdx = Mat().setTo(Scalar::all(0)),
1938  bool isRegression = false, int max_k = 32, bool updateBase = false);
1939 
1940  void clear();
1941 
1942  void find_nearest(const oclMat& samples, int k, oclMat& lables);
1943 
1944  private:
1945  oclMat samples_ocl;
1946  };
1947 
1948  /*!*************** SVM *************!*/
1949  class CV_EXPORTS CvSVM_OCL : public CvSVM
1950  {
1951  public:
1952  CvSVM_OCL();
1953 
1954  CvSVM_OCL(const cv::Mat& trainData, const cv::Mat& responses,
1955  const cv::Mat& varIdx=cv::Mat(), const cv::Mat& sampleIdx=cv::Mat(),
1957  CV_WRAP float predict( const int row_index, Mat& src, bool returnDFVal=false ) const;
1958  CV_WRAP void predict( cv::InputArray samples, cv::OutputArray results ) const;
1959  CV_WRAP float predict( const cv::Mat& sample, bool returnDFVal=false ) const;
1960  float predict( const CvMat* samples, CV_OUT CvMat* results ) const;
1961 
1962  protected:
1963  float predict( const int row_index, int row_len, Mat& src, bool returnDFVal=false ) const;
1964  void create_kernel();
1965  void create_solver();
1966  };
1967 
1968  /*!*************** END *************!*/
1969  }
1970 }
1971 #if defined _MSC_VER && _MSC_VER >= 1200
1972 # pragma warning( push)
1973 # pragma warning( disable: 4267)
1974 #endif
1976 #if defined _MSC_VER && _MSC_VER >= 1200
1977 # pragma warning( pop)
1978 #endif
1979 
1980 #endif /* __OPENCV_OCL_HPP__ */
Definition: ocl.hpp:207
int levels
Definition: ocl.hpp:1586
CvArr CvPoint2D32f double M
Definition: imgproc_c.h:186
Size cell_size
Definition: ocl.hpp:1062
CV_EXPORTS void Scharr(const oclMat &src, oclMat &dst, int ddepth, int dx, int dy, double scale=1, double delta=0.0, int bordertype=BORDER_DEFAULT)
applies the vertical or horizontal Scharr operator to the image
CV_EXPORTS void flip(const oclMat &src, oclMat &dst, int flipCode)
reverses the order of the rows, columns or both in a matrix
GLdouble GLdouble GLdouble r
void find_nearest(const Matrix< typename Distance::ElementType > &dataset, typename Distance::ElementType *query, int *matches, int nn, int skip=0, Distance distance=Distance())
Definition: ground_truth.h:42
short float uchar uchar uchar uchar uchar ushort int uchar ushort int float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float int int int float int int int float int CV_CUDEV_IMPLEMENT_VEC_BINARY_OP char CV_CUDEV_IMPLEMENT_VEC_BINARY_OP ushort CV_CUDEV_IMPLEMENT_VEC_BINARY_OP short CV_CUDEV_IMPLEMENT_VEC_BINARY_OP int CV_CUDEV_IMPLEMENT_VEC_BINARY_OP uint CV_CUDEV_IMPLEMENT_VEC_BINARY_OP float CV_CUDEV_IMPLEMENT_VEC_BINARY_OP double char
Definition: vec_math.hpp:426
const CvArr CvArr CvArr const CvPoint2D32f CvPoint2D32f int CvSize int char * status
Definition: tracking.hpp:73
Point2i Point
Definition: core.hpp:893
const char * programStr
Definition: ocl.hpp:223
int deviceVersionMinor
Definition: ocl.hpp:110
CannyBuf()
Definition: ocl.hpp:989
GLsizei GLsizei GLchar * source
Definition: objdetect.hpp:385
CV_EXPORTS_W void sqrt(InputArray src, OutputArray dst)
computes square root of each matrix element (dst = src**0.5)
float free_coef
Definition: ocl.hpp:1082
CV_EXPORTS void abs(const oclMat &src, oclMat &dst)
computes element-wise absolute values of an array (dst = abs(src))
CvArr * edges
Definition: imgproc_c.h:555
OclCascadeClassifierBuf()
Definition: ocl.hpp:907
~Context()
Definition: ocl.hpp:176
Definition: ocl.hpp:1160
Definition: ocl.hpp:172
GLenum GLint GLint y
Definition: core_c.h:613
GLenum mode
Definition: ocl.hpp:63
CV_EXPORTS void matchTemplate(const oclMat &image, const oclMat &templ, oclMat &result, int method)
computes the proximity map for the raster template and the image where the template is searched for ...
int warps
Definition: ocl.hpp:1683
std::string platformVersion
Definition: ocl.hpp:129
int int int int * dy
CV_EXPORTS Ptr< FilterEngine_GPU > createLinearFilter_GPU(int srcType, int dstType, const Mat &kernel, const Point &anchor=Point(-1,-1), int borderType=BORDER_DEFAULT)
returns the non-separable linear filter engine
Definition: ocl.hpp:73
IplImage CvRect * roi
Definition: legacy.hpp:234
GLdouble GLdouble GLdouble GLdouble top
CV_EXPORTS void transpose(const oclMat &src, oclMat &dst)
transposes the matrix
int numIters
Definition: ocl.hpp:1463
CvArr const CvArr * lut
Definition: core_c.h:1439
Context()
Definition: ocl.hpp:175
std::string deviceVendor
Definition: ocl.hpp:98
CV_EXPORTS void absdiff(const oclMat &src1, const oclMat &src2, oclMat &dst)
computes element-wise absolute difference of two arrays (dst = abs(src1 - src2))
Ptr< FilterEngine_GPU > filterDY
Definition: ocl.hpp:1007
std::vector< const PlatformInfo * > PlatformsInfo
Definition: ocl.hpp:144
class CV_EXPORTS BruteForceMatcher_OCL
Definition: ocl.hpp:1322
float max_disc_term
Definition: ocl.hpp:1589
int depth
Definition: core_c.h:73
int blockSize
Definition: ocl.hpp:1368
oclMat errorCovPre
priori error estimate covariance matrix (P'(k)): P'(k)=A*P(k-1)*At + Q)*/
Definition: ocl.hpp:1919
CV_EXPORTS void exp(const oclMat &src, oclMat &dst)
computes exponent of each matrix element (dst = e**src)
const void * getOpenCLCommandQueuePtr() const
CV_EXPORTS Ptr< FilterEngine_GPU > createSeparableLinearFilter_GPU(int srcType, int dstType, const Mat &rowKernel, const Mat &columnKernel, const Point &anchor=Point(-1,-1), double delta=0.0, int bordertype=BORDER_DEFAULT, Size imgSize=Size(-1,-1))
returns the separable linear filter engine
unsigned char ValueType
Definition: ocl.hpp:1163
int CvScalar * scalar
Definition: core_c.h:209
int deviceVendorId
Definition: ocl.hpp:99
size_t localMemorySize
Definition: ocl.hpp:106
std::vector< const DeviceInfo * > devices
Definition: ocl.hpp:137
ResultType operator()(const T *a, const T *b, int size) const
Definition: ocl.hpp:1150
const CvArr CvArr * fgmask
Definition: legacy.hpp:3418
int iterations
Definition: ocl.hpp:1694
bool fastPyramids
Definition: ocl.hpp:1461
int rows
the number of rows and columns
Definition: ocl.hpp:399
CV_EXPORTS void subtract(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask=oclMat())
subtracts one matrix from another (dst = src1 - src2)
Definition: ocl.hpp:1567
oclMat block_hists
Definition: ocl.hpp:1088
Size2i Size
Definition: core.hpp:896
CV_EXPORTS void remap(const oclMat &src, oclMat &dst, oclMat &map1, oclMat &map2, int interpolation, int bordertype, const Scalar &value=Scalar())
Applies a generic geometrical transformation to an image.
double epsilon
Definition: ocl.hpp:1689
GLdouble GLdouble u2
Definition: types_c.h:1138
oclMat dy_buf
Definition: ocl.hpp:1003
CV_EXPORTS_W Scalar mean(InputArray src, InputArray mask=noArray())
computes mean value of selected array elements
double qualityLevel
Definition: ocl.hpp:1365
CvSeq * contour
Definition: core_c.h:1431
CvCmpFunc func
Definition: core_c.h:1072
ProgramSource(const char *_name, const char *_programStr)
Definition: ocl.hpp:227
CV_EXPORTS int getOpenCLDevices(DevicesInfo &devices, int deviceType=CVCL_DEVICE_TYPE_GPU, const PlatformInfo *platform=NULL)
CV_EXPORTS void morphologyEx(const oclMat &src, oclMat &dst, int op, const Mat &kernel, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar &borderValue=morphologyDefaultBorderValue())
applies an advanced morphological operation to the image
CV_EXPORTS void filter2D(const oclMat &src, oclMat &dst, int ddepth, const Mat &kernel, Point anchor=Point(-1,-1), double delta=0.0, int borderType=BORDER_DEFAULT)
applies non-separable 2D linear filter to the image
Definition: ocl.hpp:83
CvPoint2D32f float float b
Definition: legacy.hpp:578
Definition: ocl.hpp:1128
Definition: ocl.hpp:67
std::string deviceDriverVersion
Definition: ocl.hpp:100
PyrLKOpticalFlow()
Definition: ocl.hpp:1404
const CvArr * src1
Definition: core_c.h:436
float fTau
Definition: ocl.hpp:1879
CvSize size
Definition: calib3d.hpp:212
The 2D range class.
Definition: core.hpp:979
GLenum GLsizei width
OutputArray OutputArray sqsum
Definition: imgproc.hpp:620
CV_EXPORTS int countNonZero(const oclMat &src)
counts non-zero array elements
int flags
Definition: ocl.hpp:1466
CV_EXPORTS Ptr< BaseColumnFilter_GPU > getLinearColumnFilter_GPU(int bufType, int dstType, const Mat &columnKernel, int anchor=-1, int bordertype=BORDER_DEFAULT, double delta=0.0)
returns the primitive column filter with the specified kernel
GLuint src
Definition: core_c.h:1650
BruteForceMatcher_OCL()
Definition: ocl.hpp:1336
CV_EXPORTS void Sobel(const oclMat &src, oclMat &dst, int ddepth, int dx, int dy, int ksize=3, double scale=1, double delta=0.0, int bordertype=BORDER_DEFAULT)
applies generalized Sobel operator to the image
float data_weight
Definition: ocl.hpp:1588
CV_EXPORTS void copyMakeBorder(const oclMat &src, oclMat &dst, int top, int bottom, int left, int right, int boardtype, const Scalar &value=Scalar())
copies 2D array to a larger destination array and pads borders with user-specifiable constant ...
int int int flags
Definition: highgui_c.h:186
The Base Class for Non-Separable 2D Filters.
Definition: ocl.hpp:670
CV_EXPORTS void equalizeHist(const oclMat &mat_src, oclMat &mat_dst)
only 8UC1 and 256 bins is supported now
CV_EXPORTS void resize(const oclMat &src, oclMat &dst, Size dsize, double fx=0, double fy=0, int interpolation=INTER_LINEAR)
resizes the image
GLfloat ny
CV_EXPORTS void repeat(const oclMat &src, int ny, int nx, oclMat &dst)
fills the output array with repeated copies of the input array
int wholerows
Definition: ocl.hpp:419
~CannyBuf()
Definition: ocl.hpp:990
CV_EXPORTS void buildWarpPerspectiveMaps(const Mat &M, bool inverse, Size dsize, oclMat &xmap, oclMat &ymap)
builds Perspective warping maps
Definition: core.hpp:132
CV_EXPORTS void warpPerspective(const oclMat &src, oclMat &dst, const Mat &M, Size dsize, int flags=INTER_LINEAR)
warps the image using perspective transformation
CV_EXPORTS void min(const oclMat &src1, const oclMat &src2, oclMat &dst)
computes element-wise minimum of the two arrays (dst = min(src1, src2))
CV_EXPORTS void pyrUp(const oclMat &src, oclMat &dst)
upsamples the source image and then smoothes it
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: core_c.h:403
int d
Definition: legacy.hpp:3064
Definition: ocl.hpp:62
ResultType operator()(const unsigned char *a, const unsigned char *b, int size) const
Definition: ocl.hpp:1168
CvRect r
Definition: core_c.h:1282
const CvMat const CvMat const CvMat CvMat CvMat CvMat CvMat CvSize CvMat CvMat * T
Definition: calib3d.hpp:270
CV_EXPORTS oclMat & getOclMatRef(InputArray src)
GLfloat angle
Definition: core_c.h:1297
CV_EXPORTS void setBinaryDiskCache(int mode=CACHE_RELEASE, cv::String path="./")
Enable or disable OpenCL program binary caching onto local disk.
CV_EXPORTS void meanShiftProc(const oclMat &src, oclMat &dstr, oclMat &dstsp, int sp, int sr, TermCriteria criteria=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 5, 1))
Does mean shift procedure on GPU.
bool isIntelDevice
Definition: ocl.hpp:114
CV_EXPORTS oclMatExpr operator-(const oclMat &src1, const oclMat &src2)
DeviceType deviceType
Definition: ocl.hpp:94
int ksize
Definition: ocl.hpp:647
const GLuint * buffers
Definition: core.hpp:132
bool useInitialFlow
Definition: ocl.hpp:1423
std::vector< oclMat > image_sqsums
Definition: ocl.hpp:965
Definition: ocl.hpp:167
CV_EXPORTS void magnitude(const oclMat &x, const oclMat &y, oclMat &magnitude)
computes magnitude of each (x(i), y(i)) vector
CvArr const CvMat * kernel
Definition: imgproc_c.h:89
CV_EXPORTS void finish()
CV_EXPORTS oclMat operator~(const oclMat &)
Logical operators.
int msg_type
Definition: ocl.hpp:1626
static Context * getContext()
The Base Class for Filter Engine.
Definition: ocl.hpp:688
float noiseSigma
Definition: ocl.hpp:1791
const void * getOpenCLContextPtr() const
int ndisp
Definition: ocl.hpp:1584
CV_EXPORTS void buildWarpPlaneMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat &R, const Mat &T, float scale, oclMat &map_x, oclMat &map_y)
Definition: ocl.hpp:204
int _id
Definition: ocl.hpp:92
float disc_single_jump
Definition: ocl.hpp:1624
CV_EXPORTS Scalar absSum(const oclMat &m)
int _id
Definition: ocl.hpp:126
int history
Definition: ocl.hpp:1788
oclMat detector
Definition: ocl.hpp:1083
int polyN
Definition: ocl.hpp:1464
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: highgui_c.h:230
CV_EXPORTS void split(const oclMat &src, oclMat *dst)
Divides multi-channel array into several single-channel arrays.
The class implements the following algorithm: "Improved adaptive Gausian mixture model for background...
Definition: ocl.hpp:1813
CV_INLINE CvSize cvSize(int width, int height)
Definition: types_c.h:1145
const void * getClCommandQueuePtr()
Definition: ocl.hpp:193
void int step
Definition: core_c.h:403
Definition: ocl.hpp:74
CV_EXPORTS void cornerMinEigenVal(const oclMat &src, oclMat &dst, int blockSize, int ksize, int bordertype=cv::BORDER_DEFAULT)
const CvArr CvArr int method
Definition: imgproc_c.h:281
BaseColumnFilter_GPU(int ksize_, int anchor_, int bordertype_)
Definition: ocl.hpp:659
struct CV_EXPORTS CannyBuf
Definition: ocl.hpp:979
int ksize
Definition: ocl.hpp:662
raster image moments
Definition: imgproc.hpp:1094
Gaussian Mixture-based Backbround/Foreground Segmentation Algorithm.
Definition: ocl.hpp:1770
float max_data_term
Definition: ocl.hpp:1621
CV_EXPORTS void add(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask=oclMat())
adds one matrix to another (dst = src1 + src2)
virtual ~FilterEngine_GPU()
Definition: ocl.hpp:691
CV_EXPORTS void max(const oclMat &src1, const oclMat &src2, oclMat &dst)
computes element-wise maximum of the two arrays (dst = max(src1, src2))
CV_EXPORTS Ptr< FilterEngine_GPU > createGaussianFilter_GPU(int type, Size ksize, double sigma1, double sigma2=0, int bordertype=BORDER_DEFAULT, Size imgSize=Size(-1,-1))
returns the Gaussian filter engine
Proxy datatype for passing Mat's and vector<>'s as input parameters.
Definition: core.hpp:1312
Size block_stride
Definition: ocl.hpp:1061
void clear(const ColorA &color=ColorA::black(), bool clearDepthBuffer=true)
Definition: ocl.hpp:959
ResultType operator()(const T *a, const T *b, int size) const
Definition: ocl.hpp:1134
The 2D size class.
Definition: core.hpp:81
const CvMat const CvMat const CvMat CvSize const CvMat const CvMat CvMat * R1
Definition: calib3d.hpp:284
const CvArr const CvArr CvArr * result
Definition: core_c.h:805
CV_EXPORTS Ptr< cv::CLAHE > createCLAHE(double clipLimit=40.0, Size tileGridSize=Size(8, 8))
only 8UC1 is supported now
Definition: ocl.hpp:79
Definition: ocl.hpp:90
float Type
Definition: ocl.hpp:1109
CV_EXPORTS void divide(const oclMat &src1, const oclMat &src2, oclMat &dst, double scale=1)
computes element-wise quotient of the two arrays (dst = src1 * scale / src2)
CvPoint2D32f double CvTermCriteria criteria
Definition: calib3d.hpp:65
oclMat labels
Definition: ocl.hpp:1085
int platformVersionMinor
Definition: ocl.hpp:135
Definition: ml.hpp:289
size_t step
a distance between successive rows in bytes; includes the gap if any
Definition: ocl.hpp:401
BINARY_CACHE_MODE
Definition: ocl.hpp:202
int nscales
Definition: ocl.hpp:1675
Definition: ocl.hpp:124
float Type
Definition: ocl.hpp:1117
std::vector< size_t > maxWorkItemSizes
Definition: ocl.hpp:104
T ValueType
Definition: ocl.hpp:1147
Mat labels_host
Definition: ocl.hpp:1086
std::string deviceProfile
Definition: ocl.hpp:95
GLint GLvoid * img
Definition: legacy.hpp:1150
const CvMat * measurement
Definition: tracking.hpp:220
int maxCorners
Definition: ocl.hpp:1364
CV_EXPORTS void setBinaryPath(const char *path)
set where binary cache to be saved to
BaseRowFilter_GPU(int ksize_, int anchor_, int bordertype_)
Definition: ocl.hpp:644
float fVarMax
Definition: ocl.hpp:1864
CV_EXPORTS Ptr< FilterEngine_GPU > createFilter2D_GPU(const Ptr< BaseFilter_GPU > filter2D)
returns the non-separable filter engine with the specified filter
CvMemStoragePos * pos
Definition: core_c.h:933
CV_EXPORTS Ptr< FilterEngine_GPU > createMorphologyFilter_GPU(int op, int type, const Mat &kernel, const Point &anchor=Point(-1,-1), int iterations=1)
returns morphological filter engine. Only MORPH_ERODE and MORPH_DILATE are supported.
CV_EXPORTS void dilate(const oclMat &src, oclMat &dst, const Mat &kernel, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar &borderValue=morphologyDefaultBorderValue())
dilates the image (applies the local maximum operator)
CV_EXPORTS void bilateralFilter(const oclMat &src, oclMat &dst, int d, double sigmaColor, double sigmaSpace, int borderType=BORDER_DEFAULT)
bilateralFilter
GLenum GLenum GLvoid * row
std::string platformProfile
Definition: ocl.hpp:128
GLdouble u1
CV_EXPORTS void Canny(const oclMat &image, oclMat &edges, double low_thresh, double high_thresh, int apperture_size=3, bool L2gradient=false)
compute edges of the input image using Canny operator
const CvArr CvArr double int levels
Definition: tracking.hpp:102
CV_EXPORTS void meanShiftSegmentation(const oclMat &src, Mat &dst, int sp, int sr, int minsize, TermCriteria criteria=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 5, 1))
Does mean shift segmentation with elimiation of small regions.
Definition: imgproc.hpp:651
CV_EXPORTS Ptr< BaseRowFilter_GPU > getLinearRowFilter_GPU(int srcType, int bufType, const Mat &rowKernel, int anchor=-1, int bordertype=BORDER_DEFAULT)
returns the primitive row filter with the specified kernel
CV_EXPORTS void cornerMinEigenVal_dxdy(const oclMat &src, oclMat &dst, oclMat &Dx, oclMat &Dy, int blockSize, int ksize, int bordertype=cv::BORDER_DEFAULT)
***************Kalman Filter*************!
Definition: ocl.hpp:1900
oclMat gain
Kalman gain matrix (K(k)): K(k)=P'(k)*Ht*inv(H*P'(k)*Ht+R)
Definition: ocl.hpp:1920
int wholecols
Definition: ocl.hpp:420
Base class for MOG and MOG2!
Definition: ocl.hpp:1750
GLuint GLfloat * val
Definition: ocl.hpp:891
const CvArr const CvArr const CvArr * src3
Definition: core_c.h:436
CV_EXPORTS void cornerHarris(const oclMat &src, oclMat &dst, int blockSize, int ksize, double k, int bordertype=cv::BORDER_DEFAULT)
oclMat dy
Definition: ocl.hpp:1002
uchar * datastart
helper fields used in locateROI and adjustROI
Definition: ocl.hpp:411
CV_EXPORTS void bitwise_or(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask=oclMat())
calculates per-element bit-wise disjunction of two arrays
CV_EXPORTS oclMatExpr operator+(const oclMat &src1, const oclMat &src2)
Mathematics operators.
GLsizei stride
CV_EXPORTS void meanShiftFiltering(const oclMat &src, oclMat &dst, int sp, int sr, TermCriteria criteria=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 5, 1))
CannyBuf(const Size &image_size, int apperture_size=3)
Definition: ocl.hpp:994
CV_EXPORTS void error(const char *error_string, const char *file, const int line, const char *func)
float avergeTexThreshold
Definition: ocl.hpp:1562
CV_EXPORTS void distanceToCenters(const oclMat &src, const oclMat &centers, Mat &dists, Mat &labels, int distType=NORM_L2SQR)
Compute closest centers for each lines in source and lable it after center's index.
CV_EXPORTS Scalar sqrSum(const oclMat &m)
BruteForceMatcher_OCL(L2< T >)
Definition: ocl.hpp:1337
Definition: ocl.hpp:249
std::string deviceName
Definition: ocl.hpp:97
the desired accuracy or change in parameters at which the iterative algorithm stops ...
Definition: core.hpp:2098
int numLevels
Definition: ocl.hpp:1459
float Type
Definition: ocl.hpp:1113
CvArr const CvMat * mat
Definition: core_c.h:700
double pyrScale
Definition: ocl.hpp:1460
std::string platformName
Definition: ocl.hpp:130
GLboolean GLboolean g
double harrisK
Definition: ocl.hpp:1370
std::string compilationExtraOptions
Definition: ocl.hpp:116
Definition: ml.hpp:452
Definition: ocl.hpp:1347
GLenum GLsizei GLsizei height
CV_EXPORTS void LUT(const oclMat &src, const oclMat &lut, oclMat &dst)
transforms 8-bit unsigned integers using lookup table: dst(i)=lut(src(i))
std::string String
Definition: core.hpp:85
Definition: ocl.hpp:1730
const char * name
Definition: ocl.hpp:222
GLclampf GLclampf GLclampf alpha
Definition: core_c.h:687
CvArr CvPoint int bordertype
Definition: imgproc_c.h:77
float Type
Definition: ocl.hpp:1121
CV_EXPORTS void setIdentity(oclMat &src, const Scalar &val=Scalar(1))
initializes a scaled identity matrix
const CvMat const CvMat const CvMat CvMat CvMat CvMat CvMat CvSize CvMat * R
Definition: calib3d.hpp:270
Size effect_size
Definition: ocl.hpp:1094
ProgramSource(const char *_name, const char *_programStr, const char *_programHash)
Definition: ocl.hpp:233
oclMat processNoiseCov
process noise covariance matrix (Q)
Definition: ocl.hpp:1917
Definition: types_c.h:1272
int preset
Definition: ocl.hpp:1554
std::string platformExtensons
Definition: ocl.hpp:132
int flags
includes several bit-fields:
Definition: ocl.hpp:397
BruteForceMatcher_OCL(L1< T >)
Definition: ocl.hpp:1329
int nlevels
Definition: ocl.hpp:1068
double derivLambda
Definition: ocl.hpp:1422
bool haveDoubleSupport
Definition: ocl.hpp:112
BruteForceMatcher_OCL()
Definition: ocl.hpp:1343
void releaseMemory()
Definition: ocl.hpp:1371
CvSize int int int CvPoint int delta
Definition: core_c.h:1427
std::string platformVendor
Definition: ocl.hpp:131
Definition: ocl.hpp:1728
Size ksize
Definition: ocl.hpp:677
CV_EXPORTS void bitwise_and(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask=oclMat())
calculates per-element bit-wise conjunction of two arrays
int winSize
Definition: ocl.hpp:1556
CV_EXPORTS void columnSum(const oclMat &src, oclMat &sum)
computes vertical sum, supports only CV_32FC1 images
size_t size_t CvMemStorage * storage
Definition: core_c.h:946
int ResultType
Definition: ocl.hpp:1164
CV_EXPORTS int normHamming(const uchar *a, const uchar *b, int n)
CV_EXPORTS void minMaxLoc(const oclMat &src, double *minVal, double *maxVal=0, Point *minLoc=0, Point *maxLoc=0, const oclMat &mask=oclMat())
finds global minimum and maximum array elements and returns their values with locations ...
CV_EXPORTS void compare(const oclMat &src1, const oclMat &src2, oclMat &dst, int cmpop)
compares elements of two arrays (dst = src1 src2)
CV_EXPORTS void initializeContext(void *pClPlatform, void *pClContext, void *pClDevice)
CV_EXPORTS_W void blur(InputArray src, OutputArray dst, Size ksize, Point anchor=Point(-1,-1), int borderType=BORDER_DEFAULT)
a synonym for normalized box filter
Definition: ocl.hpp:1727
T Type
Definition: ocl.hpp:1105
CvArr int block_size
Definition: imgproc_c.h:566
const CvMat CvMat CvMat int k
Definition: legacy.hpp:3052
GLenum GLint x
Definition: core_c.h:632
CV_EXPORTS double norm(const oclMat &src1, int normType=NORM_L2)
computes norm of array
Accumulator< T >::Type ResultType
Definition: ocl.hpp:1148
CvArr double double sr
Definition: imgproc_c.h:125
CV_EXPORTS void blendLinear(const oclMat &img1, const oclMat &img2, const oclMat &weights1, const oclMat &weights2, oclMat &result)
bool getMinEigenVals
Definition: ocl.hpp:1425
GLenum GLsizei n
Point anchor
Definition: ocl.hpp:678
Definition: ocl.hpp:1032
Definition: ocl.hpp:1642
float fVarMin
Definition: ocl.hpp:1863
The Base Class for 1D or Row-wise Filters.
Definition: ocl.hpp:641
CvMat CvMat * sample
Definition: ml.hpp:1985
int winSize
Definition: ocl.hpp:1462
CV_EXPORTS void bitwise_not(const oclMat &src, oclMat &dst)
perfroms per-elements bit-wise inversion
CV_EXPORTS void cornerHarris_dxdy(const oclMat &src, oclMat &dst, oclMat &Dx, oclMat &Dy, int blockSize, int ksize, double k, int bordertype=cv::BORDER_DEFAULT)
float disc_single_jump
Definition: ocl.hpp:1590
The Image Processing.
GLdouble left
DevMemType
Definition: ocl.hpp:77
CV_EXPORTS void medianFilter(const oclMat &src, oclMat &dst, int m)
Smoothes image using median filter.
std::string deviceVersion
Definition: ocl.hpp:96
double theta
Definition: ocl.hpp:1670
GLfloat GLfloat GLfloat GLfloat nx
Definition: ocl.hpp:72
uchar * dataend
Definition: ocl.hpp:412
CV_EXPORTS void sortByKey(oclMat &keys, oclMat &values, int method, bool isGreaterThan=false)
Returns the sorted result of all the elements in input based on equivalent keys.
CV_EXPORTS oclMat operator^(const oclMat &, const oclMat &)
CV_EXPORTS void addWeighted(const oclMat &src1, double alpha, const oclMat &src2, double beta, double gama, oclMat &dst)
adds one matrix to another with scale (dst = src1 * alpha + src2 * beta + gama)
OclCascadeClassifier()
Definition: ocl.hpp:894
The Base Class for Column-wise Filters.
Definition: ocl.hpp:656
Definition: types_c.h:645
const GLdouble * v
const CvArr CvArr double int int int iterations
Definition: tracking.hpp:102
float varThreshold
Definition: ocl.hpp:1838
double const CvArr double beta
Definition: core_c.h:523
GLdouble GLdouble right
Definition: ocl.hpp:1729
CV_EXPORTS oclMatExpr operator*(const oclMat &src1, const oclMat &src2)
CV_EXPORTS Scalar sum(const oclMat &m)
computes sum of array elements
The Core Functionality.
double threshold_L2hys
Definition: ocl.hpp:1066
CV_EXPORTS void adaptiveBilateralFilter(const oclMat &src, oclMat &dst, Size ksize, double sigmaSpace, double maxSigmaColor=20.0, Point anchor=Point(-1,-1), int borderType=BORDER_DEFAULT)
Applies an adaptive bilateral filter to the input image.
int ndisp
Definition: ocl.hpp:1555
Definition: core.hpp:132
Definition: ocl.hpp:1533
GLboolean GLboolean GLboolean b
Definition: legacy.hpp:633
CV_EXPORTS void phase(const oclMat &x, const oclMat &y, oclMat &angle, bool angleInDegrees=false)
computes angle (angle(i)) of each (x(i), y(i)) vector
The n-dimensional matrix class.
Definition: core.hpp:1688
CV_EXPORTS void calcHist(const oclMat &mat_src, oclMat &mat_hist)
only 8UC1 and 256 bins is supported now
double tau
Definition: ocl.hpp:1654
int rows
Definition: core_c.h:114
int iters
Definition: ocl.hpp:1421
std::vector< const DeviceInfo * > DevicesInfo
Definition: ocl.hpp:148
CV_EXPORTS Ptr< BaseFilter_GPU > getLinearFilter_GPU(int srcType, int dstType, const Mat &kernel, const Size &ksize, const Point &anchor=Point(-1,-1), int borderType=BORDER_DEFAULT)
returns 2D filter with the specified kernel
T ValueType
Definition: ocl.hpp:1131
bool isUnifiedMemory
Definition: ocl.hpp:113
int levels
Definition: ocl.hpp:1619
oclMat statePre
predicted state (x'(k)): x(k)=A*x(k-1)+B*u(k)
Definition: ocl.hpp:1912
Definition: ocl.hpp:205
ditto
Definition: core.hpp:2097
const CvArr CvSeq CvSeq ** descriptors
Definition: compat.hpp:647
CV_EXPORTS void pyrDown(const oclMat &src, oclMat &dst)
BruteForceMatcher_OCL()
Definition: ocl.hpp:1328
DistType distType
Definition: ocl.hpp:1316
GLsizei const GLfloat * value
Definition: core_c.h:341
CvSize CvPoint2D32f * corners
Definition: calib3d.hpp:215
bilinear interpolation
Definition: imgproc.hpp:555
OutputArray OutputArray labels
Definition: imgproc.hpp:823
static Scalar_< double > all(doublev0)
returns a scalar with all elements set to v0
oclMat measurementMatrix
measurement matrix (H)
Definition: ocl.hpp:1916
int cols
Definition: core_c.h:109
CV_EXPORTS void warpAffine(const oclMat &src, oclMat &dst, const Mat &M, Size dsize, int flags=INTER_LINEAR)
warps the image using affine transformation
~OclCascadeClassifierBuf()
Definition: ocl.hpp:910
GLfloat GLfloat p
virtual ~BaseRowFilter_GPU()
Definition: ocl.hpp:645
GLuint GLuint GLsizei GLenum type
Definition: core_c.h:114
CV_EXPORTS void integral(const oclMat &src, oclMat &sum, oclMat &sqsum)
computes the integral image and integral for the squared image
void void * frame
Definition: core_c.h:1459
GLenum const GLfloat * params
Definition: compat.hpp:688
BFMatcher_OCL(int norm=NORM_L2)
Definition: ocl.hpp:1350
CV_EXPORTS Moments ocl_moments(InputArray contour)
GLsizei samples
Definition: matrix_operations.hpp:67
Definition: ocl.hpp:904
int nbins
Definition: ocl.hpp:1064
Definition: ocl.hpp:82
CV_EXPORTS void setDevice(const DeviceInfo *info)
CV_EXPORTS void erode(const oclMat &src, oclMat &dst, const Mat &kernel, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar &borderValue=morphologyDefaultBorderValue())
erodes the image (applies the local minimum operator)
void releaseMemory()
Definition: ocl.hpp:1426
oclMat statePost
corrected state (x(k)): x(k)=x'(k)+K(k)*(z(k)-H*x'(k))
Definition: ocl.hpp:1913
float data_weight
Definition: ocl.hpp:1622
CV_EXPORTS double threshold(const oclMat &src, oclMat &dst, double thresh, double maxVal, int type=THRESH_TRUNC)
applies fixed threshold to the image.
CV_EXPORTS void minMax(const oclMat &src, double *minVal, double *maxVal=0, const oclMat &mask=oclMat())
finds global minimum and maximum array elements and returns their values
int int type
Definition: core_c.h:109
Definition: ocl.hpp:1103
virtual ~BaseColumnFilter_GPU()
Definition: ocl.hpp:660
Definition: ocl.hpp:220
CV_EXPORTS oclMat operator|(const oclMat &, const oclMat &)
GLuint const GLchar * name
Definition: core_c.h:1546
float backgroundRatio
Definition: ocl.hpp:1848
bool gamma_correction
Definition: ocl.hpp:1067
int int channels
Definition: core_c.h:73
size_t maxMemAllocSize
Definition: ocl.hpp:107
DistType
Definition: ocl.hpp:1179
~OclCascadeClassifier()
Definition: ocl.hpp:895
double win_sigma
Definition: ocl.hpp:1065
uchar * data
pointer to the data(OCL memory object)
Definition: ocl.hpp:403
CvMat int int CvMat ** responses
Definition: ml.hpp:1999
CV_EXPORTS void boxFilter(const oclMat &src, oclMat &dst, int ddepth, Size ksize, Point anchor=Point(-1,-1), int borderType=BORDER_DEFAULT)
smooths the image using the normalized box filter
Definition: ocl.hpp:64
template 2D point class.
Definition: core.hpp:82
double lambda
Definition: ocl.hpp:1662
int maxLevel
Definition: ocl.hpp:1420
float fCT
Definition: ocl.hpp:1871
oclMat templf
Definition: ocl.hpp:962
CV_EXPORTS void log(const oclMat &src, oclMat &dst)
computes natural logarithm of absolute value of each matrix element: dst = log(abs(src)) ...
CvArr double sp
Definition: imgproc_c.h:125
CV_EXPORTS Ptr< BaseFilter_GPU > getMorphologyFilter_GPU(int op, int type, const Mat &kernel, const Size &ksize, Point anchor=Point(-1,-1))
Definition: imgproc.hpp:62
const CvArr CvSize win_size
Definition: legacy.hpp:3123
CV_EXPORTS void polarToCart(const oclMat &magnitude, const oclMat &angle, oclMat &x, oclMat &y, bool angleInDegrees=false)
converts polar coordinates to Cartesian
float fVarInit
Definition: ocl.hpp:1862
oclMat trackBuf2
Definition: ocl.hpp:1005
const PlatformInfo * platform
Definition: ocl.hpp:118
Definition: imgproc.hpp:66
float backgroundRatio
Definition: ocl.hpp:1790
CV_EXPORTS void bitwise_xor(const oclMat &src1, const oclMat &src2, oclMat &dst, const oclMat &mask=oclMat())
calculates per-element bit-wise "exclusive or" operation
CV_EXPORTS void cartToPolar(const oclMat &x, const oclMat &y, oclMat &magnitude, oclMat &angle, bool angleInDegrees=false)
converts Cartesian coordinates to polar
CvArr int code
Definition: imgproc_c.h:144
CV_EXPORTS void interpolateFrames(const oclMat &frame0, const oclMat &frame1, const oclMat &fu, const oclMat &fv, const oclMat &bu, const oclMat &bv, float pos, oclMat &newFrame, oclMat &buf)
CV_EXPORTS Ptr< FilterEngine_GPU > createSeparableFilter_GPU(const Ptr< BaseRowFilter_GPU > &rowFilter, const Ptr< BaseColumnFilter_GPU > &columnFilter)
returns the separable filter engine with the specified filters
GLboolean GLboolean GLboolean GLboolean a
Definition: legacy.hpp:633
oclMat counter
Definition: ocl.hpp:1006
CV_EXPORTS oclMat operator&(const oclMat &, const oclMat &)
unsigned char nShadowDetection
Definition: ocl.hpp:1878
int iters
Definition: ocl.hpp:1618
int int int * dx
float max_disc_term
Definition: ocl.hpp:1623
float minEigThreshold
Definition: ocl.hpp:1424
*************** SVM *************!
Definition: ocl.hpp:1949
oclMat edgeBuf
Definition: ocl.hpp:1004
bool bShadowDetection
Definition: ocl.hpp:1877
const CvArr CvArr * disparity
Definition: calib3d.hpp:353
float max_data_term
Definition: ocl.hpp:1587
Definition: ocl.hpp:1401
std::vector< oclMat > images
Definition: ocl.hpp:963
GoodFeaturesToTrackDetector_OCL(int maxCorners=1000, double qualityLevel=0.01, double minDistance=0.0, int blockSize=3, bool useHarrisDetector=false, double harrisK=0.04)
Definition: ocl.hpp:1389
CV_EXPORTS void merge(const oclMat *src, size_t n, oclMat &dst)
oclMat errorCovPost
posteriori error estimate covariance matrix (P(k)): P(k)=(I-K(k)*H)*P'(k)
Definition: ocl.hpp:1921
CV_EXPORTS void dft(const oclMat &src, oclMat &dst, Size dft_size=Size(), int flags=0)
const CvMat CvSize image_size
Definition: calib3d.hpp:126
int maxComputeUnits
Definition: ocl.hpp:105
CV_EXPORTS void openCLExecuteKernelInterop(Context *clCxt, const cv::ocl::ProgramSource &source, string kernelName, size_t globalThreads[3], size_t localThreads[3], std::vector< std::pair< size_t, const void * > > &args, int channels, int depth, const char *build_options)
int iters
Definition: ocl.hpp:1585
unsigned char uchar
Definition: types_c.h:170
Definition: types_c.h:1333
Definition: ocl.hpp:166
int min_disp_th
Definition: ocl.hpp:1625
Definition: ocl.hpp:987
double minDistance
Definition: ocl.hpp:1366
GLuint dst
Definition: calib3d.hpp:134
oclMat image_scale
Definition: ocl.hpp:1092
CV_EXPORTS void convolve(const oclMat &image, const oclMat &temp1, oclMat &result)
computes convolution of two images
Definition: core.hpp:1950
int history
Definition: ocl.hpp:1834
DeviceType
Definition: ocl.hpp:60
bool useHarrisDetector
Definition: ocl.hpp:1369
CV_EXPORTS void buildWarpSphericalMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat &R, float scale, oclMat &map_x, oclMat &map_y)
builds spherical warping maps
false
Definition: color.hpp:230
CV_EXPORTS Ptr< FilterEngine_GPU > createBoxFilter_GPU(int srcType, int dstType, const Size &ksize, const Point &anchor=Point(-1,-1), int borderType=BORDER_DEFAULT)
returns box filter engine
GLsizei const GLfloat * points
Definition: ocl.hpp:1454
std::string deviceExtensions
Definition: ocl.hpp:101
const CvArr * templ
Definition: imgproc_c.h:281
CV_EXPORTS oclMatExpr operator/(const oclMat &src1, const oclMat &src2)
CvPoint2D32f float a
Definition: legacy.hpp:578
Definition: ocl.hpp:1176
Smart pointer to dynamically allocated objects.
Definition: core.hpp:1268
CV_EXPORTS Ptr< FilterEngine_GPU > createDerivFilter_GPU(int srcType, int dstType, int dx, int dy, int ksize, int borderType=BORDER_DEFAULT, Size imgSize=Size(-1,-1))
returns filter engine for the generalized Sobel operator
GLdouble GLdouble GLdouble bottom
GLboolean GLenum GLenum GLvoid * values
size_t maxWorkGroupSize
Definition: ocl.hpp:103
bool useInitialFlow
Definition: ocl.hpp:1696
int ndisp
Definition: ocl.hpp:1617
BaseFilter_GPU(const Size &ksize_, const Point &anchor_, const int &borderType_)
Definition: ocl.hpp:673
int platformVersionMajor
Definition: ocl.hpp:134
CV_EXPORTS void swap(Mat &a, Mat &b)
swaps two matrices
CV_EXPORTS void gemm(const oclMat &src1, const oclMat &src2, double alpha, const oclMat &src3, double beta, oclMat &dst, int flags=0)
implements generalized matrix product algorithm GEMM from BLAS
Definition: ocl.hpp:81
short
Definition: vec_math.hpp:153
Definition: ocl.hpp:1598
const GLfloat * m
int nr_plane
Definition: ocl.hpp:1620
CV_EXPORTS bool supportsFeature(FEATURE_TYPE featureType)
Definition: ocl.hpp:168
CvArr CvArr * temp
Definition: imgproc_c.h:242
Definition: ocl.hpp:165
virtual ~BaseFilter_GPU()
Definition: ocl.hpp:675
GLint GLint GLsizei GLsizei GLsizei depth
Definition: core_c.h:76
DevMemRW
Definition: ocl.hpp:70
GLenum GLenum GLenum GLenum GLenum scale
const void * getClContextPtr()
Definition: ocl.hpp:188
GLdouble GLdouble t
float varThresholdGen
Definition: ocl.hpp:1855
GLdouble s
const CvArr const CvArr * src2
Definition: core_c.h:436
Vec< _Tp, 4 > & operator*=(Vec< _Tp, 4 > &v1, const Vec< _Tp, 4 > &v2)
Definition: operations.hpp:1450
GLenum GLint GLuint mask
Definition: tracking.hpp:132
int msg_type
Definition: ocl.hpp:1591
Context * clCxt
OpenCL context associated with the oclMat object.
Definition: ocl.hpp:415
int deviceVersionMajor
Definition: ocl.hpp:109
***************K Nearest Neighbour*************!
Definition: ocl.hpp:1931
float varThreshold
Definition: ocl.hpp:1789
CV_EXPORTS void Laplacian(const oclMat &src, oclMat &dst, int ddepth, int ksize=1, double scale=1, double delta=0, int borderType=BORDER_DEFAULT)
applies Laplacian operator to the image
oclMat qangle
Definition: ocl.hpp:1090
CV_EXPORTS void multiply(const oclMat &src1, const oclMat &src2, oclMat &dst, double scale=1)
computes element-wise product of the two arrays (dst = src1 * scale * src2)
Definition: ocl.hpp:80
GLclampf f
CV_EXPORTS double kmeans(const oclMat &src, int K, oclMat &bestLabels, TermCriteria criteria, int attemps, int flags, oclMat &centers)
Does k-means procedure on GPU.
CvLatentSvmDetector * detector
Definition: objdetect.hpp:270
Size block_size
Definition: ocl.hpp:1060
CV_EXPORTS void pow(const oclMat &x, double p, oclMat &y)
the function raises every element of tne input array to p
Definition: ocl.hpp:206
Size win_size
Definition: ocl.hpp:1059
Definition: ml.hpp:233
GLsizeiptr size
Definition: core_c.h:939
CV_EXPORTS Ptr< BaseFilter_GPU > getBoxFilter_GPU(int srcType, int dstType, const Size &ksize, Point anchor=Point(-1,-1), int borderType=BORDER_DEFAULT)
returns 2D box filter
CV_EXPORTS void meanStdDev(const oclMat &mtx, Scalar &mean, Scalar &stddev)
computes mean value and standard deviation of all or selected array elements
CV_EXPORTS void buildWarpCylindricalMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat &R, float scale, oclMat &map_x, oclMat &map_y)
builds cylindrical warping maps
Scalar_< double > Scalar
Definition: core.hpp:968
CV_EXPORTS void GaussianBlur(const oclMat &src, oclMat &dst, Size ksize, double sigma1, double sigma2=0, int bordertype=BORDER_DEFAULT)
smooths the image using Gaussian filter.
Proxy datatype for passing Mat's and vector<>'s as input parameters.
Definition: core.hpp:1400
Definition: ocl.hpp:1144
CV_EXPORTS int getOpenCLPlatforms(PlatformsInfo &platforms)
FEATURE_TYPE
Definition: ocl.hpp:163
oclMat transitionMatrix
state transition matrix (A)
Definition: ocl.hpp:1914
Accumulator< T >::Type ResultType
Definition: ocl.hpp:1132
oclMat controlMatrix
control matrix (B) (not used if there is no control)
Definition: ocl.hpp:1915
std::vector< oclMat > image_sums
Definition: ocl.hpp:964
CV_EXPORTS void cvtColor(const oclMat &src, oclMat &dst, int code, int dcn=0)
int borderType
Definition: ocl.hpp:679
Rect_< int > Rect
Definition: core.hpp:897
BruteForceMatcher_OCL(Hamming)
Definition: ocl.hpp:1344
double polySigma
Definition: ocl.hpp:1465
Size user_block_size
Definition: ocl.hpp:961
Size winSize
Definition: ocl.hpp:1419
bool use_local_init_data_cost
Definition: ocl.hpp:1627
oclMat measurementNoiseCov
measurement noise covariance matrix (R)
Definition: ocl.hpp:1918
Definition: core.hpp:132
CV_EXPORTS void buildWarpAffineMaps(const Mat &M, bool inverse, Size dsize, oclMat &xmap, oclMat &ymap)
builds Affine warping maps
int * refcount
pointer to the reference counter;
Definition: ocl.hpp:407
int offset
Definition: ocl.hpp:417
CV_EXPORTS_W void line(CV_IN_OUT Mat &img, Point pt1, Point pt2, const Scalar &color, int thickness=1, int lineType=8, int shift=0)
draws the line segment (pt1, pt2) in the image
CV_EXPORTS void sepFilter2D(const oclMat &src, oclMat &dst, int ddepth, const Mat &kernelX, const Mat &kernelY, Point anchor=Point(-1,-1), double delta=0.0, int bordertype=BORDER_DEFAULT)
applies separable 2D linear filter to the image
const char * programHash
Definition: ocl.hpp:224