gpu.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) 2000-2008, Intel Corporation, all rights reserved.
14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15 // Third party copyrights are property of their respective owners.
16 //
17 // Redistribution and use in source and binary forms, with or without modification,
18 // are permitted provided that the following conditions are met:
19 //
20 // * Redistribution's of source code must retain the above copyright notice,
21 // this list of conditions and the following disclaimer.
22 //
23 // * Redistribution's in binary form must reproduce the above copyright notice,
24 // this list of conditions and the following disclaimer in the documentation
25 // and/or other materials provided with the distribution.
26 //
27 // * The name of the copyright holders may not be used to endorse or promote products
28 // derived from this software without specific prior written permission.
29 //
30 // This software is provided by the copyright holders and contributors "as is" and
31 // any express or implied warranties, including, but not limited to, the implied
32 // warranties of merchantability and fitness for a particular purpose are disclaimed.
33 // In no event shall the Intel Corporation or contributors be liable for any direct,
34 // indirect, incidental, special, exemplary, or consequential damages
35 // (including, but not limited to, procurement of substitute goods or services;
36 // loss of use, data, or profits; or business interruption) however caused
37 // and on any theory of liability, whether in contract, strict liability,
38 // or tort (including negligence or otherwise) arising in any way out of
39 // the use of this software, even if advised of the possibility of such damage.
40 //
41 //M*/
42 
43 #ifndef __OPENCV_GPU_HPP__
44 #define __OPENCV_GPU_HPP__
45 
46 #ifndef SKIP_INCLUDES
47 #include <vector>
48 #include <memory>
49 #include <iosfwd>
50 #endif
51 
52 #include "opencv2/core/gpumat.hpp"
56 
57 namespace cv { namespace gpu {
58 
60 // CudaMem is limited cv::Mat with page locked memory allocation.
61 // Page locked memory is only needed for async and faster coping to GPU.
62 // It is convertable to cv::Mat header without reference counting
63 // so you can use it with other opencv functions.
64 
65 // Page-locks the matrix m memory and maps it for the device(s)
66 CV_EXPORTS void registerPageLocked(Mat& m);
67 // Unmaps the memory of matrix m, and makes it pageable again.
68 CV_EXPORTS void unregisterPageLocked(Mat& m);
69 
70 class CV_EXPORTS CudaMem
71 {
72 public:
73  enum { ALLOC_PAGE_LOCKED = 1, ALLOC_ZEROCOPY = 2, ALLOC_WRITE_COMBINED = 4 };
74 
75  CudaMem();
76  CudaMem(const CudaMem& m);
77 
78  CudaMem(int rows, int cols, int type, int _alloc_type = ALLOC_PAGE_LOCKED);
79  CudaMem(Size size, int type, int alloc_type = ALLOC_PAGE_LOCKED);
80 
81 
83  explicit CudaMem(const Mat& m, int alloc_type = ALLOC_PAGE_LOCKED);
84 
85  ~CudaMem();
86 
87  CudaMem& operator = (const CudaMem& m);
88 
90  CudaMem clone() const;
91 
93  void create(int rows, int cols, int type, int alloc_type = ALLOC_PAGE_LOCKED);
94  void create(Size size, int type, int alloc_type = ALLOC_PAGE_LOCKED);
95 
97  void release();
98 
100  Mat createMatHeader() const;
101  operator Mat() const;
102 
104  GpuMat createGpuMatHeader() const;
105  operator GpuMat() const;
106 
107  //returns if host memory can be mapperd to gpu address space;
108  static bool canMapHostMemory();
109 
110  // Please see cv::Mat for descriptions
111  bool isContinuous() const;
112  size_t elemSize() const;
113  size_t elemSize1() const;
114  int type() const;
115  int depth() const;
116  int channels() const;
117  size_t step1() const;
118  Size size() const;
119  bool empty() const;
120 
121 
122  // Please see cv::Mat for descriptions
123  int flags;
124  int rows, cols;
125  size_t step;
126 
128  int* refcount;
129 
132 
134 };
135 
137 // Encapculates Cuda Stream. Provides interface for async coping.
138 // Passed to each function that supports async kernel execution.
139 // Reference counting is enabled
140 
141 class CV_EXPORTS Stream
142 {
143 public:
144  Stream();
145  ~Stream();
146 
147  Stream(const Stream&);
148  Stream& operator =(const Stream&);
149 
150  bool queryIfComplete();
151  void waitForCompletion();
152 
154  // Warning! cv::Mat must point to page locked memory (i.e. to CudaMem data or to its subMat)
155  void enqueueDownload(const GpuMat& src, CudaMem& dst);
156  void enqueueDownload(const GpuMat& src, Mat& dst);
157 
159  // Warning! cv::Mat must point to page locked memory (i.e. to CudaMem data or to its ROI)
160  void enqueueUpload(const CudaMem& src, GpuMat& dst);
161  void enqueueUpload(const Mat& src, GpuMat& dst);
162 
164  void enqueueCopy(const GpuMat& src, GpuMat& dst);
165 
167  void enqueueMemSet(GpuMat& src, Scalar val);
168  void enqueueMemSet(GpuMat& src, Scalar val, const GpuMat& mask);
169 
171  void enqueueConvert(const GpuMat& src, GpuMat& dst, int dtype, double a = 1, double b = 0);
172 
174  typedef void (*StreamCallback)(Stream& stream, int status, void* userData);
175  void enqueueHostCallback(StreamCallback callback, void* userData);
176 
177  static Stream& Null();
178 
179  operator bool() const;
180 
181 private:
182  struct Impl;
183 
184  explicit Stream(Impl* impl);
185  void create();
186  void release();
187 
188  Impl *impl;
189 
190  friend struct StreamAccessor;
191 };
192 
193 
195 
202 class CV_EXPORTS BaseRowFilter_GPU
203 {
204 public:
205  BaseRowFilter_GPU(int ksize_, int anchor_) : ksize(ksize_), anchor(anchor_) {}
206  virtual ~BaseRowFilter_GPU() {}
207  virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null()) = 0;
208  int ksize, anchor;
209 };
210 
217 class CV_EXPORTS BaseColumnFilter_GPU
218 {
219 public:
220  BaseColumnFilter_GPU(int ksize_, int anchor_) : ksize(ksize_), anchor(anchor_) {}
222  virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null()) = 0;
223  int ksize, anchor;
224 };
225 
231 class CV_EXPORTS BaseFilter_GPU
232 {
233 public:
234  BaseFilter_GPU(const Size& ksize_, const Point& anchor_) : ksize(ksize_), anchor(anchor_) {}
235  virtual ~BaseFilter_GPU() {}
236  virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null()) = 0;
239 };
240 
247 class CV_EXPORTS FilterEngine_GPU
248 {
249 public:
250  virtual ~FilterEngine_GPU() {}
251 
252  virtual void apply(const GpuMat& src, GpuMat& dst, Rect roi = Rect(0,0,-1,-1), Stream& stream = Stream::Null()) = 0;
253 };
254 
256 CV_EXPORTS Ptr<FilterEngine_GPU> createFilter2D_GPU(const Ptr<BaseFilter_GPU>& filter2D, int srcType, int dstType);
257 
260  const Ptr<BaseColumnFilter_GPU>& columnFilter, int srcType, int bufType, int dstType);
262  const Ptr<BaseColumnFilter_GPU>& columnFilter, int srcType, int bufType, int dstType, GpuMat& buf);
263 
266 CV_EXPORTS Ptr<BaseRowFilter_GPU> getRowSumFilter_GPU(int srcType, int sumType, int ksize, int anchor = -1);
267 
270 CV_EXPORTS Ptr<BaseColumnFilter_GPU> getColumnSumFilter_GPU(int sumType, int dstType, int ksize, int anchor = -1);
271 
274 CV_EXPORTS Ptr<BaseFilter_GPU> getBoxFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1, -1));
275 
277 CV_EXPORTS Ptr<FilterEngine_GPU> createBoxFilter_GPU(int srcType, int dstType, const Size& ksize,
278  const Point& anchor = Point(-1,-1));
279 
284 CV_EXPORTS Ptr<BaseFilter_GPU> getMorphologyFilter_GPU(int op, int type, const Mat& kernel, const Size& ksize,
285  Point anchor=Point(-1,-1));
286 
288 CV_EXPORTS Ptr<FilterEngine_GPU> createMorphologyFilter_GPU(int op, int type, const Mat& kernel,
289  const Point& anchor = Point(-1,-1), int iterations = 1);
290 CV_EXPORTS Ptr<FilterEngine_GPU> createMorphologyFilter_GPU(int op, int type, const Mat& kernel, GpuMat& buf,
291  const Point& anchor = Point(-1,-1), int iterations = 1);
292 
295 CV_EXPORTS Ptr<BaseFilter_GPU> getLinearFilter_GPU(int srcType, int dstType, const Mat& kernel, Point anchor = Point(-1, -1), int borderType = BORDER_DEFAULT);
296 
298 CV_EXPORTS Ptr<FilterEngine_GPU> createLinearFilter_GPU(int srcType, int dstType, const Mat& kernel,
299  Point anchor = Point(-1,-1), int borderType = BORDER_DEFAULT);
300 
309 CV_EXPORTS Ptr<BaseRowFilter_GPU> getLinearRowFilter_GPU(int srcType, int bufType, const Mat& rowKernel,
310  int anchor = -1, int borderType = BORDER_DEFAULT);
311 
320 CV_EXPORTS Ptr<BaseColumnFilter_GPU> getLinearColumnFilter_GPU(int bufType, int dstType, const Mat& columnKernel,
321  int anchor = -1, int borderType = BORDER_DEFAULT);
322 
324 CV_EXPORTS Ptr<FilterEngine_GPU> createSeparableLinearFilter_GPU(int srcType, int dstType, const Mat& rowKernel,
325  const Mat& columnKernel, const Point& anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT,
326  int columnBorderType = -1);
327 CV_EXPORTS Ptr<FilterEngine_GPU> createSeparableLinearFilter_GPU(int srcType, int dstType, const Mat& rowKernel,
328  const Mat& columnKernel, GpuMat& buf, const Point& anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT,
329  int columnBorderType = -1);
330 
332 CV_EXPORTS Ptr<FilterEngine_GPU> createDerivFilter_GPU(int srcType, int dstType, int dx, int dy, int ksize,
333  int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
334 CV_EXPORTS Ptr<FilterEngine_GPU> createDerivFilter_GPU(int srcType, int dstType, int dx, int dy, int ksize, GpuMat& buf,
335  int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
336 
338 CV_EXPORTS Ptr<FilterEngine_GPU> createGaussianFilter_GPU(int type, Size ksize, double sigma1, double sigma2 = 0,
339  int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
340 CV_EXPORTS Ptr<FilterEngine_GPU> createGaussianFilter_GPU(int type, Size ksize, GpuMat& buf, double sigma1, double sigma2 = 0,
341  int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
342 
344 CV_EXPORTS Ptr<BaseFilter_GPU> getMaxFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1,-1));
345 
347 CV_EXPORTS Ptr<BaseFilter_GPU> getMinFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1,-1));
348 
351 CV_EXPORTS void boxFilter(const GpuMat& src, GpuMat& dst, int ddepth, Size ksize, Point anchor = Point(-1,-1), Stream& stream = Stream::Null());
352 
354 static inline void blur(const GpuMat& src, GpuMat& dst, Size ksize, Point anchor = Point(-1,-1), Stream& stream = Stream::Null())
355 {
356  boxFilter(src, dst, -1, ksize, anchor, stream);
357 }
358 
360 CV_EXPORTS void erode(const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1);
361 CV_EXPORTS void erode(const GpuMat& src, GpuMat& dst, const Mat& kernel, GpuMat& buf,
362  Point anchor = Point(-1, -1), int iterations = 1,
363  Stream& stream = Stream::Null());
364 
366 CV_EXPORTS void dilate(const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1);
367 CV_EXPORTS void dilate(const GpuMat& src, GpuMat& dst, const Mat& kernel, GpuMat& buf,
368  Point anchor = Point(-1, -1), int iterations = 1,
369  Stream& stream = Stream::Null());
370 
372 CV_EXPORTS void morphologyEx(const GpuMat& src, GpuMat& dst, int op, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1);
373 CV_EXPORTS void morphologyEx(const GpuMat& src, GpuMat& dst, int op, const Mat& kernel, GpuMat& buf1, GpuMat& buf2,
374  Point anchor = Point(-1, -1), int iterations = 1, Stream& stream = Stream::Null());
375 
377 CV_EXPORTS void filter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernel, Point anchor=Point(-1,-1), int borderType = BORDER_DEFAULT, Stream& stream = Stream::Null());
378 
380 CV_EXPORTS void sepFilter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernelX, const Mat& kernelY,
381  Point anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
382 CV_EXPORTS void sepFilter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernelX, const Mat& kernelY, GpuMat& buf,
383  Point anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1,
384  Stream& stream = Stream::Null());
385 
387 CV_EXPORTS void Sobel(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, int ksize = 3, double scale = 1,
388  int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
389 CV_EXPORTS void Sobel(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, GpuMat& buf, int ksize = 3, double scale = 1,
390  int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1, Stream& stream = Stream::Null());
391 
393 CV_EXPORTS void Scharr(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, double scale = 1,
394  int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
395 CV_EXPORTS void Scharr(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, GpuMat& buf, double scale = 1,
396  int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1, Stream& stream = Stream::Null());
397 
399 CV_EXPORTS void GaussianBlur(const GpuMat& src, GpuMat& dst, Size ksize, double sigma1, double sigma2 = 0,
400  int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
401 CV_EXPORTS void GaussianBlur(const GpuMat& src, GpuMat& dst, Size ksize, GpuMat& buf, double sigma1, double sigma2 = 0,
402  int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1, Stream& stream = Stream::Null());
403 
406 CV_EXPORTS void Laplacian(const GpuMat& src, GpuMat& dst, int ddepth, int ksize = 1, double scale = 1, int borderType = BORDER_DEFAULT, Stream& stream = Stream::Null());
407 
408 
410 
412 CV_EXPORTS void gemm(const GpuMat& src1, const GpuMat& src2, double alpha,
413  const GpuMat& src3, double beta, GpuMat& dst, int flags = 0, Stream& stream = Stream::Null());
414 
417 CV_EXPORTS void transpose(const GpuMat& src1, GpuMat& dst, Stream& stream = Stream::Null());
418 
421 CV_EXPORTS void flip(const GpuMat& a, GpuMat& b, int flipCode, Stream& stream = Stream::Null());
422 
426 CV_EXPORTS void LUT(const GpuMat& src, const Mat& lut, GpuMat& dst, Stream& stream = Stream::Null());
427 
429 CV_EXPORTS void merge(const GpuMat* src, size_t n, GpuMat& dst, Stream& stream = Stream::Null());
430 
432 CV_EXPORTS void merge(const vector<GpuMat>& src, GpuMat& dst, Stream& stream = Stream::Null());
433 
435 CV_EXPORTS void split(const GpuMat& src, GpuMat* dst, Stream& stream = Stream::Null());
436 
438 CV_EXPORTS void split(const GpuMat& src, vector<GpuMat>& dst, Stream& stream = Stream::Null());
439 
442 CV_EXPORTS void magnitude(const GpuMat& xy, GpuMat& magnitude, Stream& stream = Stream::Null());
443 
446 CV_EXPORTS void magnitudeSqr(const GpuMat& xy, GpuMat& magnitude, Stream& stream = Stream::Null());
447 
450 CV_EXPORTS void magnitude(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, Stream& stream = Stream::Null());
451 
454 CV_EXPORTS void magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, Stream& stream = Stream::Null());
455 
458 CV_EXPORTS void phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees = false, Stream& stream = Stream::Null());
459 
462 CV_EXPORTS void cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, GpuMat& angle, bool angleInDegrees = false, Stream& stream = Stream::Null());
463 
466 CV_EXPORTS void polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees = false, Stream& stream = Stream::Null());
467 
469 CV_EXPORTS void normalize(const GpuMat& src, GpuMat& dst, double alpha = 1, double beta = 0,
470  int norm_type = NORM_L2, int dtype = -1, const GpuMat& mask = GpuMat());
471 CV_EXPORTS void normalize(const GpuMat& src, GpuMat& dst, double a, double b,
472  int norm_type, int dtype, const GpuMat& mask, GpuMat& norm_buf, GpuMat& cvt_buf);
473 
474 
476 
478 CV_EXPORTS void add(const GpuMat& a, const GpuMat& b, GpuMat& c, const GpuMat& mask = GpuMat(), int dtype = -1, Stream& stream = Stream::Null());
480 CV_EXPORTS void add(const GpuMat& a, const Scalar& sc, GpuMat& c, const GpuMat& mask = GpuMat(), int dtype = -1, Stream& stream = Stream::Null());
481 
483 CV_EXPORTS void subtract(const GpuMat& a, const GpuMat& b, GpuMat& c, const GpuMat& mask = GpuMat(), int dtype = -1, Stream& stream = Stream::Null());
485 CV_EXPORTS void subtract(const GpuMat& a, const Scalar& sc, GpuMat& c, const GpuMat& mask = GpuMat(), int dtype = -1, Stream& stream = Stream::Null());
486 
488 CV_EXPORTS void multiply(const GpuMat& a, const GpuMat& b, GpuMat& c, double scale = 1, int dtype = -1, Stream& stream = Stream::Null());
490 CV_EXPORTS void multiply(const GpuMat& a, const Scalar& sc, GpuMat& c, double scale = 1, int dtype = -1, Stream& stream = Stream::Null());
491 
493 CV_EXPORTS void divide(const GpuMat& a, const GpuMat& b, GpuMat& c, double scale = 1, int dtype = -1, Stream& stream = Stream::Null());
495 CV_EXPORTS void divide(const GpuMat& a, const Scalar& sc, GpuMat& c, double scale = 1, int dtype = -1, Stream& stream = Stream::Null());
497 CV_EXPORTS void divide(double scale, const GpuMat& b, GpuMat& c, int dtype = -1, Stream& stream = Stream::Null());
498 
500 CV_EXPORTS void addWeighted(const GpuMat& src1, double alpha, const GpuMat& src2, double beta, double gamma, GpuMat& dst,
501  int dtype = -1, Stream& stream = Stream::Null());
502 
504 static inline void scaleAdd(const GpuMat& src1, double alpha, const GpuMat& src2, GpuMat& dst, Stream& stream = Stream::Null())
505 {
506  addWeighted(src1, alpha, src2, 1.0, 0.0, dst, -1, stream);
507 }
508 
510 CV_EXPORTS void absdiff(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());
512 CV_EXPORTS void absdiff(const GpuMat& a, const Scalar& s, GpuMat& c, Stream& stream = Stream::Null());
513 
516 CV_EXPORTS void abs(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null());
517 
520 CV_EXPORTS void sqr(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null());
521 
524 CV_EXPORTS void sqrt(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null());
525 
528 CV_EXPORTS void exp(const GpuMat& a, GpuMat& b, Stream& stream = Stream::Null());
529 
532 CV_EXPORTS void log(const GpuMat& a, GpuMat& b, Stream& stream = Stream::Null());
533 
535 // (dst(i,j) = pow( src(i,j) , power), if src.type() is integer
536 // (dst(i,j) = pow(fabs(src(i,j)), power), otherwise
538 CV_EXPORTS void pow(const GpuMat& src, double power, GpuMat& dst, Stream& stream = Stream::Null());
539 
541 CV_EXPORTS void compare(const GpuMat& a, const GpuMat& b, GpuMat& c, int cmpop, Stream& stream = Stream::Null());
542 CV_EXPORTS void compare(const GpuMat& a, Scalar sc, GpuMat& c, int cmpop, Stream& stream = Stream::Null());
543 
545 CV_EXPORTS void bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null());
546 
548 CV_EXPORTS void bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null());
551 CV_EXPORTS void bitwise_or(const GpuMat& src1, const Scalar& sc, GpuMat& dst, Stream& stream = Stream::Null());
552 
554 CV_EXPORTS void bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null());
557 CV_EXPORTS void bitwise_and(const GpuMat& src1, const Scalar& sc, GpuMat& dst, Stream& stream = Stream::Null());
558 
560 CV_EXPORTS void bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null());
563 CV_EXPORTS void bitwise_xor(const GpuMat& src1, const Scalar& sc, GpuMat& dst, Stream& stream = Stream::Null());
564 
567 CV_EXPORTS void rshift(const GpuMat& src, Scalar_<int> sc, GpuMat& dst, Stream& stream = Stream::Null());
568 
571 CV_EXPORTS void lshift(const GpuMat& src, Scalar_<int> sc, GpuMat& dst, Stream& stream = Stream::Null());
572 
574 CV_EXPORTS void min(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream = Stream::Null());
575 
577 CV_EXPORTS void min(const GpuMat& src1, double src2, GpuMat& dst, Stream& stream = Stream::Null());
578 
580 CV_EXPORTS void max(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream = Stream::Null());
581 
583 CV_EXPORTS void max(const GpuMat& src1, double src2, GpuMat& dst, Stream& stream = Stream::Null());
584 
587 
590 CV_EXPORTS void alphaComp(const GpuMat& img1, const GpuMat& img2, GpuMat& dst, int alpha_op, Stream& stream = Stream::Null());
591 
592 
594 
597 CV_EXPORTS void remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap,
598  int interpolation, int borderMode = BORDER_CONSTANT, Scalar borderValue = Scalar(),
599  Stream& stream = Stream::Null());
600 
602 CV_EXPORTS void meanShiftFiltering(const GpuMat& src, GpuMat& dst, int sp, int sr,
604  Stream& stream = Stream::Null());
605 
607 CV_EXPORTS void meanShiftProc(const GpuMat& src, GpuMat& dstr, GpuMat& dstsp, int sp, int sr,
609  Stream& stream = Stream::Null());
610 
612 CV_EXPORTS void meanShiftSegmentation(const GpuMat& src, Mat& dst, int sp, int sr, int minsize,
614 
618 CV_EXPORTS void drawColorDisp(const GpuMat& src_disp, GpuMat& dst_disp, int ndisp, Stream& stream = Stream::Null());
619 
625 CV_EXPORTS void reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q, int dst_cn = 4, Stream& stream = Stream::Null());
626 
628 CV_EXPORTS void cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn = 0, Stream& stream = Stream::Null());
629 
630 enum
631 {
632  // Bayer Demosaicing (Malvar, He, and Cutler)
637 
642 
647 };
648 CV_EXPORTS void demosaicing(const GpuMat& src, GpuMat& dst, int code, int dcn = -1, Stream& stream = Stream::Null());
649 
655 CV_EXPORTS void swapChannels(GpuMat& image, const int dstOrder[4], Stream& stream = Stream::Null());
656 
658 CV_EXPORTS void gammaCorrection(const GpuMat& src, GpuMat& dst, bool forward = true, Stream& stream = Stream::Null());
659 
661 CV_EXPORTS double threshold(const GpuMat& src, GpuMat& dst, double thresh, double maxval, int type, Stream& stream = Stream::Null());
662 
665 CV_EXPORTS void resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx=0, double fy=0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null());
666 
669 CV_EXPORTS void warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR,
670  int borderMode = BORDER_CONSTANT, Scalar borderValue = Scalar(), Stream& stream = Stream::Null());
671 
672 CV_EXPORTS void buildWarpAffineMaps(const Mat& M, bool inverse, Size dsize, GpuMat& xmap, GpuMat& ymap, Stream& stream = Stream::Null());
673 
676 CV_EXPORTS void warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR,
677  int borderMode = BORDER_CONSTANT, Scalar borderValue = Scalar(), Stream& stream = Stream::Null());
678 
679 CV_EXPORTS void buildWarpPerspectiveMaps(const Mat& M, bool inverse, Size dsize, GpuMat& xmap, GpuMat& ymap, Stream& stream = Stream::Null());
680 
682 CV_EXPORTS void buildWarpPlaneMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat& R, const Mat &T, float scale,
683  GpuMat& map_x, GpuMat& map_y, Stream& stream = Stream::Null());
684 
686 CV_EXPORTS void buildWarpCylindricalMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat& R, float scale,
687  GpuMat& map_x, GpuMat& map_y, Stream& stream = Stream::Null());
688 
690 CV_EXPORTS void buildWarpSphericalMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat& R, float scale,
691  GpuMat& map_x, GpuMat& map_y, Stream& stream = Stream::Null());
692 
696 CV_EXPORTS void rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift = 0, double yShift = 0,
697  int interpolation = INTER_LINEAR, Stream& stream = Stream::Null());
698 
700 CV_EXPORTS void copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, int borderType,
701  const Scalar& value = Scalar(), Stream& stream = Stream::Null());
702 
706 CV_EXPORTS void integral(const GpuMat& src, GpuMat& sum, Stream& stream = Stream::Null());
708 CV_EXPORTS void integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer, Stream& stream = Stream::Null());
709 
713 CV_EXPORTS void sqrIntegral(const GpuMat& src, GpuMat& sqsum, Stream& stream = Stream::Null());
714 
716 CV_EXPORTS void columnSum(const GpuMat& src, GpuMat& sum);
717 
721 CV_EXPORTS void rectStdDev(const GpuMat& src, const GpuMat& sqr, GpuMat& dst, const Rect& rect, Stream& stream = Stream::Null());
722 
724 CV_EXPORTS void cornerHarris(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, double k, int borderType = BORDER_REFLECT101);
725 CV_EXPORTS void cornerHarris(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, int blockSize, int ksize, double k, int borderType = BORDER_REFLECT101);
726 CV_EXPORTS void cornerHarris(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, GpuMat& buf, int blockSize, int ksize, double k,
727  int borderType = BORDER_REFLECT101, Stream& stream = Stream::Null());
728 
730 CV_EXPORTS void cornerMinEigenVal(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, int borderType=BORDER_REFLECT101);
731 CV_EXPORTS void cornerMinEigenVal(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, int blockSize, int ksize, int borderType=BORDER_REFLECT101);
732 CV_EXPORTS void cornerMinEigenVal(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, GpuMat& buf, int blockSize, int ksize,
733  int borderType=BORDER_REFLECT101, Stream& stream = Stream::Null());
734 
737 CV_EXPORTS void mulSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flags, bool conjB=false, Stream& stream = Stream::Null());
738 
741 CV_EXPORTS void mulAndScaleSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flags, float scale, bool conjB=false, Stream& stream = Stream::Null());
742 
754 CV_EXPORTS void dft(const GpuMat& src, GpuMat& dst, Size dft_size, int flags=0, Stream& stream = Stream::Null());
755 
756 struct CV_EXPORTS ConvolveBuf
757 {
763 
764  GpuMat image_spect, templ_spect, result_spect;
765  GpuMat image_block, templ_block, result_data;
766 
767  void create(Size image_size, Size templ_size);
768  static Size estimateBlockSize(Size result_size, Size templ_size);
769 };
770 
771 
775 CV_EXPORTS void convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result, bool ccorr = false);
776 CV_EXPORTS void convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result, bool ccorr, ConvolveBuf& buf, Stream& stream = Stream::Null());
777 
778 struct CV_EXPORTS MatchTemplateBuf
779 {
781  GpuMat imagef, templf;
782  std::vector<GpuMat> images;
783  std::vector<GpuMat> image_sums;
784  std::vector<GpuMat> image_sqsums;
785 };
786 
788 CV_EXPORTS void matchTemplate(const GpuMat& image, const GpuMat& templ, GpuMat& result, int method, Stream &stream = Stream::Null());
789 
791 CV_EXPORTS void matchTemplate(const GpuMat& image, const GpuMat& templ, GpuMat& result, int method, MatchTemplateBuf &buf, Stream& stream = Stream::Null());
792 
794 CV_EXPORTS void pyrDown(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null());
795 
797 CV_EXPORTS void pyrUp(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null());
798 
801 CV_EXPORTS void blendLinear(const GpuMat& img1, const GpuMat& img2, const GpuMat& weights1, const GpuMat& weights2,
802  GpuMat& result, Stream& stream = Stream::Null());
803 
805 CV_EXPORTS void bilateralFilter(const GpuMat& src, GpuMat& dst, int kernel_size, float sigma_color, float sigma_spatial,
806  int borderMode = BORDER_DEFAULT, Stream& stream = Stream::Null());
807 
809 CV_EXPORTS void nonLocalMeans(const GpuMat& src, GpuMat& dst, float h, int search_window = 21, int block_size = 7, int borderMode = BORDER_DEFAULT, Stream& s = Stream::Null());
810 
813 {
814 public:
816  void simpleMethod(const GpuMat& src, GpuMat& dst, float h, int search_window = 21, int block_size = 7, Stream& s = Stream::Null());
817 
819  void labMethod(const GpuMat& src, GpuMat& dst, float h_luminance, float h_color, int search_window = 21, int block_size = 7, Stream& s = Stream::Null());
820 
821 private:
822 
823  GpuMat buffer, extended_src_buffer;
824  GpuMat lab, l, ab;
825 };
826 
827 struct CV_EXPORTS CannyBuf
828 {
829  void create(const Size& image_size, int apperture_size = 3);
830  void release();
831 
832  GpuMat dx, dy;
835  GpuMat st1, st2;
838 
839  CannyBuf() {}
840  explicit CannyBuf(const Size& image_size, int apperture_size = 3) {create(image_size, apperture_size);}
841  CannyBuf(const GpuMat& dx_, const GpuMat& dy_);
842 };
843 
844 CV_EXPORTS void Canny(const GpuMat& image, GpuMat& edges, double low_thresh, double high_thresh, int apperture_size = 3, bool L2gradient = false);
845 CV_EXPORTS void Canny(const GpuMat& image, CannyBuf& buf, GpuMat& edges, double low_thresh, double high_thresh, int apperture_size = 3, bool L2gradient = false);
846 CV_EXPORTS void Canny(const GpuMat& dx, const GpuMat& dy, GpuMat& edges, double low_thresh, double high_thresh, bool L2gradient = false);
847 CV_EXPORTS void Canny(const GpuMat& dx, const GpuMat& dy, CannyBuf& buf, GpuMat& edges, double low_thresh, double high_thresh, bool L2gradient = false);
848 
849 class CV_EXPORTS ImagePyramid
850 {
851 public:
852  inline ImagePyramid() : nLayers_(0) {}
853  inline ImagePyramid(const GpuMat& img, int nLayers, Stream& stream = Stream::Null())
854  {
855  build(img, nLayers, stream);
856  }
857 
858  void build(const GpuMat& img, int nLayers, Stream& stream = Stream::Null());
859 
860  void getLayer(GpuMat& outImg, Size outRoi, Stream& stream = Stream::Null()) const;
861 
862  inline void release()
863  {
864  layer0_.release();
865  pyramid_.clear();
866  nLayers_ = 0;
867  }
868 
869 private:
870  GpuMat layer0_;
871  std::vector<GpuMat> pyramid_;
872  int nLayers_;
873 };
874 
876 
878 {
881 };
882 
883 CV_EXPORTS void HoughLines(const GpuMat& src, GpuMat& lines, float rho, float theta, int threshold, bool doSort = false, int maxLines = 4096);
884 CV_EXPORTS void HoughLines(const GpuMat& src, GpuMat& lines, HoughLinesBuf& buf, float rho, float theta, int threshold, bool doSort = false, int maxLines = 4096);
885 CV_EXPORTS void HoughLinesDownload(const GpuMat& d_lines, OutputArray h_lines, OutputArray h_votes = noArray());
886 
888 
890 CV_EXPORTS void HoughLinesP(const GpuMat& image, GpuMat& lines, HoughLinesBuf& buf, float rho, float theta, int minLineLength, int maxLineGap, int maxLines = 4096);
891 
893 
895 {
900 };
901 
902 CV_EXPORTS void HoughCircles(const GpuMat& src, GpuMat& circles, int method, float dp, float minDist, int cannyThreshold, int votesThreshold, int minRadius, int maxRadius, int maxCircles = 4096);
903 CV_EXPORTS void HoughCircles(const GpuMat& src, GpuMat& circles, HoughCirclesBuf& buf, int method, float dp, float minDist, int cannyThreshold, int votesThreshold, int minRadius, int maxRadius, int maxCircles = 4096);
904 CV_EXPORTS void HoughCirclesDownload(const GpuMat& d_circles, OutputArray h_circles);
905 
909 class CV_EXPORTS GeneralizedHough_GPU : public Algorithm
910 {
911 public:
912  static Ptr<GeneralizedHough_GPU> create(int method);
913 
914  virtual ~GeneralizedHough_GPU();
915 
917  void setTemplate(const GpuMat& templ, int cannyThreshold = 100, Point templCenter = Point(-1, -1));
918  void setTemplate(const GpuMat& edges, const GpuMat& dx, const GpuMat& dy, Point templCenter = Point(-1, -1));
919 
921  void detect(const GpuMat& image, GpuMat& positions, int cannyThreshold = 100);
922  void detect(const GpuMat& edges, const GpuMat& dx, const GpuMat& dy, GpuMat& positions);
923 
924  void download(const GpuMat& d_positions, OutputArray h_positions, OutputArray h_votes = noArray());
925 
926  void release();
927 
928 protected:
929  virtual void setTemplateImpl(const GpuMat& edges, const GpuMat& dx, const GpuMat& dy, Point templCenter) = 0;
930  virtual void detectImpl(const GpuMat& edges, const GpuMat& dx, const GpuMat& dy, GpuMat& positions) = 0;
931  virtual void releaseImpl() = 0;
932 
933 private:
934  GpuMat edges_;
935  CannyBuf cannyBuf_;
936 };
937 
939 
942 CV_EXPORTS void meanStdDev(const GpuMat& mtx, Scalar& mean, Scalar& stddev);
944 CV_EXPORTS void meanStdDev(const GpuMat& mtx, Scalar& mean, Scalar& stddev, GpuMat& buf);
945 
949 CV_EXPORTS double norm(const GpuMat& src1, int normType=NORM_L2);
950 CV_EXPORTS double norm(const GpuMat& src1, int normType, GpuMat& buf);
951 CV_EXPORTS double norm(const GpuMat& src1, int normType, const GpuMat& mask, GpuMat& buf);
952 
956 CV_EXPORTS double norm(const GpuMat& src1, const GpuMat& src2, int normType=NORM_L2);
957 
960 CV_EXPORTS Scalar sum(const GpuMat& src);
961 CV_EXPORTS Scalar sum(const GpuMat& src, GpuMat& buf);
962 CV_EXPORTS Scalar sum(const GpuMat& src, const GpuMat& mask, GpuMat& buf);
963 
966 CV_EXPORTS Scalar absSum(const GpuMat& src);
967 CV_EXPORTS Scalar absSum(const GpuMat& src, GpuMat& buf);
968 CV_EXPORTS Scalar absSum(const GpuMat& src, const GpuMat& mask, GpuMat& buf);
969 
972 CV_EXPORTS Scalar sqrSum(const GpuMat& src);
973 CV_EXPORTS Scalar sqrSum(const GpuMat& src, GpuMat& buf);
974 CV_EXPORTS Scalar sqrSum(const GpuMat& src, const GpuMat& mask, GpuMat& buf);
975 
977 CV_EXPORTS void minMax(const GpuMat& src, double* minVal, double* maxVal=0, const GpuMat& mask=GpuMat());
978 CV_EXPORTS void minMax(const GpuMat& src, double* minVal, double* maxVal, const GpuMat& mask, GpuMat& buf);
979 
981 CV_EXPORTS void minMaxLoc(const GpuMat& src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0,
982  const GpuMat& mask=GpuMat());
983 CV_EXPORTS void minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point* minLoc, Point* maxLoc,
984  const GpuMat& mask, GpuMat& valbuf, GpuMat& locbuf);
985 
987 CV_EXPORTS int countNonZero(const GpuMat& src);
988 CV_EXPORTS int countNonZero(const GpuMat& src, GpuMat& buf);
989 
991 CV_EXPORTS void reduce(const GpuMat& mtx, GpuMat& vec, int dim, int reduceOp, int dtype = -1, Stream& stream = Stream::Null());
992 
993 
995 
996 CV_EXPORTS void transformPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec,
997  GpuMat& dst, Stream& stream = Stream::Null());
998 
999 CV_EXPORTS void projectPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec,
1000  const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst,
1001  Stream& stream = Stream::Null());
1002 
1003 CV_EXPORTS void solvePnPRansac(const Mat& object, const Mat& image, const Mat& camera_mat,
1004  const Mat& dist_coef, Mat& rvec, Mat& tvec, bool use_extrinsic_guess=false,
1005  int num_iters=100, float max_dist=8.0, int min_inlier_count=100,
1006  std::vector<int>* inliers=NULL);
1007 
1009 
1011 CV_EXPORTS void graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTransp, GpuMat& top, GpuMat& bottom, GpuMat& labels,
1012  GpuMat& buf, Stream& stream = Stream::Null());
1013 
1015 CV_EXPORTS void graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTransp, GpuMat& top, GpuMat& topLeft, GpuMat& topRight,
1016  GpuMat& bottom, GpuMat& bottomLeft, GpuMat& bottomRight,
1017  GpuMat& labels,
1018  GpuMat& buf, Stream& stream = Stream::Null());
1019 
1021 CV_EXPORTS void connectivityMask(const GpuMat& image, GpuMat& mask, const cv::Scalar& lo, const cv::Scalar& hi, Stream& stream = Stream::Null());
1022 
1024 CV_EXPORTS void labelComponents(const GpuMat& mask, GpuMat& components, int flags = 0, Stream& stream = Stream::Null());
1025 
1027 
1029 CV_EXPORTS void evenLevels(GpuMat& levels, int nLevels, int lowerLevel, int upperLevel);
1033 CV_EXPORTS void histEven(const GpuMat& src, GpuMat& hist, int histSize, int lowerLevel, int upperLevel, Stream& stream = Stream::Null());
1034 CV_EXPORTS void histEven(const GpuMat& src, GpuMat& hist, GpuMat& buf, int histSize, int lowerLevel, int upperLevel, Stream& stream = Stream::Null());
1039 CV_EXPORTS void histEven(const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4], Stream& stream = Stream::Null());
1040 CV_EXPORTS void histEven(const GpuMat& src, GpuMat hist[4], GpuMat& buf, int histSize[4], int lowerLevel[4], int upperLevel[4], Stream& stream = Stream::Null());
1045 CV_EXPORTS void histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels, Stream& stream = Stream::Null());
1046 CV_EXPORTS void histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels, GpuMat& buf, Stream& stream = Stream::Null());
1052 CV_EXPORTS void histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4], Stream& stream = Stream::Null());
1053 CV_EXPORTS void histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4], GpuMat& buf, Stream& stream = Stream::Null());
1054 
1057 CV_EXPORTS void calcHist(const GpuMat& src, GpuMat& hist, Stream& stream = Stream::Null());
1058 CV_EXPORTS void calcHist(const GpuMat& src, GpuMat& hist, GpuMat& buf, Stream& stream = Stream::Null());
1059 
1061 CV_EXPORTS void equalizeHist(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null());
1062 CV_EXPORTS void equalizeHist(const GpuMat& src, GpuMat& dst, GpuMat& hist, Stream& stream = Stream::Null());
1063 CV_EXPORTS void equalizeHist(const GpuMat& src, GpuMat& dst, GpuMat& hist, GpuMat& buf, Stream& stream = Stream::Null());
1064 
1065 class CV_EXPORTS CLAHE : public cv::CLAHE
1066 {
1067 public:
1068  using cv::CLAHE::apply;
1069  virtual void apply(InputArray src, OutputArray dst, Stream& stream) = 0;
1070 };
1071 CV_EXPORTS Ptr<cv::gpu::CLAHE> createCLAHE(double clipLimit = 40.0, Size tileGridSize = Size(8, 8));
1072 
1074 
1075 class CV_EXPORTS StereoBM_GPU
1076 {
1077 public:
1078  enum { BASIC_PRESET = 0, PREFILTER_XSOBEL = 1 };
1079 
1080  enum { DEFAULT_NDISP = 64, DEFAULT_WINSZ = 19 };
1081 
1083  StereoBM_GPU();
1085  StereoBM_GPU(int preset, int ndisparities = DEFAULT_NDISP, int winSize = DEFAULT_WINSZ);
1086 
1089  void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream = Stream::Null());
1090 
1092  // if current GPU will be faster than CPU in this algorithm.
1093  // It queries current active device.
1094  static bool checkIfGpuCallReasonable();
1095 
1096  int preset;
1097  int ndisp;
1098  int winSize;
1099 
1100  // If avergeTexThreshold == 0 => post procesing is disabled
1101  // If avergeTexThreshold != 0 then disparity is set 0 in each point (x,y) where for left image
1102  // SumOfHorizontalGradiensInWindow(x, y, winSize) < (winSize * winSize) * avergeTexThreshold
1103  // i.e. input left image is low textured.
1105 
1106 private:
1107  GpuMat minSSD, leBuf, riBuf;
1108 };
1109 
1111 // "Efficient Belief Propagation for Early Vision"
1112 // P.Felzenszwalb
1113 
1114 class CV_EXPORTS StereoBeliefPropagation
1115 {
1116 public:
1117  enum { DEFAULT_NDISP = 64 };
1118  enum { DEFAULT_ITERS = 5 };
1119  enum { DEFAULT_LEVELS = 5 };
1120 
1121  static void estimateRecommendedParams(int width, int height, int& ndisp, int& iters, int& levels);
1122 
1124  explicit StereoBeliefPropagation(int ndisp = DEFAULT_NDISP,
1125  int iters = DEFAULT_ITERS,
1126  int levels = DEFAULT_LEVELS,
1127  int msg_type = CV_32F);
1128 
1135  StereoBeliefPropagation(int ndisp, int iters, int levels,
1136  float max_data_term, float data_weight,
1137  float max_disc_term, float disc_single_jump,
1138  int msg_type = CV_32F);
1139 
1142  void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream = Stream::Null());
1143 
1144 
1146  void operator()(const GpuMat& data, GpuMat& disparity, Stream& stream = Stream::Null());
1147 
1148  int ndisp;
1149 
1150  int iters;
1151  int levels;
1152 
1157 
1159 private:
1160  GpuMat u, d, l, r, u2, d2, l2, r2;
1161  std::vector<GpuMat> datas;
1162  GpuMat out;
1163 };
1164 
1166 // "A Constant-Space Belief Propagation Algorithm for Stereo Matching"
1167 // Qingxiong Yang, Liang Wang, Narendra Ahuja
1168 // http://vision.ai.uiuc.edu/~qyang6/
1169 
1170 class CV_EXPORTS StereoConstantSpaceBP
1171 {
1172 public:
1173  enum { DEFAULT_NDISP = 128 };
1174  enum { DEFAULT_ITERS = 8 };
1175  enum { DEFAULT_LEVELS = 4 };
1176  enum { DEFAULT_NR_PLANE = 4 };
1177 
1178  static void estimateRecommendedParams(int width, int height, int& ndisp, int& iters, int& levels, int& nr_plane);
1179 
1181  explicit StereoConstantSpaceBP(int ndisp = DEFAULT_NDISP,
1182  int iters = DEFAULT_ITERS,
1183  int levels = DEFAULT_LEVELS,
1184  int nr_plane = DEFAULT_NR_PLANE,
1185  int msg_type = CV_32F);
1186 
1190  StereoConstantSpaceBP(int ndisp, int iters, int levels, int nr_plane,
1191  float max_data_term, float data_weight, float max_disc_term, float disc_single_jump,
1192  int min_disp_th = 0,
1193  int msg_type = CV_32F);
1194 
1197  void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream = Stream::Null());
1198 
1199  int ndisp;
1200 
1201  int iters;
1202  int levels;
1203 
1205 
1210 
1212 
1214 
1216 private:
1217  GpuMat messages_buffers;
1218 
1219  GpuMat temp;
1220  GpuMat out;
1221 };
1222 
1224 // Disparity map refinement using joint bilateral filtering given a single color image.
1225 // Qingxiong Yang, Liang Wang, Narendra Ahuja
1226 // http://vision.ai.uiuc.edu/~qyang6/
1227 
1229 {
1230 public:
1231  enum { DEFAULT_NDISP = 64 };
1232  enum { DEFAULT_RADIUS = 3 };
1233  enum { DEFAULT_ITERS = 1 };
1234 
1236  explicit DisparityBilateralFilter(int ndisp = DEFAULT_NDISP, int radius = DEFAULT_RADIUS, int iters = DEFAULT_ITERS);
1237 
1241  DisparityBilateralFilter(int ndisp, int radius, int iters, float edge_threshold, float max_disc_threshold, float sigma_range);
1242 
1245  void operator()(const GpuMat& disparity, const GpuMat& image, GpuMat& dst, Stream& stream = Stream::Null());
1246 
1247 private:
1248  int ndisp;
1249  int radius;
1250  int iters;
1251 
1252  float edge_threshold;
1253  float max_disc_threshold;
1254  float sigma_range;
1255 
1256  GpuMat table_color;
1257  GpuMat table_space;
1258 };
1259 
1260 
1262 struct CV_EXPORTS HOGConfidence
1263 {
1264  double scale;
1265  vector<Point> locations;
1266  vector<double> confidences;
1267  vector<double> part_scores[4];
1268 };
1269 
1270 struct CV_EXPORTS HOGDescriptor
1271 {
1272  enum { DEFAULT_WIN_SIGMA = -1 };
1273  enum { DEFAULT_NLEVELS = 64 };
1274  enum { DESCR_FORMAT_ROW_BY_ROW, DESCR_FORMAT_COL_BY_COL };
1275 
1276  HOGDescriptor(Size win_size=Size(64, 128), Size block_size=Size(16, 16),
1277  Size block_stride=Size(8, 8), Size cell_size=Size(8, 8),
1278  int nbins=9, double win_sigma=DEFAULT_WIN_SIGMA,
1279  double threshold_L2hys=0.2, bool gamma_correction=true,
1280  int nlevels=DEFAULT_NLEVELS);
1281 
1282  size_t getDescriptorSize() const;
1283  size_t getBlockHistogramSize() const;
1284 
1285  void setSVMDetector(const vector<float>& detector);
1286 
1287  static vector<float> getDefaultPeopleDetector();
1288  static vector<float> getPeopleDetector48x96();
1289  static vector<float> getPeopleDetector64x128();
1290 
1291  void detect(const GpuMat& img, vector<Point>& found_locations,
1292  double hit_threshold=0, Size win_stride=Size(),
1293  Size padding=Size());
1294 
1295  void detectMultiScale(const GpuMat& img, vector<Rect>& found_locations,
1296  double hit_threshold=0, Size win_stride=Size(),
1297  Size padding=Size(), double scale0=1.05,
1298  int group_threshold=2);
1299 
1300  void computeConfidence(const GpuMat& img, vector<Point>& hits, double hit_threshold,
1301  Size win_stride, Size padding, vector<Point>& locations, vector<double>& confidences);
1302 
1303  void computeConfidenceMultiScale(const GpuMat& img, vector<Rect>& found_locations,
1304  double hit_threshold, Size win_stride, Size padding,
1305  vector<HOGConfidence> &conf_out, int group_threshold);
1306 
1307  void getDescriptors(const GpuMat& img, Size win_stride,
1309  int descr_format=DESCR_FORMAT_COL_BY_COL);
1310 
1315  int nbins;
1316  double win_sigma;
1319  int nlevels;
1320 
1321 protected:
1322  void computeBlockHistograms(const GpuMat& img);
1323  void computeGradient(const GpuMat& img, GpuMat& grad, GpuMat& qangle);
1324 
1325  double getWinSigma() const;
1326  bool checkDetectorSize() const;
1327 
1328  static int numPartsWithin(int size, int part_size, int stride);
1329  static Size numPartsWithin(Size size, Size part_size, Size stride);
1330 
1331  // Coefficients of the separating plane
1332  float free_coef;
1334 
1335  // Results of the last classification step
1338 
1339  // Results of the last histogram evaluation step
1340  GpuMat block_hists, block_hists_buf;
1341 
1342  // Gradients conputation results
1343  GpuMat grad, qangle, grad_buf, qangle_buf;
1344 
1345  // returns subbuffer with required size, reallocates buffer if nessesary.
1346  static GpuMat getBuffer(const Size& sz, int type, GpuMat& buf);
1347  static GpuMat getBuffer(int rows, int cols, int type, GpuMat& buf);
1348 
1349  std::vector<GpuMat> image_scales;
1350 };
1351 
1352 
1354 
1356 {
1357 public:
1358  enum DistType {L1Dist = 0, L2Dist, HammingDist};
1359 
1360  explicit BruteForceMatcher_GPU_base(DistType distType = L2Dist);
1361 
1362  // Add descriptors to train descriptor collection
1363  void add(const std::vector<GpuMat>& descCollection);
1364 
1365  // Get train descriptors collection
1366  const std::vector<GpuMat>& getTrainDescriptors() const;
1367 
1368  // Clear train descriptors collection
1369  void clear();
1370 
1371  // Return true if there are not train descriptors in collection
1372  bool empty() const;
1373 
1374  // Return true if the matcher supports mask in match methods
1375  bool isMaskSupported() const;
1376 
1377  // Find one best match for each query descriptor
1378  void matchSingle(const GpuMat& query, const GpuMat& train,
1379  GpuMat& trainIdx, GpuMat& distance,
1380  const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null());
1381 
1382  // Download trainIdx and distance and convert it to CPU vector with DMatch
1383  static void matchDownload(const GpuMat& trainIdx, const GpuMat& distance, std::vector<DMatch>& matches);
1384  // Convert trainIdx and distance to vector with DMatch
1385  static void matchConvert(const Mat& trainIdx, const Mat& distance, std::vector<DMatch>& matches);
1386 
1387  // Find one best match for each query descriptor
1388  void match(const GpuMat& query, const GpuMat& train, std::vector<DMatch>& matches, const GpuMat& mask = GpuMat());
1389 
1390  // Make gpu collection of trains and masks in suitable format for matchCollection function
1391  void makeGpuCollection(GpuMat& trainCollection, GpuMat& maskCollection, const std::vector<GpuMat>& masks = std::vector<GpuMat>());
1392 
1393  // Find one best match from train collection for each query descriptor
1394  void matchCollection(const GpuMat& query, const GpuMat& trainCollection,
1395  GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance,
1396  const GpuMat& masks = GpuMat(), Stream& stream = Stream::Null());
1397 
1398  // Download trainIdx, imgIdx and distance and convert it to vector with DMatch
1399  static void matchDownload(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, std::vector<DMatch>& matches);
1400  // Convert trainIdx, imgIdx and distance to vector with DMatch
1401  static void matchConvert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, std::vector<DMatch>& matches);
1402 
1403  // Find one best match from train collection for each query descriptor.
1404  void match(const GpuMat& query, std::vector<DMatch>& matches, const std::vector<GpuMat>& masks = std::vector<GpuMat>());
1405 
1406  // Find k best matches for each query descriptor (in increasing order of distances)
1407  void knnMatchSingle(const GpuMat& query, const GpuMat& train,
1408  GpuMat& trainIdx, GpuMat& distance, GpuMat& allDist, int k,
1409  const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null());
1410 
1411  // Download trainIdx and distance and convert it to vector with DMatch
1412  // compactResult is used when mask is not empty. If compactResult is false matches
1413  // vector will have the same size as queryDescriptors rows. If compactResult is true
1414  // matches vector will not contain matches for fully masked out query descriptors.
1415  static void knnMatchDownload(const GpuMat& trainIdx, const GpuMat& distance,
1416  std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
1417  // Convert trainIdx and distance to vector with DMatch
1418  static void knnMatchConvert(const Mat& trainIdx, const Mat& distance,
1419  std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
1420 
1421  // Find k best matches for each query descriptor (in increasing order of distances).
1422  // compactResult is used when mask is not empty. If compactResult is false matches
1423  // vector will have the same size as queryDescriptors rows. If compactResult is true
1424  // matches vector will not contain matches for fully masked out query descriptors.
1425  void knnMatch(const GpuMat& query, const GpuMat& train,
1426  std::vector< std::vector<DMatch> >& matches, int k, const GpuMat& mask = GpuMat(),
1427  bool compactResult = false);
1428 
1429  // Find k best matches from train collection for each query descriptor (in increasing order of distances)
1430  void knnMatch2Collection(const GpuMat& query, const GpuMat& trainCollection,
1431  GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance,
1432  const GpuMat& maskCollection = GpuMat(), Stream& stream = Stream::Null());
1433 
1434  // Download trainIdx and distance and convert it to vector with DMatch
1435  // compactResult is used when mask is not empty. If compactResult is false matches
1436  // vector will have the same size as queryDescriptors rows. If compactResult is true
1437  // matches vector will not contain matches for fully masked out query descriptors.
1438  static void knnMatch2Download(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance,
1439  std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
1440  // Convert trainIdx and distance to vector with DMatch
1441  static void knnMatch2Convert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance,
1442  std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
1443 
1444  // Find k best matches for each query descriptor (in increasing order of distances).
1445  // compactResult is used when mask is not empty. If compactResult is false matches
1446  // vector will have the same size as queryDescriptors rows. If compactResult is true
1447  // matches vector will not contain matches for fully masked out query descriptors.
1448  void knnMatch(const GpuMat& query, std::vector< std::vector<DMatch> >& matches, int k,
1449  const std::vector<GpuMat>& masks = std::vector<GpuMat>(), bool compactResult = false);
1450 
1451  // Find best matches for each query descriptor which have distance less than maxDistance.
1452  // nMatches.at<int>(0, queryIdx) will contain matches count for queryIdx.
1453  // carefully nMatches can be greater than trainIdx.cols - it means that matcher didn't find all matches,
1454  // because it didn't have enough memory.
1455  // If trainIdx is empty, then trainIdx and distance will be created with size nQuery x max((nTrain / 100), 10),
1456  // otherwize user can pass own allocated trainIdx and distance with size nQuery x nMaxMatches
1457  // Matches doesn't sorted.
1458  void radiusMatchSingle(const GpuMat& query, const GpuMat& train,
1459  GpuMat& trainIdx, GpuMat& distance, GpuMat& nMatches, float maxDistance,
1460  const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null());
1461 
1462  // Download trainIdx, nMatches and distance and convert it to vector with DMatch.
1463  // matches will be sorted in increasing order of distances.
1464  // compactResult is used when mask is not empty. If compactResult is false matches
1465  // vector will have the same size as queryDescriptors rows. If compactResult is true
1466  // matches vector will not contain matches for fully masked out query descriptors.
1467  static void radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& distance, const GpuMat& nMatches,
1468  std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
1469  // Convert trainIdx, nMatches and distance to vector with DMatch.
1470  static void radiusMatchConvert(const Mat& trainIdx, const Mat& distance, const Mat& nMatches,
1471  std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
1472 
1473  // Find best matches for each query descriptor which have distance less than maxDistance
1474  // in increasing order of distances).
1475  void radiusMatch(const GpuMat& query, const GpuMat& train,
1476  std::vector< std::vector<DMatch> >& matches, float maxDistance,
1477  const GpuMat& mask = GpuMat(), bool compactResult = false);
1478 
1479  // Find best matches for each query descriptor which have distance less than maxDistance.
1480  // If trainIdx is empty, then trainIdx and distance will be created with size nQuery x max((nQuery / 100), 10),
1481  // otherwize user can pass own allocated trainIdx and distance with size nQuery x nMaxMatches
1482  // Matches doesn't sorted.
1483  void radiusMatchCollection(const GpuMat& query, GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance, GpuMat& nMatches, float maxDistance,
1484  const std::vector<GpuMat>& masks = std::vector<GpuMat>(), Stream& stream = Stream::Null());
1485 
1486  // Download trainIdx, imgIdx, nMatches and distance and convert it to vector with DMatch.
1487  // matches will be sorted in increasing order of distances.
1488  // compactResult is used when mask is not empty. If compactResult is false matches
1489  // vector will have the same size as queryDescriptors rows. If compactResult is true
1490  // matches vector will not contain matches for fully masked out query descriptors.
1491  static void radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, const GpuMat& nMatches,
1492  std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
1493  // Convert trainIdx, nMatches and distance to vector with DMatch.
1494  static void radiusMatchConvert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, const Mat& nMatches,
1495  std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
1496 
1497  // Find best matches from train collection for each query descriptor which have distance less than
1498  // maxDistance (in increasing order of distances).
1499  void radiusMatch(const GpuMat& query, std::vector< std::vector<DMatch> >& matches, float maxDistance,
1500  const std::vector<GpuMat>& masks = std::vector<GpuMat>(), bool compactResult = false);
1501 
1503 
1504 private:
1505  std::vector<GpuMat> trainDescCollection;
1506 };
1507 
1508 template <class Distance>
1509 class CV_EXPORTS BruteForceMatcher_GPU;
1510 
1511 template <typename T>
1512 class CV_EXPORTS BruteForceMatcher_GPU< L1<T> > : public BruteForceMatcher_GPU_base
1513 {
1514 public:
1517 };
1518 template <typename T>
1519 class CV_EXPORTS BruteForceMatcher_GPU< L2<T> > : public BruteForceMatcher_GPU_base
1520 {
1521 public:
1524 };
1525 template <> class CV_EXPORTS BruteForceMatcher_GPU< Hamming > : public BruteForceMatcher_GPU_base
1526 {
1527 public:
1530 };
1531 
1533 {
1534 public:
1535  explicit BFMatcher_GPU(int norm = NORM_L2) : BruteForceMatcher_GPU_base(norm == NORM_L1 ? L1Dist : norm == NORM_L2 ? L2Dist : HammingDist) {}
1536 };
1537 
1539 // The cascade classifier class for object detection: supports old haar and new lbp xlm formats and nvbin for haar cascades olny.
1540 class CV_EXPORTS CascadeClassifier_GPU
1541 {
1542 public:
1544  CascadeClassifier_GPU(const std::string& filename);
1546 
1547  bool empty() const;
1548  bool load(const std::string& filename);
1549  void release();
1550 
1551  /* returns number of detected objects */
1552  int detectMultiScale(const GpuMat& image, GpuMat& objectsBuf, double scaleFactor = 1.2, int minNeighbors = 4, Size minSize = Size());
1553  int detectMultiScale(const GpuMat& image, GpuMat& objectsBuf, Size maxObjectSize, Size minSize = Size(), double scaleFactor = 1.1, int minNeighbors = 4);
1554 
1557 
1558  Size getClassifierSize() const;
1559 
1560 private:
1561  struct CascadeClassifierImpl;
1562  CascadeClassifierImpl* impl;
1563  struct HaarCascade;
1564  struct LbpCascade;
1565  friend class CascadeClassifier_GPU_LBP;
1566 };
1567 
1569 
1570 class CV_EXPORTS FAST_GPU
1571 {
1572 public:
1573  enum
1574  {
1575  LOCATION_ROW = 0,
1577  ROWS_COUNT
1578  };
1579 
1580  // all features have same size
1581  static const int FEATURE_SIZE = 7;
1582 
1583  explicit FAST_GPU(int threshold, bool nonmaxSuppression = true, double keypointsRatio = 0.05);
1584 
1587  void operator ()(const GpuMat& image, const GpuMat& mask, GpuMat& keypoints);
1588  void operator ()(const GpuMat& image, const GpuMat& mask, std::vector<KeyPoint>& keypoints);
1589 
1591  void downloadKeypoints(const GpuMat& d_keypoints, std::vector<KeyPoint>& keypoints);
1592 
1594  void convertKeypoints(const Mat& h_keypoints, std::vector<KeyPoint>& keypoints);
1595 
1597  void release();
1598 
1600 
1602 
1605 
1608  int calcKeyPointsLocation(const GpuMat& image, const GpuMat& mask);
1609 
1613  int getKeyPoints(GpuMat& keypoints);
1614 
1615 private:
1616  GpuMat kpLoc_;
1617  int count_;
1618 
1619  GpuMat score_;
1620 
1621  GpuMat d_keypoints_;
1622 };
1623 
1625 
1626 class CV_EXPORTS ORB_GPU
1627 {
1628 public:
1629  enum
1630  {
1631  X_ROW = 0,
1637  ROWS_COUNT
1638  };
1639 
1640  enum
1641  {
1642  DEFAULT_FAST_THRESHOLD = 20
1643  };
1644 
1646  explicit ORB_GPU(int nFeatures = 500, float scaleFactor = 1.2f, int nLevels = 8, int edgeThreshold = 31,
1647  int firstLevel = 0, int WTA_K = 2, int scoreType = 0, int patchSize = 31);
1648 
1653  void operator()(const GpuMat& image, const GpuMat& mask, std::vector<KeyPoint>& keypoints);
1654  void operator()(const GpuMat& image, const GpuMat& mask, GpuMat& keypoints);
1655 
1661  void operator()(const GpuMat& image, const GpuMat& mask, std::vector<KeyPoint>& keypoints, GpuMat& descriptors);
1662  void operator()(const GpuMat& image, const GpuMat& mask, GpuMat& keypoints, GpuMat& descriptors);
1663 
1665  void downloadKeyPoints(GpuMat& d_keypoints, std::vector<KeyPoint>& keypoints);
1666 
1668  void convertKeyPoints(Mat& d_keypoints, std::vector<KeyPoint>& keypoints);
1669 
1671  inline int descriptorSize() const { return kBytes; }
1672 
1673  inline void setFastParams(int threshold, bool nonmaxSuppression = true)
1674  {
1675  fastDetector_.threshold = threshold;
1676  fastDetector_.nonmaxSuppression = nonmaxSuppression;
1677  }
1678 
1680  void release();
1681 
1684 
1685 private:
1686  enum { kBytes = 32 };
1687 
1688  void buildScalePyramids(const GpuMat& image, const GpuMat& mask);
1689 
1690  void computeKeyPointsPyramid();
1691 
1692  void computeDescriptors(GpuMat& descriptors);
1693 
1694  void mergeKeyPoints(GpuMat& keypoints);
1695 
1696  int nFeatures_;
1697  float scaleFactor_;
1698  int nLevels_;
1699  int edgeThreshold_;
1700  int firstLevel_;
1701  int WTA_K_;
1702  int scoreType_;
1703  int patchSize_;
1704 
1705  // The number of desired features per scale
1706  std::vector<size_t> n_features_per_level_;
1707 
1708  // Points to compute BRIEF descriptors from
1709  GpuMat pattern_;
1710 
1711  std::vector<GpuMat> imagePyr_;
1712  std::vector<GpuMat> maskPyr_;
1713 
1714  GpuMat buf_;
1715 
1716  std::vector<GpuMat> keyPointsPyr_;
1717  std::vector<int> keyPointsCount_;
1718 
1719  FAST_GPU fastDetector_;
1720 
1721  Ptr<FilterEngine_GPU> blurFilter;
1722 
1723  GpuMat d_keypoints_;
1724 };
1725 
1727 
1728 class CV_EXPORTS BroxOpticalFlow
1729 {
1730 public:
1731  BroxOpticalFlow(float alpha_, float gamma_, float scale_factor_, int inner_iterations_, int outer_iterations_, int solver_iterations_) :
1732  alpha(alpha_), gamma(gamma_), scale_factor(scale_factor_),
1733  inner_iterations(inner_iterations_), outer_iterations(outer_iterations_), solver_iterations(solver_iterations_)
1734  {
1735  }
1736 
1742  void operator ()(const GpuMat& frame0, const GpuMat& frame1, GpuMat& u, GpuMat& v, Stream& stream = Stream::Null());
1743 
1745  float alpha;
1746 
1748  float gamma;
1749 
1752 
1755 
1758 
1761 
1763 };
1764 
1766 {
1767 public:
1768  explicit GoodFeaturesToTrackDetector_GPU(int maxCorners = 1000, double qualityLevel = 0.01, double minDistance = 0.0,
1769  int blockSize = 3, bool useHarrisDetector = false, double harrisK = 0.04);
1770 
1772  void operator ()(const GpuMat& image, GpuMat& corners, const GpuMat& mask = GpuMat());
1773 
1776  double minDistance;
1777 
1780  double harrisK;
1781 
1783  {
1784  Dx_.release();
1785  Dy_.release();
1786  buf_.release();
1787  eig_.release();
1788  minMaxbuf_.release();
1789  tmpCorners_.release();
1790  }
1791 
1792 private:
1793  GpuMat Dx_;
1794  GpuMat Dy_;
1795  GpuMat buf_;
1796  GpuMat eig_;
1797  GpuMat minMaxbuf_;
1798  GpuMat tmpCorners_;
1799 };
1800 
1801 inline GoodFeaturesToTrackDetector_GPU::GoodFeaturesToTrackDetector_GPU(int maxCorners_, double qualityLevel_, double minDistance_,
1802  int blockSize_, bool useHarrisDetector_, double harrisK_)
1803 {
1804  maxCorners = maxCorners_;
1805  qualityLevel = qualityLevel_;
1806  minDistance = minDistance_;
1807  blockSize = blockSize_;
1808  useHarrisDetector = useHarrisDetector_;
1809  harrisK = harrisK_;
1810 }
1811 
1812 
1813 class CV_EXPORTS PyrLKOpticalFlow
1814 {
1815 public:
1816  PyrLKOpticalFlow();
1817 
1818  void sparse(const GpuMat& prevImg, const GpuMat& nextImg, const GpuMat& prevPts, GpuMat& nextPts,
1819  GpuMat& status, GpuMat* err = 0);
1820 
1821  void dense(const GpuMat& prevImg, const GpuMat& nextImg, GpuMat& u, GpuMat& v, GpuMat* err = 0);
1822 
1823  void releaseMemory();
1824 
1827  int iters;
1828  double derivLambda; //unused
1830  float minEigThreshold; //unused
1831  bool getMinEigenVals; //unused
1832 
1833 private:
1834  GpuMat uPyr_[2];
1835  vector<GpuMat> prevPyr_;
1836  vector<GpuMat> nextPyr_;
1837  GpuMat vPyr_[2];
1838  vector<GpuMat> buf_;
1839  vector<GpuMat> unused;
1840  bool isDeviceArch11_;
1841 };
1842 
1843 
1844 class CV_EXPORTS FarnebackOpticalFlow
1845 {
1846 public:
1848  {
1849  numLevels = 5;
1850  pyrScale = 0.5;
1851  fastPyramids = false;
1852  winSize = 13;
1853  numIters = 10;
1854  polyN = 5;
1855  polySigma = 1.1;
1856  flags = 0;
1857  isDeviceArch11_ = !DeviceInfo().supports(FEATURE_SET_COMPUTE_12);
1858  }
1859 
1861  double pyrScale;
1863  int winSize;
1865  int polyN;
1866  double polySigma;
1867  int flags;
1868 
1869  void operator ()(const GpuMat &frame0, const GpuMat &frame1, GpuMat &flowx, GpuMat &flowy, Stream &s = Stream::Null());
1870 
1872  {
1873  frames_[0].release();
1874  frames_[1].release();
1875  pyrLevel_[0].release();
1876  pyrLevel_[1].release();
1877  M_.release();
1878  bufM_.release();
1879  R_[0].release();
1880  R_[1].release();
1881  blurredFrame_[0].release();
1882  blurredFrame_[1].release();
1883  pyramid0_.clear();
1884  pyramid1_.clear();
1885  }
1886 
1887 private:
1888  void prepareGaussian(
1889  int n, double sigma, float *g, float *xg, float *xxg,
1890  double &ig11, double &ig03, double &ig33, double &ig55);
1891 
1892  void setPolynomialExpansionConsts(int n, double sigma);
1893 
1894  void updateFlow_boxFilter(
1895  const GpuMat& R0, const GpuMat& R1, GpuMat& flowx, GpuMat &flowy,
1896  GpuMat& M, GpuMat &bufM, int blockSize, bool updateMatrices, Stream streams[]);
1897 
1898  void updateFlow_gaussianBlur(
1899  const GpuMat& R0, const GpuMat& R1, GpuMat& flowx, GpuMat& flowy,
1900  GpuMat& M, GpuMat &bufM, int blockSize, bool updateMatrices, Stream streams[]);
1901 
1902  GpuMat frames_[2];
1903  GpuMat pyrLevel_[2], M_, bufM_, R_[2], blurredFrame_[2];
1904  std::vector<GpuMat> pyramid0_, pyramid1_;
1905 
1906  bool isDeviceArch11_;
1907 };
1908 
1909 
1910 // Implementation of the Zach, Pock and Bischof Dual TV-L1 Optical Flow method
1911 //
1912 // see reference:
1913 // [1] C. Zach, T. Pock and H. Bischof, "A Duality Based Approach for Realtime TV-L1 Optical Flow".
1914 // [2] Javier Sanchez, Enric Meinhardt-Llopis and Gabriele Facciolo. "TV-L1 Optical Flow Estimation".
1916 {
1917 public:
1919 
1920  void operator ()(const GpuMat& I0, const GpuMat& I1, GpuMat& flowx, GpuMat& flowy);
1921 
1922  void collectGarbage();
1923 
1927  double tau;
1928 
1935  double lambda;
1936 
1943  double theta;
1944 
1948  int nscales;
1949 
1956  int warps;
1957 
1962  double epsilon;
1963 
1968 
1970 
1971 private:
1972  void procOneScale(const GpuMat& I0, const GpuMat& I1, GpuMat& u1, GpuMat& u2);
1973 
1974  std::vector<GpuMat> I0s;
1975  std::vector<GpuMat> I1s;
1976  std::vector<GpuMat> u1s;
1977  std::vector<GpuMat> u2s;
1978 
1979  GpuMat I1x_buf;
1980  GpuMat I1y_buf;
1981 
1982  GpuMat I1w_buf;
1983  GpuMat I1wx_buf;
1984  GpuMat I1wy_buf;
1985 
1986  GpuMat grad_buf;
1987  GpuMat rho_c_buf;
1988 
1989  GpuMat p11_buf;
1990  GpuMat p12_buf;
1991  GpuMat p21_buf;
1992  GpuMat p22_buf;
1993 
1994  GpuMat diff_buf;
1995  GpuMat norm_buf;
1996 };
1997 
1998 
2000 CV_EXPORTS void calcOpticalFlowBM(const GpuMat& prev, const GpuMat& curr,
2002  GpuMat& velx, GpuMat& vely, GpuMat& buf,
2003  Stream& stream = Stream::Null());
2004 
2005 class CV_EXPORTS FastOpticalFlowBM
2006 {
2007 public:
2008  void operator ()(const GpuMat& I0, const GpuMat& I1, GpuMat& flowx, GpuMat& flowy, int search_window = 21, int block_window = 7, Stream& s = Stream::Null());
2009 
2010 private:
2011  GpuMat buffer;
2012  GpuMat extended_I0;
2013  GpuMat extended_I1;
2014 };
2015 
2016 
2031 CV_EXPORTS void interpolateFrames(const GpuMat& frame0, const GpuMat& frame1,
2032  const GpuMat& fu, const GpuMat& fv,
2033  const GpuMat& bu, const GpuMat& bv,
2034  float pos, GpuMat& newFrame, GpuMat& buf,
2035  Stream& stream = Stream::Null());
2036 
2037 CV_EXPORTS void createOpticalFlowNeedleMap(const GpuMat& u, const GpuMat& v, GpuMat& vertex, GpuMat& colors);
2038 
2039 
2041 
2042 // Foreground Object Detection from Videos Containing Complex Background.
2043 // Liyuan Li, Weimin Huang, Irene Y.H. Gu, and Qi Tian.
2044 // ACM MM2003 9p
2045 class CV_EXPORTS FGDStatModel
2046 {
2047 public:
2048  struct CV_EXPORTS Params
2049  {
2050  int Lc; // Quantized levels per 'color' component. Power of two, typically 32, 64 or 128.
2051  int N1c; // Number of color vectors used to model normal background color variation at a given pixel.
2052  int N2c; // Number of color vectors retained at given pixel. Must be > N1c, typically ~ 5/3 of N1c.
2053  // Used to allow the first N1c vectors to adapt over time to changing background.
2054 
2055  int Lcc; // Quantized levels per 'color co-occurrence' component. Power of two, typically 16, 32 or 64.
2056  int N1cc; // Number of color co-occurrence vectors used to model normal background color variation at a given pixel.
2057  int N2cc; // Number of color co-occurrence vectors retained at given pixel. Must be > N1cc, typically ~ 5/3 of N1cc.
2058  // Used to allow the first N1cc vectors to adapt over time to changing background.
2059 
2060  bool is_obj_without_holes; // If TRUE we ignore holes within foreground blobs. Defaults to TRUE.
2061  int perform_morphing; // Number of erode-dilate-erode foreground-blob cleanup iterations.
2062  // These erase one-pixel junk blobs and merge almost-touching blobs. Default value is 1.
2063 
2064  float alpha1; // How quickly we forget old background pixel values seen. Typically set to 0.1.
2065  float alpha2; // "Controls speed of feature learning". Depends on T. Typical value circa 0.005.
2066  float alpha3; // Alternate to alpha2, used (e.g.) for quicker initial convergence. Typical value 0.1.
2067 
2068  float delta; // Affects color and color co-occurrence quantization, typically set to 2.
2069  float T; // A percentage value which determines when new features can be recognized as new background. (Typically 0.9).
2070  float minArea; // Discard foreground blobs whose bounding box is smaller than this threshold.
2071 
2072  // default Params
2073  Params();
2074  };
2075 
2076  // out_cn - channels count in output result (can be 3 or 4)
2077  // 4-channels require more memory, but a bit faster
2078  explicit FGDStatModel(int out_cn = 3);
2079  explicit FGDStatModel(const cv::gpu::GpuMat& firstFrame, const Params& params = Params(), int out_cn = 3);
2080 
2081  ~FGDStatModel();
2082 
2083  void create(const cv::gpu::GpuMat& firstFrame, const Params& params = Params());
2084  void release();
2085 
2086  int update(const cv::gpu::GpuMat& curFrame);
2087 
2088  //8UC3 or 8UC4 reference background image
2090 
2091  //8UC1 foreground image
2093 
2094  std::vector< std::vector<cv::Point> > foreground_regions;
2095 
2096 private:
2097  FGDStatModel(const FGDStatModel&);
2098  FGDStatModel& operator=(const FGDStatModel&);
2099 
2100  class Impl;
2101  std::auto_ptr<Impl> impl_;
2102 };
2103 
2113 class CV_EXPORTS MOG_GPU
2114 {
2115 public:
2117  MOG_GPU(int nmixtures = -1);
2118 
2120  void initialize(Size frameSize, int frameType);
2121 
2123  void operator()(const GpuMat& frame, GpuMat& fgmask, float learningRate = 0.0f, Stream& stream = Stream::Null());
2124 
2126  void getBackgroundImage(GpuMat& backgroundImage, Stream& stream = Stream::Null()) const;
2127 
2129  void release();
2130 
2131  int history;
2134  float noiseSigma;
2135 
2136 private:
2137  int nmixtures_;
2138 
2139  Size frameSize_;
2140  int frameType_;
2141  int nframes_;
2142 
2143  GpuMat weight_;
2144  GpuMat sortKey_;
2145  GpuMat mean_;
2146  GpuMat var_;
2147 };
2148 
2156 class CV_EXPORTS MOG2_GPU
2157 {
2158 public:
2160  MOG2_GPU(int nmixtures = -1);
2161 
2163  void initialize(Size frameSize, int frameType);
2164 
2166  void operator()(const GpuMat& frame, GpuMat& fgmask, float learningRate = -1.0f, Stream& stream = Stream::Null());
2167 
2169  void getBackgroundImage(GpuMat& backgroundImage, Stream& stream = Stream::Null()) const;
2170 
2172  void release();
2173 
2174  // parameters
2175  // you should call initialize after parameters changes
2176 
2177  int history;
2178 
2182  // threshold on the squared Mahalanobis distance to decide if it is well described
2183  // by the background model or not. Related to Cthr from the paper.
2184  // This does not influence the update of the background. A typical value could be 4 sigma
2185  // and that is varThreshold=4*4=16; Corresponds to Tb in the paper.
2186 
2188  // less important parameters - things you might change but be carefull
2190 
2192  // corresponds to fTB=1-cf from the paper
2193  // TB - threshold when the component becomes significant enough to be included into
2194  // the background model. It is the TB=1-cf from the paper. So I use cf=0.1 => TB=0.
2195  // For alpha=0.001 it means that the mode should exist for approximately 105 frames before
2196  // it is considered foreground
2197  // float noiseSigma;
2199 
2200  //correspondts to Tg - threshold on the squared Mahalan. dist. to decide
2201  //when a sample is close to the existing components. If it is not close
2202  //to any a new component will be generated. I use 3 sigma => Tg=3*3=9.
2203  //Smaller Tg leads to more generated components and higher Tg might make
2204  //lead to small number of components but they can grow too large
2205  float fVarInit;
2206  float fVarMin;
2207  float fVarMax;
2208 
2209  //initial variance for the newly generated components.
2210  //It will will influence the speed of adaptation. A good guess should be made.
2211  //A simple way is to estimate the typical standard deviation from the images.
2212  //I used here 10 as a reasonable value
2213  // min and max can be used to further control the variance
2214  float fCT; //CT - complexity reduction prior
2215  //this is related to the number of samples needed to accept that a component
2216  //actually exists. We use CT=0.05 of all the samples. By setting CT=0 you get
2217  //the standard Stauffer&Grimson algorithm (maybe not exact but very similar)
2218 
2219  //shadow detection parameters
2220  bool bShadowDetection; //default 1 - do shadow detection
2221  unsigned char nShadowDetection; //do shadow detection - insert this value as the detection result - 127 default value
2222  float fTau;
2223  // Tau - shadow threshold. The shadow is detected if the pixel is darker
2224  //version of the background. Tau is a threshold on how much darker the shadow can be.
2225  //Tau= 0.5 means that if pixel is more than 2 times darker then it is not shadow
2226  //See: Prati,Mikic,Trivedi,Cucchiarra,"Detecting Moving Shadows...",IEEE PAMI,2003.
2227 
2228 private:
2229  int nmixtures_;
2230 
2231  Size frameSize_;
2232  int frameType_;
2233  int nframes_;
2234 
2235  GpuMat weight_;
2236  GpuMat variance_;
2237  GpuMat mean_;
2238 
2239  GpuMat bgmodelUsedModes_; //keep track of number of modes per pixel
2240 };
2241 
2249 class CV_EXPORTS GMG_GPU
2250 {
2251 public:
2252  GMG_GPU();
2253 
2260  void initialize(Size frameSize, float min = 0.0f, float max = 255.0f);
2261 
2269  void operator ()(const GpuMat& frame, GpuMat& fgmask, float learningRate = -1.0f, Stream& stream = Stream::Null());
2270 
2272  void release();
2273 
2276 
2279 
2282 
2285 
2288 
2291 
2294 
2297 
2298 private:
2299  float maxVal_, minVal_;
2300 
2301  Size frameSize_;
2302 
2303  int frameNum_;
2304 
2305  GpuMat nfeatures_;
2306  GpuMat colors_;
2307  GpuMat weights_;
2308 
2309  Ptr<FilterEngine_GPU> boxFilter_;
2310  GpuMat buf_;
2311 };
2312 
2314 
2315 // Works only under Windows
2316 // Supports olny H264 video codec and AVI files
2317 class CV_EXPORTS VideoWriter_GPU
2318 {
2319 public:
2320  struct EncoderParams;
2321 
2322  // Callbacks for video encoder, use it if you want to work with raw video stream
2323  class EncoderCallBack;
2324 
2326  {
2327  SF_UYVY = 0,
2333  SF_GRAY = SF_BGR
2334  };
2335 
2336  VideoWriter_GPU();
2337  VideoWriter_GPU(const std::string& fileName, cv::Size frameSize, double fps, SurfaceFormat format = SF_BGR);
2338  VideoWriter_GPU(const std::string& fileName, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format = SF_BGR);
2339  VideoWriter_GPU(const cv::Ptr<EncoderCallBack>& encoderCallback, cv::Size frameSize, double fps, SurfaceFormat format = SF_BGR);
2340  VideoWriter_GPU(const cv::Ptr<EncoderCallBack>& encoderCallback, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format = SF_BGR);
2341  ~VideoWriter_GPU();
2342 
2343  // all methods throws cv::Exception if error occurs
2344  void open(const std::string& fileName, cv::Size frameSize, double fps, SurfaceFormat format = SF_BGR);
2345  void open(const std::string& fileName, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format = SF_BGR);
2346  void open(const cv::Ptr<EncoderCallBack>& encoderCallback, cv::Size frameSize, double fps, SurfaceFormat format = SF_BGR);
2347  void open(const cv::Ptr<EncoderCallBack>& encoderCallback, cv::Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format = SF_BGR);
2348 
2349  bool isOpened() const;
2350  void close();
2351 
2352  void write(const cv::gpu::GpuMat& image, bool lastFrame = false);
2353 
2354  struct CV_EXPORTS EncoderParams
2355  {
2356  int P_Interval; // NVVE_P_INTERVAL,
2357  int IDR_Period; // NVVE_IDR_PERIOD,
2358  int DynamicGOP; // NVVE_DYNAMIC_GOP,
2359  int RCType; // NVVE_RC_TYPE,
2360  int AvgBitrate; // NVVE_AVG_BITRATE,
2361  int PeakBitrate; // NVVE_PEAK_BITRATE,
2362  int QP_Level_Intra; // NVVE_QP_LEVEL_INTRA,
2363  int QP_Level_InterP; // NVVE_QP_LEVEL_INTER_P,
2364  int QP_Level_InterB; // NVVE_QP_LEVEL_INTER_B,
2365  int DeblockMode; // NVVE_DEBLOCK_MODE,
2366  int ProfileLevel; // NVVE_PROFILE_LEVEL,
2367  int ForceIntra; // NVVE_FORCE_INTRA,
2368  int ForceIDR; // NVVE_FORCE_IDR,
2369  int ClearStat; // NVVE_CLEAR_STAT,
2370  int DIMode; // NVVE_SET_DEINTERLACE,
2371  int Presets; // NVVE_PRESETS,
2372  int DisableCabac; // NVVE_DISABLE_CABAC,
2373  int NaluFramingType; // NVVE_CONFIGURE_NALU_FRAMING_TYPE
2374  int DisableSPSPPS; // NVVE_DISABLE_SPS_PPS
2375 
2376  EncoderParams();
2377  explicit EncoderParams(const std::string& configFile);
2378 
2379  void load(const std::string& configFile);
2380  void save(const std::string& configFile) const;
2381  };
2382 
2383  EncoderParams getParams() const;
2384 
2385  class CV_EXPORTS EncoderCallBack
2386  {
2387  public:
2388  enum PicType
2389  {
2390  IFRAME = 1,
2391  PFRAME = 2,
2392  BFRAME = 3
2393  };
2394 
2395  virtual ~EncoderCallBack() {}
2396 
2397  // callback function to signal the start of bitstream that is to be encoded
2398  // must return pointer to buffer
2399  virtual uchar* acquireBitStream(int* bufferSize) = 0;
2400 
2401  // callback function to signal that the encoded bitstream is ready to be written to file
2402  virtual void releaseBitStream(unsigned char* data, int size) = 0;
2403 
2404  // callback function to signal that the encoding operation on the frame has started
2405  virtual void onBeginFrame(int frameNumber, PicType picType) = 0;
2406 
2407  // callback function signals that the encoding operation on the frame has finished
2408  virtual void onEndFrame(int frameNumber, PicType picType) = 0;
2409  };
2410 
2411 private:
2413  VideoWriter_GPU& operator=(const VideoWriter_GPU&);
2414 
2415  class Impl;
2416  std::auto_ptr<Impl> impl_;
2417 };
2418 
2419 
2421 
2422 namespace detail
2423 {
2424  class FrameQueue;
2425  class VideoParser;
2426 }
2427 
2428 class CV_EXPORTS VideoReader_GPU
2429 {
2430 public:
2431  enum Codec
2432  {
2433  MPEG1 = 0,
2441 
2442  Uncompressed_YUV420 = (('I'<<24)|('Y'<<16)|('U'<<8)|('V')), // Y,U,V (4:2:0)
2443  Uncompressed_YV12 = (('Y'<<24)|('V'<<16)|('1'<<8)|('2')), // Y,V,U (4:2:0)
2444  Uncompressed_NV12 = (('N'<<24)|('V'<<16)|('1'<<8)|('2')), // Y,UV (4:2:0)
2445  Uncompressed_YUYV = (('Y'<<24)|('U'<<16)|('Y'<<8)|('V')), // YUYV/YUY2 (4:2:2)
2446  Uncompressed_UYVY = (('U'<<24)|('Y'<<16)|('V'<<8)|('Y')) // UYVY (4:2:2)
2447  };
2448 
2450  {
2451  Monochrome=0,
2454  YUV444
2455  };
2456 
2457  struct FormatInfo
2458  {
2461  int width;
2462  int height;
2463  };
2464 
2465  class VideoSource;
2466 
2467  VideoReader_GPU();
2468  explicit VideoReader_GPU(const std::string& filename);
2469  explicit VideoReader_GPU(const cv::Ptr<VideoSource>& source);
2470 
2471  ~VideoReader_GPU();
2472 
2473  void open(const std::string& filename);
2474  void open(const cv::Ptr<VideoSource>& source);
2475  bool isOpened() const;
2476 
2477  void close();
2478 
2479  bool read(GpuMat& image);
2480 
2481  FormatInfo format() const;
2482  void dumpFormat(std::ostream& st);
2483 
2484  class CV_EXPORTS VideoSource
2485  {
2486  public:
2487  VideoSource() : frameQueue_(0), videoParser_(0) {}
2488  virtual ~VideoSource() {}
2489 
2490  virtual FormatInfo format() const = 0;
2491  virtual void start() = 0;
2492  virtual void stop() = 0;
2493  virtual bool isStarted() const = 0;
2494  virtual bool hasError() const = 0;
2495 
2496  void setFrameQueue(detail::FrameQueue* frameQueue) { frameQueue_ = frameQueue; }
2497  void setVideoParser(detail::VideoParser* videoParser) { videoParser_ = videoParser; }
2498 
2499  protected:
2500  bool parseVideoData(const uchar* data, size_t size, bool endOfStream = false);
2501 
2502  private:
2503  VideoSource(const VideoSource&);
2504  VideoSource& operator =(const VideoSource&);
2505 
2506  detail::FrameQueue* frameQueue_;
2507  detail::VideoParser* videoParser_;
2508  };
2509 
2510 private:
2512  VideoReader_GPU& operator =(const VideoReader_GPU&);
2513 
2514  class Impl;
2515  std::auto_ptr<Impl> impl_;
2516 };
2517 
2519 CV_EXPORTS void compactPoints(GpuMat &points0, GpuMat &points1, const GpuMat &mask);
2520 
2521 CV_EXPORTS void calcWobbleSuppressionMaps(
2522  int left, int idx, int right, Size size, const Mat &ml, const Mat &mr,
2523  GpuMat &mapx, GpuMat &mapy);
2524 
2525 } // namespace gpu
2526 
2527 } // namespace cv
2528 
2529 #endif /* __OPENCV_GPU_HPP__ */
Definition: gpu.hpp:2328
CV_EXPORTS void minMaxLoc(const GpuMat &src, double *minVal, double *maxVal=0, Point *minLoc=0, Point *maxLoc=0, const GpuMat &mask=GpuMat())
finds global minimum and maximum array elements and returns their values with locations ...
CV_EXPORTS void solvePnPRansac(const Mat &object, const Mat &image, const Mat &camera_mat, const Mat &dist_coef, Mat &rvec, Mat &tvec, bool use_extrinsic_guess=false, int num_iters=100, float max_dist=8.0, int min_inlier_count=100, std::vector< int > *inliers=NULL)
CvArr CvPoint2D32f double M
Definition: imgproc_c.h:186
Definition: gpu.hpp:1633
GpuMat map
Definition: gpu.hpp:834
float backgroundRatio
Definition: gpu.hpp:2191
Definition: gpu.hpp:586
Definition: gpu.hpp:2440
Point2i Point
Definition: core.hpp:893
const CvArr CvArr CvArr const CvPoint2D32f CvPoint2D32f int CvSize int char * status
Definition: tracking.hpp:73
Definition: gpu.hpp:640
int AvgBitrate
Definition: gpu.hpp:2360
GLsizei GLsizei GLchar * source
CV_EXPORTS void buildWarpPerspectiveMaps(const Mat &M, bool inverse, Size dsize, GpuMat &xmap, GpuMat &ymap, Stream &stream=Stream::Null())
CvArr * edges
Definition: imgproc_c.h:555
int ClearStat
Definition: gpu.hpp:2369
Definition: gpu.hpp:2048
CV_EXPORTS void compare(const GpuMat &a, const GpuMat &b, GpuMat &c, int cmpop, Stream &stream=Stream::Null())
compares elements of two arrays (c = a b)
CV_EXPORTS void erode(const GpuMat &src, GpuMat &dst, const Mat &kernel, Point anchor=Point(-1,-1), int iterations=1)
erodes the image (applies the local minimum operator)
CV_EXPORTS void sqrt(const GpuMat &src, GpuMat &dst, Stream &stream=Stream::Null())
GLenum GLint GLint y
Definition: core_c.h:613
int ndisp
Definition: gpu.hpp:1097
virtual CV_WRAP void apply(InputArray src, OutputArray dst)=0
double polySigma
Definition: gpu.hpp:1866
CV_EXPORTS void exp(const GpuMat &a, GpuMat &b, Stream &stream=Stream::Null())
int levels
Definition: gpu.hpp:1151
CV_EXPORTS Ptr< BaseFilter_GPU > getMinFilter_GPU(int srcType, int dstType, const Size &ksize, Point anchor=Point(-1,-1))
returns minimum filter
int int int int * dy
virtual ~VideoSource()
Definition: gpu.hpp:2488
CV_EXPORTS Ptr< BaseFilter_GPU > getMaxFilter_GPU(int srcType, int dstType, const Size &ksize, Point anchor=Point(-1,-1))
returns maximum filter
IplImage CvRect * roi
Definition: legacy.hpp:234
GLdouble GLdouble GLdouble GLdouble top
Termination criteria in iterative algorithms.
Definition: core.hpp:2091
float gamma
gradient constancy importance
Definition: gpu.hpp:1748
Definition: gpu.hpp:1228
GLenum GLenum GLuint components
float avergeTexThreshold
Definition: gpu.hpp:1104
CV_EXPORTS void LUT(const GpuMat &src, const Mat &lut, GpuMat &dst, Stream &stream=Stream::Null())
CV_EXPORTS void HoughLinesDownload(const GpuMat &d_lines, OutputArray h_lines, OutputArray h_votes=noArray())
float disc_single_jump
Definition: gpu.hpp:1209
Definition: gpu.hpp:849
CvArr const CvArr * lut
Definition: core_c.h:1439
CV_EXPORTS void pow(const GpuMat &src, double power, GpuMat &dst, Stream &stream=Stream::Null())
computes power of each matrix element:
bool useInitialFlow
Definition: gpu.hpp:1969
double pyrScale
Definition: gpu.hpp:1861
const char const char ** filename
Definition: core_c.h:1750
float fVarMax
Definition: gpu.hpp:2207
Definition: gpu.hpp:641
Definition: gpu.hpp:635
Codec
Definition: gpu.hpp:2431
int depth
Definition: core_c.h:73
CV_EXPORTS void addWeighted(const GpuMat &src1, double alpha, const GpuMat &src2, double beta, double gamma, GpuMat &dst, int dtype=-1, Stream &stream=Stream::Null())
computes the weighted sum of two arrays (dst = alpha*src1 + beta*src2 + gamma)
int flags
Definition: gpu.hpp:1867
int iters
Definition: gpu.hpp:1150
int double fps
Definition: highgui_c.h:598
Definition: gpu.hpp:644
float fVarMin
Definition: gpu.hpp:2206
float alpha2
Definition: gpu.hpp:2065
CV_EXPORTS void max(const GpuMat &src1, const GpuMat &src2, GpuMat &dst, Stream &stream=Stream::Null())
computes per-element maximum of two arrays (dst = max(src1, src2))
float varThreshold
Definition: gpu.hpp:2132
CV_EXPORTS void createOpticalFlowNeedleMap(const GpuMat &u, const GpuMat &v, GpuMat &vertex, GpuMat &colors)
bool visualizeInPlace
Definition: gpu.hpp:1556
int rows
Definition: gpu.hpp:124
DistType
Definition: gpu.hpp:1358
int nr_plane
Definition: gpu.hpp:1204
float varThreshold
Definition: gpu.hpp:2181
CV_EXPORTS void warpAffine(const GpuMat &src, GpuMat &dst, const Mat &M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, Scalar borderValue=Scalar(), Stream &stream=Stream::Null())
int msg_type
Definition: gpu.hpp:1158
const CvArr CvArr * fgmask
Definition: legacy.hpp:3418
int ksize
Definition: gpu.hpp:208
const CvArr CvSize CvSize CvSize int use_previous
Definition: legacy.hpp:3127
BaseRowFilter_GPU(int ksize_, int anchor_)
Definition: gpu.hpp:205
CV_EXPORTS void reprojectImageTo3D(const GpuMat &disp, GpuMat &xyzw, const Mat &Q, int dst_cn=4, Stream &stream=Stream::Null())
float data_weight
Definition: gpu.hpp:1207
Definition: gpu.hpp:1728
CV_EXPORTS void min(const GpuMat &src1, const GpuMat &src2, GpuMat &dst, Stream &stream=Stream::Null())
computes per-element minimum of two arrays (dst = min(src1, src2))
float fTau
Definition: gpu.hpp:2222
int ndisp
Definition: gpu.hpp:1148
Size2i Size
Definition: core.hpp:896
void int double dp
Definition: imgproc_c.h:608
void close()
CV_EXPORTS Ptr< BaseFilter_GPU > getBoxFilter_GPU(int srcType, int dstType, const Size &ksize, Point anchor=Point(-1,-1))
const CvArr * curr
Definition: legacy.hpp:3123
CV_EXPORTS void equalizeHist(const GpuMat &src, GpuMat &dst, Stream &stream=Stream::Null())
normalizes the grayscale image brightness and contrast by normalizing its histogram ...
uchar * data
Definition: gpu.hpp:127
float delta
Definition: gpu.hpp:2068
Definition: gpu.hpp:585
CV_EXPORTS void rshift(const GpuMat &src, Scalar_< int > sc, GpuMat &dst, Stream &stream=Stream::Null())
GLdouble GLdouble u2
CV_EXPORTS Ptr< BaseColumnFilter_GPU > getColumnSumFilter_GPU(int sumType, int dstType, int ksize, int anchor=-1)
int DeblockMode
Definition: gpu.hpp:2365
CV_EXPORTS_W Scalar mean(InputArray src, InputArray mask=noArray())
computes mean value of selected array elements
int history
Definition: gpu.hpp:2131
int descriptorSize() const
returns the descriptor size in bytes
Definition: gpu.hpp:1671
int inner_iterations
number of lagged non-linearity iterations (inner loop)
Definition: gpu.hpp:1754
Ptr< FilterEngine_GPU > filterDY
Definition: gpu.hpp:837
double theta
Definition: gpu.hpp:1943
CV_EXPORTS void integralBuffered(const GpuMat &src, GpuMat &sum, GpuMat &buffer, Stream &stream=Stream::Null())
buffered version
CannyBuf cannyBuf
Definition: gpu.hpp:899
CV_EXPORTS void abs(const GpuMat &src, GpuMat &dst, Stream &stream=Stream::Null())
const int * idx
Definition: core_c.h:323
uchar * dataend
Definition: gpu.hpp:131
BruteForceMatcher_GPU()
Definition: gpu.hpp:1515
const CvArr * src1
Definition: core_c.h:436
int warps
Definition: gpu.hpp:1956
Size block_size
Definition: gpu.hpp:759
CvSize size
Definition: calib3d.hpp:212
GLenum GLsizei width
int Presets
Definition: gpu.hpp:2371
OutputArray OutputArray sqsum
Definition: imgproc.hpp:620
CV_EXPORTS void calcWobbleSuppressionMaps(int left, int idx, int right, Size size, const Mat &ml, const Mat &mr, GpuMat &mapx, GpuMat &mapy)
Definition: gpu.hpp:1540
GpuMat templf
Definition: gpu.hpp:781
GpuMat buf
Definition: gpu.hpp:1762
CV_EXPORTS void blendLinear(const GpuMat &img1, const GpuMat &img2, const GpuMat &weights1, const GpuMat &weights2, GpuMat &result, Stream &stream=Stream::Null())
cv::gpu::GpuMat background
Definition: gpu.hpp:2089
float max_disc_term
Definition: gpu.hpp:1208
GLuint src
Definition: core_c.h:1650
Definition: gpu.hpp:2457
void int double rho
Definition: imgproc_c.h:603
CV_EXPORTS void meanShiftSegmentation(const GpuMat &src, Mat &dst, int sp, int sr, int minsize, TermCriteria criteria=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 5, 1))
Does mean shift segmentation with elimination of small regions.
int int int flags
Definition: highgui_c.h:186
int width
Definition: gpu.hpp:2461
Codec codec
Definition: gpu.hpp:2459
CV_EXPORTS Scalar sqrSum(const GpuMat &src)
CV_EXPORTS Ptr< cv::gpu::CLAHE > createCLAHE(double clipLimit=40.0, Size tileGridSize=Size(8, 8))
CV_EXPORTS void cvtColor(const GpuMat &src, GpuMat &dst, int code, int dcn=0, Stream &stream=Stream::Null())
converts image from one color space to another
The class implements the following algorithm: "Improved adaptive Gausian mixture model for background...
Definition: gpu.hpp:2156
Definition: core.hpp:132
int smoothingRadius
Smoothing radius, in pixels, for cleaning up FG image.
Definition: gpu.hpp:2293
const CvArr CvSize CvArr CvArr * vely
Definition: legacy.hpp:3123
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: core_c.h:403
int d
Definition: legacy.hpp:3064
CV_EXPORTS void cornerHarris(const GpuMat &src, GpuMat &dst, int blockSize, int ksize, double k, int borderType=BORDER_REFLECT101)
computes Harris cornerness criteria at each image pixel
float scale_factor
pyramid scale factor
Definition: gpu.hpp:1751
CannyBuf()
Definition: gpu.hpp:839
Definition: gpu.hpp:2437
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
GLfloat angle
Definition: core_c.h:1297
Size block_size
Definition: gpu.hpp:1312
CV_EXPORTS void compactPoints(GpuMat &points0, GpuMat &points1, const GpuMat &mask)
removes points (CV_32FC2, single row matrix) with zero mask value
CV_EXPORTS void HoughCircles(const GpuMat &src, GpuMat &circles, int method, float dp, float minDist, int cannyThreshold, int votesThreshold, int minRadius, int maxRadius, int maxCircles=4096)
CV_EXPORTS void histEven(const GpuMat &src, GpuMat &hist, int histSize, int lowerLevel, int upperLevel, Stream &stream=Stream::Null())
double tau
Definition: gpu.hpp:1927
CV_EXPORTS Ptr< FilterEngine_GPU > createSeparableLinearFilter_GPU(int srcType, int dstType, const Mat &rowKernel, const Mat &columnKernel, const Point &anchor=Point(-1,-1), int rowBorderType=BORDER_DEFAULT, int columnBorderType=-1)
returns the separable linear filter engine
Gaussian Mixture-based Backbround/Foreground Segmentation Algorithm.
Definition: gpu.hpp:2113
The Base Class for Non-Separable 2D Filters.
Definition: gpu.hpp:231
float T
Definition: gpu.hpp:2069
Definition: core.hpp:132
int perform_morphing
Definition: gpu.hpp:2061
CV_EXPORTS void registerPageLocked(Mat &m)
Definition: gpu.hpp:2453
void setFrameQueue(detail::FrameQueue *frameQueue)
Definition: gpu.hpp:2496
bool use_local_init_data_cost
Definition: gpu.hpp:1215
CvArr const CvMat * kernel
Definition: imgproc_c.h:89
CV_EXPORTS void sqr(const GpuMat &src, GpuMat &dst, Stream &stream=Stream::Null())
CV_EXPORTS void buildWarpPlaneMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat &R, const Mat &T, float scale, GpuMat &map_x, GpuMat &map_y, Stream &stream=Stream::Null())
builds plane warping maps
const CvArr CvSize CvSize shift_size
Definition: legacy.hpp:3127
std::vector< GpuMat > images
Definition: gpu.hpp:782
CV_EXPORTS void absdiff(const GpuMat &a, const GpuMat &b, GpuMat &c, Stream &stream=Stream::Null())
computes element-wise absolute difference of two arrays (c = abs(a - b))
size_t step
Definition: gpu.hpp:125
CV_EXPORTS void bitwise_xor(const GpuMat &src1, const GpuMat &src2, GpuMat &dst, const GpuMat &mask=GpuMat(), Stream &stream=Stream::Null())
calculates per-element bit-wise "exclusive or" operation
CV_EXPORTS void transpose(const GpuMat &src1, GpuMat &dst, Stream &stream=Stream::Null())
int polyN
Definition: gpu.hpp:1865
CV_EXPORTS void buildWarpSphericalMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat &R, float scale, GpuMat &map_x, GpuMat &map_y, Stream &stream=Stream::Null())
builds spherical warping maps
GLXDrawable GLXDrawable read
int QP_Level_Intra
Definition: gpu.hpp:2362
CV_EXPORTS void reduce(const GpuMat &mtx, GpuMat &vec, int dim, int reduceOp, int dtype=-1, Stream &stream=Stream::Null())
reduces a matrix to a vector
CV_EXPORTS void lshift(const GpuMat &src, Scalar_< int > sc, GpuMat &dst, Stream &stream=Stream::Null())
HoughCircles.
Definition: gpu.hpp:894
GpuMat templ_spect
Definition: gpu.hpp:764
static Stream & Null()
virtual ~BaseColumnFilter_GPU()
Definition: gpu.hpp:221
int QP_Level_InterP
Definition: gpu.hpp:2363
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: highgui_c.h:230
const CvArr CvArr int method
Definition: imgproc_c.h:281
CV_EXPORTS void integral(const GpuMat &src, GpuMat &sum, Stream &stream=Stream::Null())
CV_EXPORTS_W void write(FileStorage &fs, const string &name, int value)
struct CV_EXPORTS CannyBuf
Definition: ocl.hpp:979
CV_EXPORTS void histRange(const GpuMat &src, GpuMat &hist, const GpuMat &levels, Stream &stream=Stream::Null())
CV_EXPORTS void merge(const GpuMat *src, size_t n, GpuMat &dst, Stream &stream=Stream::Null())
makes multi-channel array out of several single-channel arrays
Size winSize
Definition: gpu.hpp:1825
Proxy datatype for passing Mat's and vector<>'s as input parameters.
Definition: core.hpp:1312
virtual ~BaseRowFilter_GPU()
Definition: gpu.hpp:206
DistType distType
Definition: gpu.hpp:1502
ImagePyramid(const GpuMat &img, int nLayers, Stream &stream=Stream::Null())
Definition: gpu.hpp:853
int winSize
Definition: gpu.hpp:1098
CvRect rect
Definition: core_c.h:100
void clear(const ColorA &color=ColorA::black(), bool clearDepthBuffer=true)
bool bShadowDetection
Definition: gpu.hpp:2220
CV_EXPORTS string format(const char *fmt,...)
CV_EXPORTS void pyrDown(const GpuMat &src, GpuMat &dst, Stream &stream=Stream::Null())
smoothes the source image and downsamples it
int threshold
Definition: gpu.hpp:1601
Definition: gpu.hpp:639
int numLevels
Definition: gpu.hpp:1860
float free_coef
Definition: gpu.hpp:1332
const CvPoint2D32f vertex[4]
Definition: legacy.hpp:1070
GoodFeaturesToTrackDetector_GPU(int maxCorners=1000, double qualityLevel=0.01, double minDistance=0.0, int blockSize=3, bool useHarrisDetector=false, double harrisK=0.04)
Definition: gpu.hpp:1801
CV_EXPORTS void gemm(const GpuMat &src1, const GpuMat &src2, double alpha, const GpuMat &src3, double beta, GpuMat &dst, int flags=0, Stream &stream=Stream::Null())
implements generalized matrix product algorithm GEMM from BLAS
The 2D size class.
Definition: core.hpp:81
bool is_obj_without_holes
Definition: gpu.hpp:2060
const CvMat const CvMat const CvMat CvSize const CvMat const CvMat CvMat * R1
Definition: calib3d.hpp:284
CV_EXPORTS void split(const GpuMat &src, GpuMat *dst, Stream &stream=Stream::Null())
copies each plane of a multi-channel array to a dedicated array
CV_EXPORTS Ptr< BaseRowFilter_GPU > getLinearRowFilter_GPU(int srcType, int bufType, const Mat &rowKernel, int anchor=-1, int borderType=BORDER_DEFAULT)
const CvArr const CvArr CvArr * result
Definition: core_c.h:805
typedef void(CV_CDECL *CvMouseCallback)(int event
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.
bool getMinEigenVals
Definition: gpu.hpp:1831
ImagePyramid()
Definition: gpu.hpp:852
CV_EXPORTS void buildWarpAffineMaps(const Mat &M, bool inverse, Size dsize, GpuMat &xmap, GpuMat &ymap, Stream &stream=Stream::Null())
Definition: gpu.hpp:756
CV_EXPORTS void magnitude(const GpuMat &xy, GpuMat &magnitude, Stream &stream=Stream::Null())
vector< double > confidences
Definition: gpu.hpp:1266
The Base Class for 1D or Row-wise Filters.
Definition: gpu.hpp:202
CvPoint2D32f double CvTermCriteria criteria
Definition: calib3d.hpp:65
int outer_iterations
number of warping iterations (number of pyramid levels)
Definition: gpu.hpp:1757
Size win_size
Definition: gpu.hpp:1311
CvArr const CvArr const CvArr * mapy
Definition: imgproc_c.h:176
CV_EXPORTS void morphologyEx(const GpuMat &src, GpuMat &dst, int op, const Mat &kernel, Point anchor=Point(-1,-1), int iterations=1)
applies an advanced morphological operation to the image
int ForceIntra
Definition: gpu.hpp:2367
CvPoint CvPoint void * buffer
Definition: imgproc_c.h:262
const CvArr CvSize CvSize CvSize max_range
Definition: legacy.hpp:3127
CV_EXPORTS void columnSum(const GpuMat &src, GpuMat &sum)
computes vertical sum, supports only CV_32FC1 images
int nbins
Definition: gpu.hpp:1315
float max_data_term
Definition: gpu.hpp:1206
GLint GLvoid * img
Definition: legacy.hpp:1150
int RCType
Definition: gpu.hpp:2359
float backgroundRatio
Definition: gpu.hpp:2133
CvMemStoragePos * pos
Definition: core_c.h:933
double harrisK
Definition: gpu.hpp:1780
double start
Definition: core_c.h:774
Definition: gpu.hpp:2317
Definition: stream_accessor.hpp:57
SourceFileRef load(const DataSourceRef &dataSource, size_t sampleRate=0)
GpuMat list
Definition: gpu.hpp:880
GLdouble u1
CannyBuf(const Size &image_size, int apperture_size=3)
Definition: gpu.hpp:840
int N1c
Definition: gpu.hpp:2051
const CvArr CvArr double int levels
Definition: tracking.hpp:102
GpuMat qangle_buf
Definition: gpu.hpp:1343
CV_EXPORTS void Canny(const GpuMat &image, GpuMat &edges, double low_thresh, double high_thresh, int apperture_size=3, bool L2gradient=false)
float disc_single_jump
Definition: gpu.hpp:1156
CvArr const CvArr * mapx
Definition: imgproc_c.h:176
GLuint GLfloat * val
float decisionThreshold
Value above which pixel is determined to be FG.
Definition: gpu.hpp:2290
const CvArr const CvArr const CvArr * src3
Definition: core_c.h:436
Definition: gpumat.hpp:106
Definition: gpu.hpp:1844
CV_EXPORTS void divide(const GpuMat &a, const GpuMat &b, GpuMat &c, double scale=1, int dtype=-1, Stream &stream=Stream::Null())
computes element-wise weighted quotient of the two arrays (c = a / b)
CV_EXPORTS void Scharr(const GpuMat &src, GpuMat &dst, int ddepth, int dx, int dy, double scale=1, int rowBorderType=BORDER_DEFAULT, int columnBorderType=-1)
applies the vertical or horizontal Scharr operator to the image
int PeakBitrate
Definition: gpu.hpp:2361
Size cell_size
Definition: gpu.hpp:1314
GLsizei stride
BruteForceMatcher_GPU(Hamming)
Definition: gpu.hpp:1529
float alpha
flow smoothness
Definition: gpu.hpp:1745
int alloc_type
Definition: gpu.hpp:133
float minEigThreshold
Definition: gpu.hpp:1830
CV_EXPORTS void pyrUp(const GpuMat &src, GpuMat &dst, Stream &stream=Stream::Null())
upsamples the source image and then smoothes it
Definition: gpu.hpp:1813
CV_EXPORTS void gammaCorrection(const GpuMat &src, GpuMat &dst, bool forward=true, Stream &stream=Stream::Null())
Routines for correcting image color gamma.
Definition: gpu.hpp:1570
float noiseSigma
Definition: gpu.hpp:2134
Definition: gpu.hpp:1915
CV_EXPORTS void projectPoints(const GpuMat &src, const Mat &rvec, const Mat &tvec, const Mat &camera_mat, const Mat &dist_coef, GpuMat &dst, Stream &stream=Stream::Null())
int quantizationLevels
Number of discrete levels in each channel to be used in histograms.
Definition: gpu.hpp:2284
double lambda
Definition: gpu.hpp:1935
int maxFeatures
Total number of distinct colors to maintain in histogram.
Definition: gpu.hpp:2275
bool updateBackgroundModel
Perform background model update.
Definition: gpu.hpp:2296
Definition: gpu.hpp:1632
bool nonmaxSuppression
Definition: gpu.hpp:1599
FarnebackOpticalFlow()
Definition: gpu.hpp:1847
CV_EXPORTS void sepFilter2D(const GpuMat &src, GpuMat &dst, int ddepth, const Mat &kernelX, const Mat &kernelY, Point anchor=Point(-1,-1), int rowBorderType=BORDER_DEFAULT, int columnBorderType=-1)
applies separable 2D linear filter to the image
the desired accuracy or change in parameters at which the iterative algorithm stops ...
Definition: core.hpp:2098
Definition: gpu.hpp:634
const CvArr CvSeq ** keypoints
Definition: compat.hpp:647
Definition: gpu.hpp:141
CV_EXPORTS Ptr< FilterEngine_GPU > createFilter2D_GPU(const Ptr< BaseFilter_GPU > &filter2D, int srcType, int dstType)
returns the non-separable filter engine with the specified filter
CvArr const CvMat * Q
Definition: calib3d.hpp:365
GLboolean GLboolean g
CV_EXPORTS void meanStdDev(const GpuMat &mtx, Scalar &mean, Scalar &stddev)
void setFastParams(int threshold, bool nonmaxSuppression=true)
Definition: gpu.hpp:1673
Definition: gpu.hpp:645
int DisableCabac
Definition: gpu.hpp:2372
GLenum GLsizei GLsizei height
GLclampf GLclampf GLclampf alpha
Definition: core_c.h:687
int CvHistogram * hist
Definition: imgproc_c.h:440
CV_EXPORTS void cornerMinEigenVal(const GpuMat &src, GpuMat &dst, int blockSize, int ksize, int borderType=BORDER_REFLECT101)
computes minimum eigen value of 2x2 derivative covariation matrix at each pixel - the cornerness crit...
Size ksize
Definition: gpu.hpp:237
const CvMat const CvMat const CvMat CvMat CvMat CvMat CvMat CvSize CvMat * R
Definition: calib3d.hpp:270
CV_EXPORTS void filter2D(const GpuMat &src, GpuMat &dst, int ddepth, const Mat &kernel, Point anchor=Point(-1,-1), int borderType=BORDER_DEFAULT, Stream &stream=Stream::Null())
applies non-separable 2D linear filter to the image
void release()
Definition: gpu.hpp:862
CV_EXPORTS void HoughLines(const GpuMat &src, GpuMat &lines, float rho, float theta, int threshold, bool doSort=false, int maxLines=4096)
CV_EXPORTS void rectStdDev(const GpuMat &src, const GpuMat &sqr, GpuMat &dst, const Rect &rect, Stream &stream=Stream::Null())
Definition: gpu.hpp:2434
GLuint buffer
float fCT
Definition: gpu.hpp:2214
float backgroundPrior
Prior probability that any given pixel is a background pixel. A sensitivity parameter.
Definition: gpu.hpp:2287
virtual ~BaseFilter_GPU()
Definition: gpu.hpp:235
Definition: gpu.hpp:1262
Definition: gpu.hpp:1532
CV_EXPORTS void boxFilter(const GpuMat &src, GpuMat &dst, int ddepth, Size ksize, Point anchor=Point(-1,-1), Stream &stream=Stream::Null())
Mat labels_host
Definition: gpu.hpp:1337
std::vector< GpuMat > image_sqsums
Definition: gpu.hpp:784
Fast (but approximate)version of non-local means algorith similar to CPU function (running sums techn...
Definition: gpu.hpp:812
Definition: gpu.hpp:585
CV_EXPORTS void unregisterPageLocked(Mat &m)
int nlevels
Definition: gpu.hpp:1319
CV_EXPORTS void interpolateFrames(const GpuMat &frame0, const GpuMat &frame1, const GpuMat &fu, const GpuMat &fv, const GpuMat &bu, const GpuMat &bv, float pos, GpuMat &newFrame, GpuMat &buf, Stream &stream=Stream::Null())
int iterations
Definition: gpu.hpp:1967
CV_EXPORTS Ptr< FilterEngine_GPU > createLinearFilter_GPU(int srcType, int dstType, const Mat &kernel, Point anchor=Point(-1,-1), int borderType=BORDER_DEFAULT)
returns the non-separable linear filter engine
Definition: gpu.hpp:909
Point anchor
Definition: gpu.hpp:238
bool gamma_correction
Definition: gpu.hpp:1318
GpuMat detector
Definition: gpu.hpp:1333
GpuMat block_hists_buf
Definition: gpu.hpp:1340
Definition: gpu.hpp:2005
void int int uchar void * userData
Definition: legacy.hpp:78
CV_EXPORTS Ptr< BaseFilter_GPU > getMorphologyFilter_GPU(int op, int type, const Mat &kernel, const Size &ksize, Point anchor=Point(-1,-1))
CvArr int block_size
Definition: imgproc_c.h:566
Size dft_size
Definition: gpu.hpp:761
const CvMat CvMat CvMat int k
Definition: legacy.hpp:3052
Smart pointer for GPU memory with reference counting. Its interface is mostly similar with cv::Mat...
Definition: gpumat.hpp:154
GLenum GLint x
Definition: core_c.h:632
CV_EXPORTS void flip(const GpuMat &a, GpuMat &b, int flipCode, Stream &stream=Stream::Null())
CV_EXPORTS void bilateralFilter(const GpuMat &src, GpuMat &dst, int kernel_size, float sigma_color, float sigma_spatial, int borderMode=BORDER_DEFAULT, Stream &stream=Stream::Null())
Performa bilateral filtering of passsed image.
Definition: gpu.hpp:636
CV_EXPORTS void resize(const GpuMat &src, GpuMat &dst, Size dsize, double fx=0, double fy=0, int interpolation=INTER_LINEAR, Stream &stream=Stream::Null())
bool blurForDescriptor
if true, image will be blurred before descriptors calculation
Definition: gpu.hpp:1683
Definition: gpu.hpp:586
CV_EXPORTS Ptr< FilterEngine_GPU > createBoxFilter_GPU(int srcType, int dstType, const Size &ksize, const Point &anchor=Point(-1,-1))
returns box filter engine
CvOpenGlDrawCallback callback
Definition: highgui_c.h:256
CvArr double double sr
Definition: imgproc_c.h:125
Definition: features2d.hpp:1004
Definition: gpumat.hpp:71
Definition: gpu.hpp:586
GLenum GLsizei n
CV_EXPORTS void minMax(const GpuMat &src, double *minVal, double *maxVal=0, const GpuMat &mask=GpuMat())
finds global minimum and maximum array elements and returns their values
CV_EXPORTS Ptr< BaseRowFilter_GPU > getRowSumFilter_GPU(int srcType, int sumType, int ksize, int anchor=-1)
bool findLargestObject
Definition: gpu.hpp:1555
Definition: gpu.hpp:2331
bool useInitialFlow
Definition: gpu.hpp:1829
The Image Processing.
CV_EXPORTS void subtract(const GpuMat &a, const GpuMat &b, GpuMat &c, const GpuMat &mask=GpuMat(), int dtype=-1, Stream &stream=Stream::Null())
subtracts one matrix from another (c = a - b)
GLdouble left
bool useHarrisDetector
Definition: gpu.hpp:1779
Definition: gpu.hpp:646
int levels
Definition: gpu.hpp:1202
BroxOpticalFlow(float alpha_, float gamma_, float scale_factor_, int inner_iterations_, int outer_iterations_, int solver_iterations_)
Definition: gpu.hpp:1731
int flags
Definition: gpu.hpp:123
Definition: gpu.hpp:2435
int iters
Definition: gpu.hpp:1827
Definition: gpu.hpp:2428
int blockSize
Definition: gpu.hpp:1778
virtual ~EncoderCallBack()
Definition: gpu.hpp:2395
Definition: gpu.hpp:2045
void releaseMemory()
Definition: gpu.hpp:1871
void int double double theta
Definition: imgproc_c.h:603
int DynamicGOP
Definition: gpu.hpp:2358
CV_EXPORTS Ptr< BaseColumnFilter_GPU > getLinearColumnFilter_GPU(int bufType, int dstType, const Mat &columnKernel, int anchor=-1, int borderType=BORDER_DEFAULT)
Definition: gpu.hpp:638
GpuMat unused
Definition: gpu.hpp:836
uchar * datastart
Definition: gpu.hpp:130
CV_EXPORTS void add(const GpuMat &a, const GpuMat &b, GpuMat &c, const GpuMat &mask=GpuMat(), int dtype=-1, Stream &stream=Stream::Null())
adds one matrix to another (c = a + b)
const GLdouble * v
const CvArr CvArr double int int int iterations
Definition: tracking.hpp:102
Definition: gpu.hpp:586
CV_EXPORTS void multiply(const GpuMat &a, const GpuMat &b, GpuMat &c, double scale=1, int dtype=-1, Stream &stream=Stream::Null())
computes element-wise weighted product of the two arrays (c = scale * a * b)
ChromaFormat
Definition: gpu.hpp:2449
int spect_len
Definition: gpu.hpp:762
double const CvArr double beta
Definition: core_c.h:523
int ForceIDR
Definition: gpu.hpp:2368
GLdouble GLdouble right
ChromaFormat chromaFormat
Definition: gpu.hpp:2460
float alpha3
Definition: gpu.hpp:2066
GLboolean GLboolean GLboolean b
Definition: legacy.hpp:633
CV_EXPORTS Ptr< FilterEngine_GPU > createDerivFilter_GPU(int srcType, int dstType, int dx, int dy, int ksize, int rowBorderType=BORDER_DEFAULT, int columnBorderType=-1)
returns filter engine for the generalized Sobel operator
Definition: gpu.hpp:1355
The n-dimensional matrix class.
Definition: core.hpp:1688
double epsilon
Definition: gpu.hpp:1962
double keypointsRatio
max keypoints = keypointsRatio * img.size().area()
Definition: gpu.hpp:1604
int IDR_Period
Definition: gpu.hpp:2357
int rows
Definition: core_c.h:114
BaseFilter_GPU(const Size &ksize_, const Point &anchor_)
Definition: gpu.hpp:234
int numInitializationFrames
Number of frames of video to use to initialize histograms.
Definition: gpu.hpp:2281
VideoSource()
Definition: gpu.hpp:2487
CV_EXPORTS int countNonZero(const GpuMat &src)
counts non-zero array elements
Definition: gpu.hpp:2249
CV_EXPORTS void buildWarpCylindricalMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat &R, float scale, GpuMat &map_x, GpuMat &map_y, Stream &stream=Stream::Null())
builds cylindrical warping maps
ditto
Definition: core.hpp:2097
Definition: gpu.hpp:2329
const CvArr CvSeq CvSeq ** descriptors
Definition: compat.hpp:647
CvArr CvPoint2D32f double maxRadius
Definition: imgproc_c.h:191
GLsizei const GLfloat * value
Definition: core_c.h:341
CV_EXPORTS void graphcut(GpuMat &terminals, GpuMat &leftTransp, GpuMat &rightTransp, GpuMat &top, GpuMat &bottom, GpuMat &labels, GpuMat &buf, Stream &stream=Stream::Null())
performs labeling via graph cuts of a 2D regular 4-connected graph.
CvSize CvPoint2D32f * corners
Definition: calib3d.hpp:215
GpuMat accum
Definition: gpu.hpp:879
int nscales
Definition: gpu.hpp:1948
bilinear interpolation
Definition: imgproc.hpp:555
int solver_iterations
number of linear system solver iterations
Definition: gpu.hpp:1760
OutputArray OutputArray labels
Definition: imgproc.hpp:823
int maxCorners
Definition: gpu.hpp:1774
unsigned char nShadowDetection
Definition: gpu.hpp:2221
Definition: gpu.hpp:1075
int Lcc
Definition: gpu.hpp:2055
int cols
Definition: core_c.h:109
CV_EXPORTS void matchTemplate(const GpuMat &image, const GpuMat &templ, GpuMat &result, int method, Stream &stream=Stream::Null())
computes the proximity map for the raster template and the image where the template is searched for ...
int maxLevel
Definition: gpu.hpp:1826
GLuint GLuint GLsizei GLenum type
Definition: core_c.h:114
void void * frame
Definition: core_c.h:1459
GLenum const GLfloat * params
Definition: compat.hpp:688
CV_EXPORTS void mulSpectrums(const GpuMat &a, const GpuMat &b, GpuMat &c, int flags, bool conjB=false, Stream &stream=Stream::Null())
const GLubyte * c
Definition: legacy.hpp:633
SurfaceFormat
Definition: gpu.hpp:2325
GpuMat edges
Definition: gpu.hpp:896
CV_EXPORTS void Sobel(const GpuMat &src, GpuMat &dst, int ddepth, int dx, int dy, int ksize=3, double scale=1, int rowBorderType=BORDER_DEFAULT, int columnBorderType=-1)
applies generalized Sobel operator to the image
int int type
Definition: core_c.h:109
float alpha1
Definition: gpu.hpp:2064
Definition: gpu.hpp:1636
int int int int int int h
CV_EXPORTS void demosaicing(const GpuMat &src, GpuMat &dst, int code, int dcn=-1, Stream &stream=Stream::Null())
class CV_EXPORTS BruteForceMatcher_GPU
Definition: gpu.hpp:1509
CV_EXPORTS void labelComponents(const GpuMat &mask, GpuMat &components, int flags=0, Stream &stream=Stream::Null())
performs connected componnents labeling.
int int channels
Definition: core_c.h:73
float data_weight
Definition: gpu.hpp:1154
Definition: gpu.hpp:827
int height
Definition: gpu.hpp:2462
Definition: gpu.hpp:585
int N2c
Definition: gpu.hpp:2052
CV_EXPORTS void warpPerspective(const GpuMat &src, GpuMat &dst, const Mat &M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, Scalar borderValue=Scalar(), Stream &stream=Stream::Null())
Definition: gpu.hpp:2439
int N2cc
Definition: gpu.hpp:2057
Definition: gpu.hpp:585
template 2D point class.
Definition: core.hpp:82
Definition: gpu.hpp:2452
int NaluFramingType
Definition: gpu.hpp:2373
BruteForceMatcher_GPU()
Definition: gpu.hpp:1522
CV_EXPORTS double norm(const GpuMat &src1, int normType=NORM_L2)
double win_sigma
Definition: gpu.hpp:1316
Definition: gpu.hpp:2438
CvArr double sp
Definition: imgproc_c.h:125
std::vector< std::vector< cv::Point > > foreground_regions
Definition: gpu.hpp:2094
Definition: imgproc.hpp:62
Definition: gpu.hpp:633
int N1cc
Definition: gpu.hpp:2056
const CvArr CvSize win_size
Definition: legacy.hpp:3123
int DIMode
Definition: gpu.hpp:2370
CV_EXPORTS void HoughCirclesDownload(const GpuMat &d_circles, OutputArray h_circles)
Definition: imgproc.hpp:66
Definition: gpu.hpp:1576
Definition: gpu.hpp:585
CV_EXPORTS void bitwise_or(const GpuMat &src1, const GpuMat &src2, GpuMat &dst, const GpuMat &mask=GpuMat(), Stream &stream=Stream::Null())
calculates per-element bit-wise disjunction of two arrays
int ksize
Definition: gpu.hpp:223
CvArr int code
Definition: imgproc_c.h:144
std::vector< GpuMat > image_scales
Definition: gpu.hpp:1349
GpuMat templ_block
Definition: gpu.hpp:765
GLboolean GLboolean GLboolean GLboolean a
Definition: legacy.hpp:633
int iters
Definition: gpu.hpp:1201
Definition: features2d.hpp:988
CV_EXPORTS Ptr< BaseFilter_GPU > getLinearFilter_GPU(int srcType, int dstType, const Mat &kernel, Point anchor=Point(-1,-1), int borderType=BORDER_DEFAULT)
Definition: imgproc.hpp:766
Definition: gpu.hpp:585
int int int * dx
Definition: gpu.hpp:2332
CV_EXPORTS void normalize(const GpuMat &src, GpuMat &dst, double alpha=1, double beta=0, int norm_type=NORM_L2, int dtype=-1, const GpuMat &mask=GpuMat())
scales and shifts array elements so that either the specified norm (alpha) or the minimum (alpha) and...
Definition: gpu.hpp:585
Base class for high-level OpenCV algorithms.
Definition: core.hpp:4390
const CvArr CvArr * disparity
Definition: calib3d.hpp:353
HoughLines.
Definition: gpu.hpp:877
CV_EXPORTS void connectivityMask(const GpuMat &image, GpuMat &mask, const cv::Scalar &lo, const cv::Scalar &hi, Stream &stream=Stream::Null())
compute mask for Generalized Flood fill componetns labeling.
GpuMat list
Definition: gpu.hpp:898
int numIters
Definition: gpu.hpp:1864
GLsizei const GLint * locations
CV_EXPORTS void dft(const GpuMat &src, GpuMat &dst, Size dft_size, int flags=0, Stream &stream=Stream::Null())
CV_EXPORTS void cartToPolar(const GpuMat &x, const GpuMat &y, GpuMat &magnitude, GpuMat &angle, bool angleInDegrees=false, Stream &stream=Stream::Null())
BruteForceMatcher_GPU(L2< T >)
Definition: gpu.hpp:1523
Size result_size
Definition: gpu.hpp:758
CV_EXPORTS void log(const GpuMat &a, GpuMat &b, Stream &stream=Stream::Null())
CV_EXPORTS void convolve(const GpuMat &image, const GpuMat &templ, GpuMat &result, bool ccorr=false)
int DisableSPSPPS
Definition: gpu.hpp:2374
CV_EXPORTS void drawColorDisp(const GpuMat &src_disp, GpuMat &dst_disp, int ndisp, Stream &stream=Stream::Null())
const CvMat CvSize image_size
Definition: calib3d.hpp:126
float learningRate
Set between 0.0 and 1.0, determines how quickly features are "forgotten" from histograms.
Definition: gpu.hpp:2278
Definition: gpu.hpp:2330
GpuMat labels_buf
Definition: gpu.hpp:1336
The Base Class for Column-wise Filters.
Definition: gpu.hpp:217
Definition: gpu.hpp:1635
Definition: gpu.hpp:2436
unsigned char uchar
Definition: types_c.h:170
Definition: gpu.hpp:1065
const CvArr CvSize CvArr * velx
Definition: legacy.hpp:3123
CV_EXPORTS void bitwise_and(const GpuMat &src1, const GpuMat &src2, GpuMat &dst, const GpuMat &mask=GpuMat(), Stream &stream=Stream::Null())
calculates per-element bit-wise conjunction of two arrays
GLenum GLsizei GLenum format
void setVideoParser(detail::VideoParser *videoParser)
Definition: gpu.hpp:2497
double const CvArr double double gamma
Definition: core_c.h:523
GLuint dst
Definition: calib3d.hpp:134
int P_Interval
Definition: gpu.hpp:2356
Definition: gpu.hpp:1170
CV_EXPORTS void swapChannels(GpuMat &image, const int dstOrder[4], Stream &stream=Stream::Null())
cv::gpu::GpuMat foreground
Definition: gpu.hpp:2092
Size user_block_size
Definition: gpu.hpp:760
int winSize
Definition: gpu.hpp:1863
Definition: gpu.hpp:778
CV_EXPORTS double threshold(const GpuMat &src, GpuMat &dst, double thresh, double maxval, int type, Stream &stream=Stream::Null())
applies fixed threshold to the image
int msg_type
Definition: gpu.hpp:1213
void releaseMemory()
Definition: gpu.hpp:1782
CV_EXPORTS void polarToCart(const GpuMat &magnitude, const GpuMat &angle, GpuMat &x, GpuMat &y, bool angleInDegrees=false, Stream &stream=Stream::Null())
CV_EXPORTS Scalar sum(const GpuMat &src)
CV_EXPORTS void sqrIntegral(const GpuMat &src, GpuMat &sqsum, Stream &stream=Stream::Null())
CV_EXPORTS void calcOpticalFlowBM(const GpuMat &prev, const GpuMat &curr, Size block_size, Size shift_size, Size max_range, bool use_previous, GpuMat &velx, GpuMat &vely, GpuMat &buf, Stream &stream=Stream::Null())
Calculates optical flow for 2 images using block matching algorithm */.
GpuMat accum
Definition: gpu.hpp:897
CV_EXPORTS Scalar absSum(const GpuMat &src)
const CvArr * templ
Definition: imgproc_c.h:281
Smart pointer to dynamically allocated objects.
Definition: core.hpp:1268
CV_EXPORTS void phase(const GpuMat &x, const GpuMat &y, GpuMat &angle, bool angleInDegrees=false, Stream &stream=Stream::Null())
GLdouble GLdouble GLdouble bottom
CV_EXPORTS Ptr< FilterEngine_GPU > createGaussianFilter_GPU(int type, Size ksize, double sigma1, double sigma2=0, int rowBorderType=BORDER_DEFAULT, int columnBorderType=-1)
returns the Gaussian filter engine
bool fastPyramids
Definition: gpu.hpp:1862
int ndisp
Definition: gpu.hpp:1199
CV_EXPORTS void meanShiftProc(const GpuMat &src, GpuMat &dstr, GpuMat &dstsp, int sp, int sr, TermCriteria criteria=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 5, 1), Stream &stream=Stream::Null())
Does mean shift procedure on GPU.
GpuMat mag
Definition: gpu.hpp:833
CV_EXPORTS Ptr< FilterEngine_GPU > createSeparableFilter_GPU(const Ptr< BaseRowFilter_GPU > &rowFilter, const Ptr< BaseColumnFilter_GPU > &columnFilter, int srcType, int bufType, int dstType)
returns the separable filter engine with the specified filters
int ProfileLevel
Definition: gpu.hpp:2366
const GLfloat * m
CvMat * points1
Definition: calib3d.hpp:117
float minArea
Definition: gpu.hpp:2070
Definition: gpu.hpp:585
Size block_stride
Definition: gpu.hpp:1313
Definition: gpu.hpp:1270
CV_EXPORTS void magnitudeSqr(const GpuMat &xy, GpuMat &magnitude, Stream &stream=Stream::Null())
float fVarInit
Definition: gpu.hpp:2205
Definition: gpu.hpp:643
bool supports(FeatureSet feature_set) const
CV_EXPORTS void bitwise_not(const GpuMat &src, GpuMat &dst, const GpuMat &mask=GpuMat(), Stream &stream=Stream::Null())
performs per-elements bit-wise inversion
Definition: gpu.hpp:1634
CvArr CvArr * temp
Definition: imgproc_c.h:242
CV_EXPORTS void remap(const GpuMat &src, GpuMat &dst, const GpuMat &xmap, const GpuMat &ymap, int interpolation, int borderMode=BORDER_CONSTANT, Scalar borderValue=Scalar(), Stream &stream=Stream::Null())
CV_EXPORTS void GaussianBlur(const GpuMat &src, GpuMat &dst, Size ksize, double sigma1, double sigma2=0, int rowBorderType=BORDER_DEFAULT, int columnBorderType=-1)
smooths the image using Gaussian filter.
CV_EXPORTS OutputArray noArray()
Definition: imgproc.hpp:64
GLenum GLenum GLenum GLenum GLenum scale
CV_EXPORTS void transformPoints(const GpuMat &src, const Mat &rvec, const Mat &tvec, GpuMat &dst, Stream &stream=Stream::Null())
CvArr double power
Definition: core_c.h:618
int preset
Definition: gpu.hpp:1096
Definition: gpu.hpp:70
CV_EXPORTS void mulAndScaleSpectrums(const GpuMat &a, const GpuMat &b, GpuMat &c, int flags, float scale, bool conjB=false, Stream &stream=Stream::Null())
int min_disp_th
Definition: gpu.hpp:1211
GLdouble s
const CvArr const CvArr * src2
Definition: core_c.h:436
double scale
Definition: gpu.hpp:1264
virtual ~FilterEngine_GPU()
Definition: gpu.hpp:250
GLenum GLint GLuint mask
Definition: tracking.hpp:132
int QP_Level_InterB
Definition: gpu.hpp:2364
double qualityLevel
Definition: gpu.hpp:1775
BruteForceMatcher_GPU()
Definition: gpu.hpp:1528
GLclampf f
CvPoint int radius
Definition: core_c.h:1290
float varThresholdGen
Definition: gpu.hpp:2198
BruteForceMatcher_GPU(L1< T >)
Definition: gpu.hpp:1516
CvLatentSvmDetector * detector
Definition: objdetect.hpp:270
BaseColumnFilter_GPU(int ksize_, int anchor_)
Definition: gpu.hpp:220
CV_EXPORTS void copyMakeBorder(const GpuMat &src, GpuMat &dst, int top, int bottom, int left, int right, int borderType, const Scalar &value=Scalar(), Stream &stream=Stream::Null())
copies 2D array to a larger destination array and pads borders with user-specifiable constant ...
CV_EXPORTS void calcHist(const GpuMat &src, GpuMat &hist, Stream &stream=Stream::Null())
CV_EXPORTS void alphaComp(const GpuMat &img1, const GpuMat &img2, GpuMat &dst, int alpha_op, Stream &stream=Stream::Null())
CV_EXPORTS void dilate(const GpuMat &src, GpuMat &dst, const Mat &kernel, Point anchor=Point(-1,-1), int iterations=1)
dilates the image (applies the local maximum operator)
float max_disc_term
Definition: gpu.hpp:1155
GLsizeiptr size
Definition: core_c.h:939
Scalar_< double > Scalar
Definition: core.hpp:968
Proxy datatype for passing Mat's and vector<>'s as input parameters.
Definition: core.hpp:1400
double minDistance
Definition: gpu.hpp:1776
Definition: features2d.hpp:972
Size user_block_size
Definition: gpu.hpp:780
Definition: gpu.hpp:1114
CV_EXPORTS void rotate(const GpuMat &src, GpuMat &dst, Size dsize, double angle, double xShift=0, double yShift=0, int interpolation=INTER_LINEAR, Stream &stream=Stream::Null())
CV_EXPORTS void Laplacian(const GpuMat &src, GpuMat &dst, int ddepth, int ksize=1, double scale=1, int borderType=BORDER_DEFAULT, Stream &stream=Stream::Null())
int * refcount
Definition: gpu.hpp:128
GpuMat dy
Definition: gpu.hpp:832
CV_EXPORTS void HoughLinesP(const GpuMat &image, GpuMat &lines, HoughLinesBuf &buf, float rho, float theta, int minLineLength, int maxLineGap, int maxLines=4096)
HoughLinesP.
double derivLambda
Definition: gpu.hpp:1828
Rect_< int > Rect
Definition: core.hpp:897
The Base Class for Filter Engine.
Definition: gpu.hpp:247
int Lc
Definition: gpu.hpp:2050
float max_data_term
Definition: gpu.hpp:1153
CV_EXPORTS void evenLevels(GpuMat &levels, int nLevels, int lowerLevel, int upperLevel)
Compute levels with even distribution. levels will have 1 row and nLevels cols and CV_32SC1 type...
std::vector< GpuMat > image_sums
Definition: gpu.hpp:783
Definition: gpu.hpp:1626
BFMatcher_GPU(int norm=NORM_L2)
Definition: gpu.hpp:1535
int history
Definition: gpu.hpp:2177
GpuMat st2
Definition: gpu.hpp:835
Definition: gpu.hpp:585
vector< Point > locations
Definition: gpu.hpp:1265
CV_EXPORTS void meanShiftFiltering(const GpuMat &src, GpuMat &dst, int sp, int sr, TermCriteria criteria=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 5, 1), Stream &stream=Stream::Null())
Does mean shift filtering on GPU.
double threshold_L2hys
Definition: gpu.hpp:1317
CV_EXPORTS void nonLocalMeans(const GpuMat &src, GpuMat &dst, float h, int search_window=21, int block_size=7, int borderMode=BORDER_DEFAULT, Stream &s=Stream::Null())
Brute force non-local means algorith (slow but universal)