1 /*M///////////////////////////////////////////////////////////////////////////////////////
\r
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
\r
5 // By downloading, copying, installing or using the software you agree to this license.
\r
6 // If you do not agree to this license, do not download, install,
\r
7 // copy or use the software.
\r
10 // License Agreement
\r
11 // For Open Source Computer Vision Library
\r
13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
\r
14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
\r
15 // Third party copyrights are property of their respective owners.
\r
17 // Redistribution and use in source and binary forms, with or without modification,
\r
18 // are permitted provided that the following conditions are met:
\r
20 // * Redistribution's of source code must retain the above copyright notice,
\r
21 // this list of conditions and the following disclaimer.
\r
23 // * Redistribution's in binary form must reproduce the above copyright notice,
\r
24 // this list of conditions and the following disclaimer in the documentation
\r
25 // and/or other GpuMaterials provided with the distribution.
\r
27 // * The name of the copyright holders may not be used to endorse or promote products
\r
28 // derived from this software without specific prior written permission.
\r
30 // This software is provided by the copyright holders and contributors "as is" and
\r
31 // any express or implied warranties, including, but not limited to, the implied
\r
32 // warranties of merchantability and fitness for a particular purpose are disclaimed.
\r
33 // In no event shall the Intel Corporation or contributors be liable for any direct,
\r
34 // indirect, incidental, special, exemplary, or consequential damages
\r
35 // (including, but not limited to, procurement of substitute goods or services;
\r
36 // loss of use, data, or profits; or business interruption) however caused
\r
37 // and on any theory of liability, whether in contract, strict liability,
\r
38 // or tort (including negligence or otherwise) arising in any way out of
\r
39 // the use of this software, even if advised of the possibility of such damage.
\r
43 #ifndef __OPENCV_GPU_HPP__
\r
44 #define __OPENCV_GPU_HPP__
\r
47 #include "opencv2/core/core.hpp"
\r
48 #include "opencv2/imgproc/imgproc.hpp"
\r
49 #include "opencv2/objdetect/objdetect.hpp"
\r
50 #include "opencv2/gpu/devmem2d.hpp"
\r
51 #include "opencv2/features2d/features2d.hpp"
\r
57 //////////////////////////////// Initialization & Info ////////////////////////
\r
59 //! This is the only function that do not throw exceptions if the library is compiled without Cuda.
\r
60 CV_EXPORTS int getCudaEnabledDeviceCount();
\r
62 //! Functions below throw cv::Expception if the library is compiled without Cuda.
\r
63 CV_EXPORTS string getDeviceName(int device);
\r
64 CV_EXPORTS void setDevice(int device);
\r
65 CV_EXPORTS int getDevice();
\r
67 CV_EXPORTS void getComputeCapability(int device, int& major, int& minor);
\r
68 CV_EXPORTS int getNumberOfSMs(int device);
\r
70 CV_EXPORTS void getGpuMemInfo(size_t& free, size_t& total);
\r
72 CV_EXPORTS bool hasNativeDoubleSupport(int device);
\r
73 CV_EXPORTS bool hasAtomicsSupport(int device);
\r
75 CV_EXPORTS bool hasPtxVersion(int major, int minor);
\r
76 CV_EXPORTS bool hasLessOrEqualPtxVersion(int major, int minor);
\r
77 CV_EXPORTS bool hasGreaterOrEqualPtxVersion(int major, int minor);
\r
79 CV_EXPORTS bool hasCubinVersion(int major, int minor);
\r
80 CV_EXPORTS bool hasGreaterOrEqualCubinVersion(int major, int minor);
\r
82 CV_EXPORTS bool hasVersion(int major, int minor);
\r
83 CV_EXPORTS bool hasGreaterOrEqualVersion(int major, int minor);
\r
85 CV_EXPORTS bool isCompatibleWith(int device);
\r
87 //////////////////////////////// Error handling ////////////////////////
\r
89 CV_EXPORTS void error(const char *error_string, const char *file, const int line, const char *func);
\r
90 CV_EXPORTS void nppError( int err, const char *file, const int line, const char *func);
\r
92 //////////////////////////////// GpuMat ////////////////////////////////
\r
96 //! Smart pointer for GPU memory with reference counting. Its interface is mostly similar with cv::Mat.
\r
97 class CV_EXPORTS GpuMat
\r
100 //! default constructor
\r
102 //! constructs GpuMatrix of the specified size and type (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.)
\r
103 GpuMat(int rows, int cols, int type);
\r
104 GpuMat(Size size, int type);
\r
105 //! constucts GpuMatrix and fills it with the specified value _s.
\r
106 GpuMat(int rows, int cols, int type, const Scalar& s);
\r
107 GpuMat(Size size, int type, const Scalar& s);
\r
108 //! copy constructor
\r
109 GpuMat(const GpuMat& m);
\r
111 //! constructor for GpuMatrix headers pointing to user-allocated data
\r
112 GpuMat(int rows, int cols, int type, void* data, size_t step = Mat::AUTO_STEP);
\r
113 GpuMat(Size size, int type, void* data, size_t step = Mat::AUTO_STEP);
\r
115 //! creates a matrix header for a part of the bigger matrix
\r
116 GpuMat(const GpuMat& m, const Range& rowRange, const Range& colRange);
\r
117 GpuMat(const GpuMat& m, const Rect& roi);
\r
119 //! builds GpuMat from Mat. Perfom blocking upload to device.
\r
120 explicit GpuMat (const Mat& m);
\r
122 //! destructor - calls release()
\r
125 //! assignment operators
\r
126 GpuMat& operator = (const GpuMat& m);
\r
127 //! assignment operator. Perfom blocking upload to device.
\r
128 GpuMat& operator = (const Mat& m);
\r
130 //! returns lightweight DevMem2D_ structure for passing to nvcc-compiled code.
\r
131 // Contains just image size, data ptr and step.
\r
132 template <class T> operator DevMem2D_<T>() const;
\r
133 template <class T> operator PtrStep_<T>() const;
\r
135 //! pefroms blocking upload data to GpuMat.
\r
136 void upload(const cv::Mat& m);
\r
139 void upload(const CudaMem& m, Stream& stream);
\r
141 //! downloads data from device to host memory. Blocking calls.
\r
142 operator Mat() const;
\r
143 void download(cv::Mat& m) const;
\r
146 void download(CudaMem& m, Stream& stream) const;
\r
148 //! returns a new GpuMatrix header for the specified row
\r
149 GpuMat row(int y) const;
\r
150 //! returns a new GpuMatrix header for the specified column
\r
151 GpuMat col(int x) const;
\r
152 //! ... for the specified row span
\r
153 GpuMat rowRange(int startrow, int endrow) const;
\r
154 GpuMat rowRange(const Range& r) const;
\r
155 //! ... for the specified column span
\r
156 GpuMat colRange(int startcol, int endcol) const;
\r
157 GpuMat colRange(const Range& r) const;
\r
159 //! returns deep copy of the GpuMatrix, i.e. the data is copied
\r
160 GpuMat clone() const;
\r
161 //! copies the GpuMatrix content to "m".
\r
162 // It calls m.create(this->size(), this->type()).
\r
163 void copyTo( GpuMat& m ) const;
\r
164 //! copies those GpuMatrix elements to "m" that are marked with non-zero mask elements.
\r
165 void copyTo( GpuMat& m, const GpuMat& mask ) const;
\r
166 //! converts GpuMatrix to another datatype with optional scalng. See cvConvertScale.
\r
167 void convertTo( GpuMat& m, int rtype, double alpha=1, double beta=0 ) const;
\r
169 void assignTo( GpuMat& m, int type=-1 ) const;
\r
171 //! sets every GpuMatrix element to s
\r
172 GpuMat& operator = (const Scalar& s);
\r
173 //! sets some of the GpuMatrix elements to s, according to the mask
\r
174 GpuMat& setTo(const Scalar& s, const GpuMat& mask = GpuMat());
\r
175 //! creates alternative GpuMatrix header for the same data, with different
\r
176 // number of channels and/or different number of rows. see cvReshape.
\r
177 GpuMat reshape(int cn, int rows = 0) const;
\r
179 //! allocates new GpuMatrix data unless the GpuMatrix already has specified size and type.
\r
180 // previous data is unreferenced if needed.
\r
181 void create(int rows, int cols, int type);
\r
182 void create(Size size, int type);
\r
183 //! decreases reference counter;
\r
184 // deallocate the data when reference counter reaches 0.
\r
187 //! swaps with other smart pointer
\r
188 void swap(GpuMat& mat);
\r
190 //! locates GpuMatrix header within a parent GpuMatrix. See below
\r
191 void locateROI( Size& wholeSize, Point& ofs ) const;
\r
192 //! moves/resizes the current GpuMatrix ROI inside the parent GpuMatrix.
\r
193 GpuMat& adjustROI( int dtop, int dbottom, int dleft, int dright );
\r
194 //! extracts a rectangular sub-GpuMatrix
\r
195 // (this is a generalized form of row, rowRange etc.)
\r
196 GpuMat operator()( Range rowRange, Range colRange ) const;
\r
197 GpuMat operator()( const Rect& roi ) const;
\r
199 //! returns true iff the GpuMatrix data is continuous
\r
200 // (i.e. when there are no gaps between successive rows).
\r
201 // similar to CV_IS_GpuMat_CONT(cvGpuMat->type)
\r
202 bool isContinuous() const;
\r
203 //! returns element size in bytes,
\r
204 // similar to CV_ELEM_SIZE(cvMat->type)
\r
205 size_t elemSize() const;
\r
206 //! returns the size of element channel in bytes.
\r
207 size_t elemSize1() const;
\r
208 //! returns element type, similar to CV_MAT_TYPE(cvMat->type)
\r
210 //! returns element type, similar to CV_MAT_DEPTH(cvMat->type)
\r
212 //! returns element type, similar to CV_MAT_CN(cvMat->type)
\r
213 int channels() const;
\r
214 //! returns step/elemSize1()
\r
215 size_t step1() const;
\r
216 //! returns GpuMatrix size:
\r
217 // width == number of columns, height == number of rows
\r
219 //! returns true if GpuMatrix data is NULL
\r
220 bool empty() const;
\r
222 //! returns pointer to y-th row
\r
223 uchar* ptr(int y = 0);
\r
224 const uchar* ptr(int y = 0) const;
\r
226 //! template version of the above method
\r
227 template<typename _Tp> _Tp* ptr(int y = 0);
\r
228 template<typename _Tp> const _Tp* ptr(int y = 0) const;
\r
230 //! matrix transposition
\r
233 /*! includes several bit-fields:
\r
234 - the magic signature
\r
237 - number of channels
\r
240 //! the number of rows and columns
\r
242 //! a distance between successive rows in bytes; includes the gap if any
\r
244 //! pointer to the data
\r
247 //! pointer to the reference counter;
\r
248 // when GpuMatrix points to user-allocated data, the pointer is NULL
\r
251 //! helper fields used in locateROI and adjustROI
\r
256 //#define TemplatedGpuMat // experimental now, deprecated to use
\r
257 #ifdef TemplatedGpuMat
\r
258 #include "GpuMat_BetaDeprecated.hpp"
\r
261 //! Creates continuous GPU matrix
\r
262 CV_EXPORTS void createContinuous(int rows, int cols, int type, GpuMat& m);
\r
264 //! Ensures that size of the given matrix is not less than (rows, cols) size
\r
265 //! and matrix type is match specified one too
\r
266 CV_EXPORTS void ensureSizeIsEnough(int rows, int cols, int type, GpuMat& m);
\r
268 //////////////////////////////// CudaMem ////////////////////////////////
\r
269 // CudaMem is limited cv::Mat with page locked memory allocation.
\r
270 // Page locked memory is only needed for async and faster coping to GPU.
\r
271 // It is convertable to cv::Mat header without reference counting
\r
272 // so you can use it with other opencv functions.
\r
274 class CV_EXPORTS CudaMem
\r
277 enum { ALLOC_PAGE_LOCKED = 1, ALLOC_ZEROCOPY = 2, ALLOC_WRITE_COMBINED = 4 };
\r
280 CudaMem(const CudaMem& m);
\r
282 CudaMem(int rows, int cols, int type, int _alloc_type = ALLOC_PAGE_LOCKED);
\r
283 CudaMem(Size size, int type, int alloc_type = ALLOC_PAGE_LOCKED);
\r
286 //! creates from cv::Mat with coping data
\r
287 explicit CudaMem(const Mat& m, int alloc_type = ALLOC_PAGE_LOCKED);
\r
291 CudaMem& operator = (const CudaMem& m);
\r
293 //! returns deep copy of the matrix, i.e. the data is copied
\r
294 CudaMem clone() const;
\r
296 //! allocates new matrix data unless the matrix already has specified size and type.
\r
297 void create(int rows, int cols, int type, int alloc_type = ALLOC_PAGE_LOCKED);
\r
298 void create(Size size, int type, int alloc_type = ALLOC_PAGE_LOCKED);
\r
300 //! decrements reference counter and released memory if needed.
\r
303 //! returns matrix header with disabled reference counting for CudaMem data.
\r
304 Mat createMatHeader() const;
\r
305 operator Mat() const;
\r
307 //! maps host memory into device address space and returns GpuMat header for it. Throws exception if not supported by hardware.
\r
308 GpuMat createGpuMatHeader() const;
\r
309 operator GpuMat() const;
\r
311 //returns if host memory can be mapperd to gpu address space;
\r
312 static bool canMapHostMemory();
\r
314 // Please see cv::Mat for descriptions
\r
315 bool isContinuous() const;
\r
316 size_t elemSize() const;
\r
317 size_t elemSize1() const;
\r
320 int channels() const;
\r
321 size_t step1() const;
\r
323 bool empty() const;
\r
326 // Please see cv::Mat for descriptions
\r
340 //////////////////////////////// CudaStream ////////////////////////////////
\r
341 // Encapculates Cuda Stream. Provides interface for async coping.
\r
342 // Passed to each function that supports async kernel execution.
\r
343 // Reference counting is enabled
\r
345 class CV_EXPORTS Stream
\r
351 Stream(const Stream&);
\r
352 Stream& operator=(const Stream&);
\r
354 bool queryIfComplete();
\r
355 void waitForCompletion();
\r
357 //! downloads asynchronously.
\r
358 // Warning! cv::Mat must point to page locked memory (i.e. to CudaMem data or to its subMat)
\r
359 void enqueueDownload(const GpuMat& src, CudaMem& dst);
\r
360 void enqueueDownload(const GpuMat& src, Mat& dst);
\r
362 //! uploads asynchronously.
\r
363 // Warning! cv::Mat must point to page locked memory (i.e. to CudaMem data or to its ROI)
\r
364 void enqueueUpload(const CudaMem& src, GpuMat& dst);
\r
365 void enqueueUpload(const Mat& src, GpuMat& dst);
\r
367 void enqueueCopy(const GpuMat& src, GpuMat& dst);
\r
369 void enqueueMemSet(const GpuMat& src, Scalar val);
\r
370 void enqueueMemSet(const GpuMat& src, Scalar val, const GpuMat& mask);
\r
372 // converts matrix type, ex from float to uchar depending on type
\r
373 void enqueueConvert(const GpuMat& src, GpuMat& dst, int type, double a = 1, double b = 0);
\r
379 friend struct StreamAccessor;
\r
383 ////////////////////////////// Arithmetics ///////////////////////////////////
\r
385 //! transposes the matrix
\r
386 //! supports matrix with element size = 1, 4 and 8 bytes (CV_8UC1, CV_8UC4, CV_16UC2, CV_32FC1, etc)
\r
387 CV_EXPORTS void transpose(const GpuMat& src1, GpuMat& dst);
\r
389 //! reverses the order of the rows, columns or both in a matrix
\r
390 //! supports CV_8UC1, CV_8UC4 types
\r
391 CV_EXPORTS void flip(const GpuMat& a, GpuMat& b, int flipCode);
\r
393 //! transforms 8-bit unsigned integers using lookup table: dst(i)=lut(src(i))
\r
394 //! destination array will have the depth type as lut and the same channels number as source
\r
395 //! supports CV_8UC1, CV_8UC3 types
\r
396 CV_EXPORTS void LUT(const GpuMat& src, const Mat& lut, GpuMat& dst);
\r
398 //! makes multi-channel array out of several single-channel arrays
\r
399 CV_EXPORTS void merge(const GpuMat* src, size_t n, GpuMat& dst);
\r
401 //! makes multi-channel array out of several single-channel arrays
\r
402 CV_EXPORTS void merge(const vector<GpuMat>& src, GpuMat& dst);
\r
404 //! makes multi-channel array out of several single-channel arrays (async version)
\r
405 CV_EXPORTS void merge(const GpuMat* src, size_t n, GpuMat& dst, const Stream& stream);
\r
407 //! makes multi-channel array out of several single-channel arrays (async version)
\r
408 CV_EXPORTS void merge(const vector<GpuMat>& src, GpuMat& dst, const Stream& stream);
\r
410 //! copies each plane of a multi-channel array to a dedicated array
\r
411 CV_EXPORTS void split(const GpuMat& src, GpuMat* dst);
\r
413 //! copies each plane of a multi-channel array to a dedicated array
\r
414 CV_EXPORTS void split(const GpuMat& src, vector<GpuMat>& dst);
\r
416 //! copies each plane of a multi-channel array to a dedicated array (async version)
\r
417 CV_EXPORTS void split(const GpuMat& src, GpuMat* dst, const Stream& stream);
\r
419 //! copies each plane of a multi-channel array to a dedicated array (async version)
\r
420 CV_EXPORTS void split(const GpuMat& src, vector<GpuMat>& dst, const Stream& stream);
\r
422 //! computes magnitude of complex (x(i).re, x(i).im) vector
\r
423 //! supports only CV_32FC2 type
\r
424 CV_EXPORTS void magnitude(const GpuMat& x, GpuMat& magnitude);
\r
426 //! computes squared magnitude of complex (x(i).re, x(i).im) vector
\r
427 //! supports only CV_32FC2 type
\r
428 CV_EXPORTS void magnitudeSqr(const GpuMat& x, GpuMat& magnitude);
\r
430 //! computes magnitude of each (x(i), y(i)) vector
\r
431 //! supports only floating-point source
\r
432 CV_EXPORTS void magnitude(const GpuMat& x, const GpuMat& y, GpuMat& magnitude);
\r
434 CV_EXPORTS void magnitude(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, const Stream& stream);
\r
436 //! computes squared magnitude of each (x(i), y(i)) vector
\r
437 //! supports only floating-point source
\r
438 CV_EXPORTS void magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& magnitude);
\r
440 CV_EXPORTS void magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, const Stream& stream);
\r
442 //! computes angle (angle(i)) of each (x(i), y(i)) vector
\r
443 //! supports only floating-point source
\r
444 CV_EXPORTS void phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees = false);
\r
446 CV_EXPORTS void phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees, const Stream& stream);
\r
448 //! converts Cartesian coordinates to polar
\r
449 //! supports only floating-point source
\r
450 CV_EXPORTS void cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, GpuMat& angle, bool angleInDegrees = false);
\r
452 CV_EXPORTS void cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, GpuMat& angle, bool angleInDegrees, const Stream& stream);
\r
454 //! converts polar coordinates to Cartesian
\r
455 //! supports only floating-point source
\r
456 CV_EXPORTS void polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees = false);
\r
458 CV_EXPORTS void polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees, const Stream& stream);
\r
461 //////////////////////////// Per-element operations ////////////////////////////////////
\r
463 //! adds one matrix to another (c = a + b)
\r
464 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
465 CV_EXPORTS void add(const GpuMat& a, const GpuMat& b, GpuMat& c);
\r
466 //! adds scalar to a matrix (c = a + s)
\r
467 //! supports CV_32FC1 and CV_32FC2 type
\r
468 CV_EXPORTS void add(const GpuMat& a, const Scalar& sc, GpuMat& c);
\r
470 //! subtracts one matrix from another (c = a - b)
\r
471 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
472 CV_EXPORTS void subtract(const GpuMat& a, const GpuMat& b, GpuMat& c);
\r
473 //! subtracts scalar from a matrix (c = a - s)
\r
474 //! supports CV_32FC1 and CV_32FC2 type
\r
475 CV_EXPORTS void subtract(const GpuMat& a, const Scalar& sc, GpuMat& c);
\r
477 //! computes element-wise product of the two arrays (c = a * b)
\r
478 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
479 CV_EXPORTS void multiply(const GpuMat& a, const GpuMat& b, GpuMat& c);
\r
480 //! multiplies matrix to a scalar (c = a * s)
\r
481 //! supports CV_32FC1 and CV_32FC2 type
\r
482 CV_EXPORTS void multiply(const GpuMat& a, const Scalar& sc, GpuMat& c);
\r
484 //! computes element-wise quotient of the two arrays (c = a / b)
\r
485 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
486 CV_EXPORTS void divide(const GpuMat& a, const GpuMat& b, GpuMat& c);
\r
487 //! computes element-wise quotient of matrix and scalar (c = a / s)
\r
488 //! supports CV_32FC1 and CV_32FC2 type
\r
489 CV_EXPORTS void divide(const GpuMat& a, const Scalar& sc, GpuMat& c);
\r
491 //! computes exponent of each matrix element (b = e**a)
\r
492 //! supports only CV_32FC1 type
\r
493 CV_EXPORTS void exp(const GpuMat& a, GpuMat& b);
\r
495 //! computes natural logarithm of absolute value of each matrix element: b = log(abs(a))
\r
496 //! supports only CV_32FC1 type
\r
497 CV_EXPORTS void log(const GpuMat& a, GpuMat& b);
\r
499 //! computes element-wise absolute difference of two arrays (c = abs(a - b))
\r
500 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
501 CV_EXPORTS void absdiff(const GpuMat& a, const GpuMat& b, GpuMat& c);
\r
502 //! computes element-wise absolute difference of array and scalar (c = abs(a - s))
\r
503 //! supports only CV_32FC1 type
\r
504 CV_EXPORTS void absdiff(const GpuMat& a, const Scalar& s, GpuMat& c);
\r
506 //! compares elements of two arrays (c = a <cmpop> b)
\r
507 //! supports CV_8UC4, CV_32FC1 types
\r
508 CV_EXPORTS void compare(const GpuMat& a, const GpuMat& b, GpuMat& c, int cmpop);
\r
510 //! performs per-elements bit-wise inversion
\r
511 CV_EXPORTS void bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask=GpuMat());
\r
513 CV_EXPORTS void bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask, const Stream& stream);
\r
515 //! calculates per-element bit-wise disjunction of two arrays
\r
516 CV_EXPORTS void bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat());
\r
518 CV_EXPORTS void bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, const Stream& stream);
\r
520 //! calculates per-element bit-wise conjunction of two arrays
\r
521 CV_EXPORTS void bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat());
\r
523 CV_EXPORTS void bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, const Stream& stream);
\r
525 //! calculates per-element bit-wise "exclusive or" operation
\r
526 CV_EXPORTS void bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat());
\r
528 CV_EXPORTS void bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, const Stream& stream);
\r
530 //! computes per-element minimum of two arrays (dst = min(src1, src2))
\r
531 CV_EXPORTS void min(const GpuMat& src1, const GpuMat& src2, GpuMat& dst);
\r
533 CV_EXPORTS void min(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const Stream& stream);
\r
535 //! computes per-element minimum of array and scalar (dst = min(src1, src2))
\r
536 CV_EXPORTS void min(const GpuMat& src1, double src2, GpuMat& dst);
\r
538 CV_EXPORTS void min(const GpuMat& src1, double src2, GpuMat& dst, const Stream& stream);
\r
540 //! computes per-element maximum of two arrays (dst = max(src1, src2))
\r
541 CV_EXPORTS void max(const GpuMat& src1, const GpuMat& src2, GpuMat& dst);
\r
543 CV_EXPORTS void max(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const Stream& stream);
\r
545 //! computes per-element maximum of array and scalar (dst = max(src1, src2))
\r
546 CV_EXPORTS void max(const GpuMat& src1, double src2, GpuMat& dst);
\r
548 CV_EXPORTS void max(const GpuMat& src1, double src2, GpuMat& dst, const Stream& stream);
\r
551 ////////////////////////////// Image processing //////////////////////////////
\r
553 //! DST[x,y] = SRC[xmap[x,y],ymap[x,y]] with bilinear interpolation.
\r
554 //! supports CV_8UC1, CV_8UC3 source types and CV_32FC1 map type
\r
555 CV_EXPORTS void remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap);
\r
557 //! Does mean shift filtering on GPU.
\r
558 CV_EXPORTS void meanShiftFiltering(const GpuMat& src, GpuMat& dst, int sp, int sr,
\r
559 TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
\r
561 //! Does mean shift procedure on GPU.
\r
562 CV_EXPORTS void meanShiftProc(const GpuMat& src, GpuMat& dstr, GpuMat& dstsp, int sp, int sr,
\r
563 TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
\r
565 //! Does mean shift segmentation with elimination of small regions.
\r
566 CV_EXPORTS void meanShiftSegmentation(const GpuMat& src, Mat& dst, int sp, int sr, int minsize,
\r
567 TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
\r
569 //! Does coloring of disparity image: [0..ndisp) -> [0..240, 1, 1] in HSV.
\r
570 //! Supported types of input disparity: CV_8U, CV_16S.
\r
571 //! Output disparity has CV_8UC4 type in BGRA format (alpha = 255).
\r
572 CV_EXPORTS void drawColorDisp(const GpuMat& src_disp, GpuMat& dst_disp, int ndisp);
\r
574 CV_EXPORTS void drawColorDisp(const GpuMat& src_disp, GpuMat& dst_disp, int ndisp, const Stream& stream);
\r
576 //! Reprojects disparity image to 3D space.
\r
577 //! Supports CV_8U and CV_16S types of input disparity.
\r
578 //! The output is a 4-channel floating-point (CV_32FC4) matrix.
\r
579 //! Each element of this matrix will contain the 3D coordinates of the point (x,y,z,1), computed from the disparity map.
\r
580 //! Q is the 4x4 perspective transformation matrix that can be obtained with cvStereoRectify.
\r
581 CV_EXPORTS void reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q);
\r
583 CV_EXPORTS void reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q, const Stream& stream);
\r
585 //! converts image from one color space to another
\r
586 CV_EXPORTS void cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn = 0);
\r
588 CV_EXPORTS void cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn, const Stream& stream);
\r
590 //! applies fixed threshold to the image.
\r
591 //! Now supports only THRESH_TRUNC threshold type and one channels float source.
\r
592 CV_EXPORTS double threshold(const GpuMat& src, GpuMat& dst, double thresh);
\r
594 //! resizes the image
\r
595 //! Supports INTER_NEAREST, INTER_LINEAR
\r
596 //! supports CV_8UC1, CV_8UC4 types
\r
597 CV_EXPORTS void resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx=0, double fy=0, int interpolation = INTER_LINEAR);
\r
599 //! warps the image using affine transformation
\r
600 //! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
\r
601 CV_EXPORTS void warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR);
\r
603 //! warps the image using perspective transformation
\r
604 //! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
\r
605 CV_EXPORTS void warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR);
\r
607 //! rotate 8bit single or four channel image
\r
608 //! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
\r
609 //! supports CV_8UC1, CV_8UC4 types
\r
610 CV_EXPORTS void rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift = 0, double yShift = 0, int interpolation = INTER_LINEAR);
\r
612 //! copies 2D array to a larger destination array and pads borders with user-specifiable constant
\r
613 //! supports CV_8UC1, CV_8UC4, CV_32SC1 and CV_32FC1 types
\r
614 CV_EXPORTS void copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, const Scalar& value = Scalar());
\r
616 //! computes the integral image
\r
617 //! sum will have CV_32S type, but will contain unsigned int values
\r
618 //! supports only CV_8UC1 source type
\r
619 CV_EXPORTS void integral(const GpuMat& src, GpuMat& sum);
\r
621 //! computes the integral image and integral for the squared image
\r
622 //! sum will have CV_32S type, sqsum - CV32F type
\r
623 //! supports only CV_8UC1 source type
\r
624 CV_EXPORTS void integral(const GpuMat& src, GpuMat& sum, GpuMat& sqsum);
\r
626 //! computes squared integral image
\r
627 //! result matrix will have 64F type, but will contain 64U values
\r
628 //! supports source images of 8UC1 type only
\r
629 CV_EXPORTS void sqrIntegral(const GpuMat& src, GpuMat& sqsum);
\r
631 //! computes vertical sum, supports only CV_32FC1 images
\r
632 CV_EXPORTS void columnSum(const GpuMat& src, GpuMat& sum);
\r
634 //! computes the standard deviation of integral images
\r
635 //! supports only CV_32SC1 source type and CV_32FC1 sqr type
\r
636 //! output will have CV_32FC1 type
\r
637 CV_EXPORTS void rectStdDev(const GpuMat& src, const GpuMat& sqr, GpuMat& dst, const Rect& rect);
\r
639 //! applies Canny edge detector and produces the edge map
\r
640 //! supprots only CV_8UC1 source type
\r
641 //! disabled until fix crash
\r
642 CV_EXPORTS void Canny(const GpuMat& image, GpuMat& edges, double threshold1, double threshold2, int apertureSize = 3);
\r
644 //! computes Harris cornerness criteria at each image pixel
\r
645 CV_EXPORTS void cornerHarris(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, double k, int borderType=BORDER_REFLECT101);
\r
647 //! computes minimum eigen value of 2x2 derivative covariation matrix at each pixel - the cornerness criteria
\r
648 CV_EXPORTS void cornerMinEigenVal(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, int borderType=BORDER_REFLECT101);
\r
650 //! performs per-element multiplication of two full (not packed) Fourier spectrums
\r
651 //! supports 32FC2 matrixes only (interleaved format)
\r
652 CV_EXPORTS void mulSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flags, bool conjB=false);
\r
654 //! performs per-element multiplication of two full (not packed) Fourier spectrums
\r
655 //! supports 32FC2 matrixes only (interleaved format)
\r
656 CV_EXPORTS void mulAndScaleSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flags,
\r
657 float scale, bool conjB=false);
\r
659 //! Performs a forward or inverse discrete Fourier transform (1D or 2D) of floating point matrix.
\r
660 //! Param dft_size is the size of DFT transform.
\r
662 //! If the source matrix is not continous, then additional copy will be done,
\r
663 //! so to avoid copying ensure the source matrix is continous one. If you want to use
\r
664 //! preallocated output ensure it is continuous too, otherwise it will be reallocated.
\r
666 //! Being implemented via CUFFT real-to-complex transform result contains only non-redundant values
\r
667 //! in CUFFT's format. Result as full complex matrix for such kind of transform cannot be retrieved.
\r
669 //! For complex-to-real transform it is assumed that the source matrix is packed in CUFFT's format.
\r
670 CV_EXPORTS void dft(const GpuMat& src, GpuMat& dst, Size dft_size, int flags=0);
\r
672 //! computes convolution (or cross-correlation) of two images using discrete Fourier transform
\r
673 //! supports source images of 32FC1 type only
\r
674 //! result matrix will have 32FC1 type
\r
675 CV_EXPORTS void convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result,
\r
678 struct CV_EXPORTS ConvolveBuf;
\r
680 //! buffered version
\r
681 CV_EXPORTS void convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result,
\r
682 bool ccorr, ConvolveBuf& buf);
\r
684 struct CV_EXPORTS ConvolveBuf
\r
687 ConvolveBuf(Size image_size, Size templ_size)
\r
688 { create(image_size, templ_size); }
\r
689 void create(Size image_size, Size templ_size);
\r
692 static Size estimateBlockSize(Size result_size, Size templ_size);
\r
693 friend void convolve(const GpuMat&, const GpuMat&, GpuMat&, bool, ConvolveBuf&);
\r
700 GpuMat image_spect, templ_spect, result_spect;
\r
701 GpuMat image_block, templ_block, result_data;
\r
704 //! computes the proximity map for the raster template and the image where the template is searched for
\r
705 CV_EXPORTS void matchTemplate(const GpuMat& image, const GpuMat& templ, GpuMat& result, int method);
\r
708 ////////////////////////////// Matrix reductions //////////////////////////////
\r
710 //! computes mean value and standard deviation of all or selected array elements
\r
711 //! supports only CV_8UC1 type
\r
712 CV_EXPORTS void meanStdDev(const GpuMat& mtx, Scalar& mean, Scalar& stddev);
\r
714 //! computes norm of array
\r
715 //! supports NORM_INF, NORM_L1, NORM_L2
\r
716 //! supports only CV_8UC1 type
\r
717 CV_EXPORTS double norm(const GpuMat& src1, int normType=NORM_L2);
\r
719 //! computes norm of the difference between two arrays
\r
720 //! supports NORM_INF, NORM_L1, NORM_L2
\r
721 //! supports only CV_8UC1 type
\r
722 CV_EXPORTS double norm(const GpuMat& src1, const GpuMat& src2, int normType=NORM_L2);
\r
724 //! computes sum of array elements
\r
725 //! supports only single channel images
\r
726 CV_EXPORTS Scalar sum(const GpuMat& src);
\r
728 //! computes sum of array elements
\r
729 //! supports only single channel images
\r
730 CV_EXPORTS Scalar sum(const GpuMat& src, GpuMat& buf);
\r
732 //! computes squared sum of array elements
\r
733 //! supports only single channel images
\r
734 CV_EXPORTS Scalar sqrSum(const GpuMat& src);
\r
736 //! computes squared sum of array elements
\r
737 //! supports only single channel images
\r
738 CV_EXPORTS Scalar sqrSum(const GpuMat& src, GpuMat& buf);
\r
740 //! finds global minimum and maximum array elements and returns their values
\r
741 CV_EXPORTS void minMax(const GpuMat& src, double* minVal, double* maxVal=0, const GpuMat& mask=GpuMat());
\r
743 //! finds global minimum and maximum array elements and returns their values
\r
744 CV_EXPORTS void minMax(const GpuMat& src, double* minVal, double* maxVal, const GpuMat& mask, GpuMat& buf);
\r
746 //! finds global minimum and maximum array elements and returns their values with locations
\r
747 CV_EXPORTS void minMaxLoc(const GpuMat& src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0,
\r
748 const GpuMat& mask=GpuMat());
\r
750 //! finds global minimum and maximum array elements and returns their values with locations
\r
751 CV_EXPORTS void minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point* minLoc, Point* maxLoc,
\r
752 const GpuMat& mask, GpuMat& valbuf, GpuMat& locbuf);
\r
754 //! counts non-zero array elements
\r
755 CV_EXPORTS int countNonZero(const GpuMat& src);
\r
757 //! counts non-zero array elements
\r
758 CV_EXPORTS int countNonZero(const GpuMat& src, GpuMat& buf);
\r
761 //////////////////////////////// Filter Engine ////////////////////////////////
\r
764 The Base Class for 1D or Row-wise Filters
\r
766 This is the base class for linear or non-linear filters that process 1D data.
\r
767 In particular, such filters are used for the "horizontal" filtering parts in separable filters.
\r
769 class CV_EXPORTS BaseRowFilter_GPU
\r
772 BaseRowFilter_GPU(int ksize_, int anchor_) : ksize(ksize_), anchor(anchor_) {}
\r
773 virtual ~BaseRowFilter_GPU() {}
\r
774 virtual void operator()(const GpuMat& src, GpuMat& dst) = 0;
\r
779 The Base Class for Column-wise Filters
\r
781 This is the base class for linear or non-linear filters that process columns of 2D arrays.
\r
782 Such filters are used for the "vertical" filtering parts in separable filters.
\r
784 class CV_EXPORTS BaseColumnFilter_GPU
\r
787 BaseColumnFilter_GPU(int ksize_, int anchor_) : ksize(ksize_), anchor(anchor_) {}
\r
788 virtual ~BaseColumnFilter_GPU() {}
\r
789 virtual void operator()(const GpuMat& src, GpuMat& dst) = 0;
\r
794 The Base Class for Non-Separable 2D Filters.
\r
796 This is the base class for linear or non-linear 2D filters.
\r
798 class CV_EXPORTS BaseFilter_GPU
\r
801 BaseFilter_GPU(const Size& ksize_, const Point& anchor_) : ksize(ksize_), anchor(anchor_) {}
\r
802 virtual ~BaseFilter_GPU() {}
\r
803 virtual void operator()(const GpuMat& src, GpuMat& dst) = 0;
\r
809 The Base Class for Filter Engine.
\r
811 The class can be used to apply an arbitrary filtering operation to an image.
\r
812 It contains all the necessary intermediate buffers.
\r
814 class CV_EXPORTS FilterEngine_GPU
\r
817 virtual ~FilterEngine_GPU() {}
\r
819 virtual void apply(const GpuMat& src, GpuMat& dst, Rect roi = Rect(0,0,-1,-1)) = 0;
\r
822 //! returns the non-separable filter engine with the specified filter
\r
823 CV_EXPORTS Ptr<FilterEngine_GPU> createFilter2D_GPU(const Ptr<BaseFilter_GPU>& filter2D, int srcType, int dstType);
\r
825 //! returns the separable filter engine with the specified filters
\r
826 CV_EXPORTS Ptr<FilterEngine_GPU> createSeparableFilter_GPU(const Ptr<BaseRowFilter_GPU>& rowFilter,
\r
827 const Ptr<BaseColumnFilter_GPU>& columnFilter, int srcType, int bufType, int dstType);
\r
829 //! returns horizontal 1D box filter
\r
830 //! supports only CV_8UC1 source type and CV_32FC1 sum type
\r
831 CV_EXPORTS Ptr<BaseRowFilter_GPU> getRowSumFilter_GPU(int srcType, int sumType, int ksize, int anchor = -1);
\r
833 //! returns vertical 1D box filter
\r
834 //! supports only CV_8UC1 sum type and CV_32FC1 dst type
\r
835 CV_EXPORTS Ptr<BaseColumnFilter_GPU> getColumnSumFilter_GPU(int sumType, int dstType, int ksize, int anchor = -1);
\r
837 //! returns 2D box filter
\r
838 //! supports CV_8UC1 and CV_8UC4 source type, dst type must be the same as source type
\r
839 CV_EXPORTS Ptr<BaseFilter_GPU> getBoxFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1, -1));
\r
841 //! returns box filter engine
\r
842 CV_EXPORTS Ptr<FilterEngine_GPU> createBoxFilter_GPU(int srcType, int dstType, const Size& ksize,
\r
843 const Point& anchor = Point(-1,-1));
\r
845 //! returns 2D morphological filter
\r
846 //! only MORPH_ERODE and MORPH_DILATE are supported
\r
847 //! supports CV_8UC1 and CV_8UC4 types
\r
848 //! kernel must have CV_8UC1 type, one rows and cols == ksize.width * ksize.height
\r
849 CV_EXPORTS Ptr<BaseFilter_GPU> getMorphologyFilter_GPU(int op, int type, const Mat& kernel, const Size& ksize,
\r
850 Point anchor=Point(-1,-1));
\r
852 //! returns morphological filter engine. Only MORPH_ERODE and MORPH_DILATE are supported.
\r
853 CV_EXPORTS Ptr<FilterEngine_GPU> createMorphologyFilter_GPU(int op, int type, const Mat& kernel,
\r
854 const Point& anchor = Point(-1,-1), int iterations = 1);
\r
856 //! returns 2D filter with the specified kernel
\r
857 //! supports CV_8UC1 and CV_8UC4 types
\r
858 CV_EXPORTS Ptr<BaseFilter_GPU> getLinearFilter_GPU(int srcType, int dstType, const Mat& kernel, const Size& ksize,
\r
859 Point anchor = Point(-1, -1));
\r
861 //! returns the non-separable linear filter engine
\r
862 CV_EXPORTS Ptr<FilterEngine_GPU> createLinearFilter_GPU(int srcType, int dstType, const Mat& kernel,
\r
863 const Point& anchor = Point(-1,-1));
\r
865 //! returns the primitive row filter with the specified kernel.
\r
866 //! supports only CV_8UC1, CV_8UC4, CV_16SC1, CV_16SC2, CV_32SC1, CV_32FC1 source type.
\r
867 //! there are two version of algorithm: NPP and OpenCV.
\r
868 //! NPP calls when srcType == CV_8UC1 or srcType == CV_8UC4 and bufType == srcType,
\r
869 //! otherwise calls OpenCV version.
\r
870 //! NPP supports only BORDER_CONSTANT border type.
\r
871 //! OpenCV version supports only CV_32F as buffer depth and
\r
872 //! BORDER_REFLECT101, BORDER_REPLICATE and BORDER_CONSTANT border types.
\r
873 CV_EXPORTS Ptr<BaseRowFilter_GPU> getLinearRowFilter_GPU(int srcType, int bufType, const Mat& rowKernel,
\r
874 int anchor = -1, int borderType = BORDER_CONSTANT);
\r
876 //! returns the primitive column filter with the specified kernel.
\r
877 //! supports only CV_8UC1, CV_8UC4, CV_16SC1, CV_16SC2, CV_32SC1, CV_32FC1 dst type.
\r
878 //! there are two version of algorithm: NPP and OpenCV.
\r
879 //! NPP calls when dstType == CV_8UC1 or dstType == CV_8UC4 and bufType == dstType,
\r
880 //! otherwise calls OpenCV version.
\r
881 //! NPP supports only BORDER_CONSTANT border type.
\r
882 //! OpenCV version supports only CV_32F as buffer depth and
\r
883 //! BORDER_REFLECT101, BORDER_REPLICATE and BORDER_CONSTANT border types.
\r
884 CV_EXPORTS Ptr<BaseColumnFilter_GPU> getLinearColumnFilter_GPU(int bufType, int dstType, const Mat& columnKernel,
\r
885 int anchor = -1, int borderType = BORDER_CONSTANT);
\r
887 //! returns the separable linear filter engine
\r
888 CV_EXPORTS Ptr<FilterEngine_GPU> createSeparableLinearFilter_GPU(int srcType, int dstType, const Mat& rowKernel,
\r
889 const Mat& columnKernel, const Point& anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT,
\r
890 int columnBorderType = -1);
\r
892 //! returns filter engine for the generalized Sobel operator
\r
893 CV_EXPORTS Ptr<FilterEngine_GPU> createDerivFilter_GPU(int srcType, int dstType, int dx, int dy, int ksize,
\r
894 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
896 //! returns the Gaussian filter engine
\r
897 CV_EXPORTS Ptr<FilterEngine_GPU> createGaussianFilter_GPU(int type, Size ksize, double sigma1, double sigma2 = 0,
\r
898 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
900 //! returns maximum filter
\r
901 CV_EXPORTS Ptr<BaseFilter_GPU> getMaxFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1,-1));
\r
903 //! returns minimum filter
\r
904 CV_EXPORTS Ptr<BaseFilter_GPU> getMinFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1,-1));
\r
906 //! smooths the image using the normalized box filter
\r
907 //! supports CV_8UC1, CV_8UC4 types
\r
908 CV_EXPORTS void boxFilter(const GpuMat& src, GpuMat& dst, int ddepth, Size ksize, Point anchor = Point(-1,-1));
\r
910 //! a synonym for normalized box filter
\r
911 static inline void blur(const GpuMat& src, GpuMat& dst, Size ksize, Point anchor = Point(-1,-1)) { boxFilter(src, dst, -1, ksize, anchor); }
\r
913 //! erodes the image (applies the local minimum operator)
\r
914 CV_EXPORTS void erode( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1);
\r
916 //! dilates the image (applies the local maximum operator)
\r
917 CV_EXPORTS void dilate( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1);
\r
919 //! applies an advanced morphological operation to the image
\r
920 CV_EXPORTS void morphologyEx( const GpuMat& src, GpuMat& dst, int op, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1);
\r
922 //! applies non-separable 2D linear filter to the image
\r
923 CV_EXPORTS void filter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernel, Point anchor=Point(-1,-1));
\r
925 //! applies separable 2D linear filter to the image
\r
926 CV_EXPORTS void sepFilter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernelX, const Mat& kernelY,
\r
927 Point anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
929 //! applies generalized Sobel operator to the image
\r
930 CV_EXPORTS void Sobel(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, int ksize = 3, double scale = 1,
\r
931 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
933 //! applies the vertical or horizontal Scharr operator to the image
\r
934 CV_EXPORTS void Scharr(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, double scale = 1,
\r
935 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
937 //! smooths the image using Gaussian filter.
\r
938 CV_EXPORTS void GaussianBlur(const GpuMat& src, GpuMat& dst, Size ksize, double sigma1, double sigma2 = 0,
\r
939 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
941 //! applies Laplacian operator to the image
\r
942 //! supports only ksize = 1 and ksize = 3
\r
943 CV_EXPORTS void Laplacian(const GpuMat& src, GpuMat& dst, int ddepth, int ksize = 1, double scale = 1);
\r
945 //////////////////////////////// Image Labeling ////////////////////////////////
\r
947 //!performs labeling via graph cuts
\r
948 CV_EXPORTS void graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTransp, GpuMat& top, GpuMat& bottom, GpuMat& labels, GpuMat& buf);
\r
950 ////////////////////////////////// Histograms //////////////////////////////////
\r
952 //! Compute levels with even distribution. levels will have 1 row and nLevels cols and CV_32SC1 type.
\r
953 CV_EXPORTS void evenLevels(GpuMat& levels, int nLevels, int lowerLevel, int upperLevel);
\r
954 //! Calculates histogram with evenly distributed bins for signle channel source.
\r
955 //! Supports CV_8UC1, CV_16UC1 and CV_16SC1 source types.
\r
956 //! Output hist will have one row and histSize cols and CV_32SC1 type.
\r
957 CV_EXPORTS void histEven(const GpuMat& src, GpuMat& hist, int histSize, int lowerLevel, int upperLevel);
\r
958 //! Calculates histogram with evenly distributed bins for four-channel source.
\r
959 //! All channels of source are processed separately.
\r
960 //! Supports CV_8UC4, CV_16UC4 and CV_16SC4 source types.
\r
961 //! Output hist[i] will have one row and histSize[i] cols and CV_32SC1 type.
\r
962 CV_EXPORTS void histEven(const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4]);
\r
963 //! Calculates histogram with bins determined by levels array.
\r
964 //! levels must have one row and CV_32SC1 type if source has integer type or CV_32FC1 otherwise.
\r
965 //! Supports CV_8UC1, CV_16UC1, CV_16SC1 and CV_32FC1 source types.
\r
966 //! Output hist will have one row and (levels.cols-1) cols and CV_32SC1 type.
\r
967 CV_EXPORTS void histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels);
\r
968 //! Calculates histogram with bins determined by levels array.
\r
969 //! All levels must have one row and CV_32SC1 type if source has integer type or CV_32FC1 otherwise.
\r
970 //! All channels of source are processed separately.
\r
971 //! Supports CV_8UC4, CV_16UC4, CV_16SC4 and CV_32FC4 source types.
\r
972 //! Output hist[i] will have one row and (levels[i].cols-1) cols and CV_32SC1 type.
\r
973 CV_EXPORTS void histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4]);
\r
975 //////////////////////////////// StereoBM_GPU ////////////////////////////////
\r
977 class CV_EXPORTS StereoBM_GPU
\r
980 enum { BASIC_PRESET = 0, PREFILTER_XSOBEL = 1 };
\r
982 enum { DEFAULT_NDISP = 64, DEFAULT_WINSZ = 19 };
\r
984 //! the default constructor
\r
986 //! the full constructor taking the camera-specific preset, number of disparities and the SAD window size. ndisparities must be multiple of 8.
\r
987 StereoBM_GPU(int preset, int ndisparities = DEFAULT_NDISP, int winSize = DEFAULT_WINSZ);
\r
989 //! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair
\r
990 //! Output disparity has CV_8U type.
\r
991 void operator() ( const GpuMat& left, const GpuMat& right, GpuMat& disparity);
\r
994 void operator() ( const GpuMat& left, const GpuMat& right, GpuMat& disparity, const Stream & stream);
\r
996 //! Some heuristics that tries to estmate
\r
997 // if current GPU will be faster then CPU in this algorithm.
\r
998 // It queries current active device.
\r
999 static bool checkIfGpuCallReasonable();
\r
1005 // If avergeTexThreshold == 0 => post procesing is disabled
\r
1006 // If avergeTexThreshold != 0 then disparity is set 0 in each point (x,y) where for left image
\r
1007 // SumOfHorizontalGradiensInWindow(x, y, winSize) < (winSize * winSize) * avergeTexThreshold
\r
1008 // i.e. input left image is low textured.
\r
1009 float avergeTexThreshold;
\r
1011 GpuMat minSSD, leBuf, riBuf;
\r
1014 ////////////////////////// StereoBeliefPropagation ///////////////////////////
\r
1015 // "Efficient Belief Propagation for Early Vision"
\r
1018 class CV_EXPORTS StereoBeliefPropagation
\r
1021 enum { DEFAULT_NDISP = 64 };
\r
1022 enum { DEFAULT_ITERS = 5 };
\r
1023 enum { DEFAULT_LEVELS = 5 };
\r
1025 static void estimateRecommendedParams(int width, int height, int& ndisp, int& iters, int& levels);
\r
1027 //! the default constructor
\r
1028 explicit StereoBeliefPropagation(int ndisp = DEFAULT_NDISP,
\r
1029 int iters = DEFAULT_ITERS,
\r
1030 int levels = DEFAULT_LEVELS,
\r
1031 int msg_type = CV_32F);
\r
1033 //! the full constructor taking the number of disparities, number of BP iterations on each level,
\r
1034 //! number of levels, truncation of data cost, data weight,
\r
1035 //! truncation of discontinuity cost and discontinuity single jump
\r
1036 //! DataTerm = data_weight * min(fabs(I2-I1), max_data_term)
\r
1037 //! DiscTerm = min(disc_single_jump * fabs(f1-f2), max_disc_term)
\r
1038 //! please see paper for more details
\r
1039 StereoBeliefPropagation(int ndisp, int iters, int levels,
\r
1040 float max_data_term, float data_weight,
\r
1041 float max_disc_term, float disc_single_jump,
\r
1042 int msg_type = CV_32F);
\r
1044 //! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair,
\r
1045 //! if disparity is empty output type will be CV_16S else output type will be disparity.type().
\r
1046 void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity);
\r
1049 void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream);
\r
1052 //! version for user specified data term
\r
1053 void operator()(const GpuMat& data, GpuMat& disparity);
\r
1054 void operator()(const GpuMat& data, GpuMat& disparity, Stream& stream);
\r
1061 float max_data_term;
\r
1062 float data_weight;
\r
1063 float max_disc_term;
\r
1064 float disc_single_jump;
\r
1068 GpuMat u, d, l, r, u2, d2, l2, r2;
\r
1069 std::vector<GpuMat> datas;
\r
1073 /////////////////////////// StereoConstantSpaceBP ///////////////////////////
\r
1074 // "A Constant-Space Belief Propagation Algorithm for Stereo Matching"
\r
1075 // Qingxiong Yang, Liang Wang
\86, Narendra Ahuja
\r
1076 // http://vision.ai.uiuc.edu/~qyang6/
\r
1078 class CV_EXPORTS StereoConstantSpaceBP
\r
1081 enum { DEFAULT_NDISP = 128 };
\r
1082 enum { DEFAULT_ITERS = 8 };
\r
1083 enum { DEFAULT_LEVELS = 4 };
\r
1084 enum { DEFAULT_NR_PLANE = 4 };
\r
1086 static void estimateRecommendedParams(int width, int height, int& ndisp, int& iters, int& levels, int& nr_plane);
\r
1088 //! the default constructor
\r
1089 explicit StereoConstantSpaceBP(int ndisp = DEFAULT_NDISP,
\r
1090 int iters = DEFAULT_ITERS,
\r
1091 int levels = DEFAULT_LEVELS,
\r
1092 int nr_plane = DEFAULT_NR_PLANE,
\r
1093 int msg_type = CV_32F);
\r
1095 //! the full constructor taking the number of disparities, number of BP iterations on each level,
\r
1096 //! number of levels, number of active disparity on the first level, truncation of data cost, data weight,
\r
1097 //! truncation of discontinuity cost, discontinuity single jump and minimum disparity threshold
\r
1098 StereoConstantSpaceBP(int ndisp, int iters, int levels, int nr_plane,
\r
1099 float max_data_term, float data_weight, float max_disc_term, float disc_single_jump,
\r
1100 int min_disp_th = 0,
\r
1101 int msg_type = CV_32F);
\r
1103 //! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair,
\r
1104 //! if disparity is empty output type will be CV_16S else output type will be disparity.type().
\r
1105 void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity);
\r
1108 void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream);
\r
1117 float max_data_term;
\r
1118 float data_weight;
\r
1119 float max_disc_term;
\r
1120 float disc_single_jump;
\r
1126 bool use_local_init_data_cost;
\r
1128 GpuMat u[2], d[2], l[2], r[2];
\r
1129 GpuMat disp_selected_pyr[2];
\r
1132 GpuMat data_cost_selected;
\r
1139 /////////////////////////// DisparityBilateralFilter ///////////////////////////
\r
1140 // Disparity map refinement using joint bilateral filtering given a single color image.
\r
1141 // Qingxiong Yang, Liang Wang
\86, Narendra Ahuja
\r
1142 // http://vision.ai.uiuc.edu/~qyang6/
\r
1144 class CV_EXPORTS DisparityBilateralFilter
\r
1147 enum { DEFAULT_NDISP = 64 };
\r
1148 enum { DEFAULT_RADIUS = 3 };
\r
1149 enum { DEFAULT_ITERS = 1 };
\r
1151 //! the default constructor
\r
1152 explicit DisparityBilateralFilter(int ndisp = DEFAULT_NDISP, int radius = DEFAULT_RADIUS, int iters = DEFAULT_ITERS);
\r
1154 //! the full constructor taking the number of disparities, filter radius,
\r
1155 //! number of iterations, truncation of data continuity, truncation of disparity continuity
\r
1156 //! and filter range sigma
\r
1157 DisparityBilateralFilter(int ndisp, int radius, int iters, float edge_threshold, float max_disc_threshold, float sigma_range);
\r
1159 //! the disparity map refinement operator. Refine disparity map using joint bilateral filtering given a single color image.
\r
1160 //! disparity must have CV_8U or CV_16S type, image must have CV_8UC1 or CV_8UC3 type.
\r
1161 void operator()(const GpuMat& disparity, const GpuMat& image, GpuMat& dst);
\r
1164 void operator()(const GpuMat& disparity, const GpuMat& image, GpuMat& dst, Stream& stream);
\r
1171 float edge_threshold;
\r
1172 float max_disc_threshold;
\r
1173 float sigma_range;
\r
1175 GpuMat table_color;
\r
1176 GpuMat table_space;
\r
1180 //////////////// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector //////////////
\r
1182 struct CV_EXPORTS HOGDescriptor
\r
1184 enum { DEFAULT_WIN_SIGMA = -1 };
\r
1185 enum { DEFAULT_NLEVELS = 64 };
\r
1186 enum { DESCR_FORMAT_ROW_BY_ROW, DESCR_FORMAT_COL_BY_COL };
\r
1188 HOGDescriptor(Size win_size=Size(64, 128), Size block_size=Size(16, 16),
\r
1189 Size block_stride=Size(8, 8), Size cell_size=Size(8, 8),
\r
1190 int nbins=9, double win_sigma=DEFAULT_WIN_SIGMA,
\r
1191 double threshold_L2hys=0.2, bool gamma_correction=true,
\r
1192 int nlevels=DEFAULT_NLEVELS);
\r
1194 size_t getDescriptorSize() const;
\r
1195 size_t getBlockHistogramSize() const;
\r
1197 void setSVMDetector(const vector<float>& detector);
\r
1199 static vector<float> getDefaultPeopleDetector();
\r
1200 static vector<float> getPeopleDetector48x96();
\r
1201 static vector<float> getPeopleDetector64x128();
\r
1203 void detect(const GpuMat& img, vector<Point>& found_locations,
\r
1204 double hit_threshold=0, Size win_stride=Size(),
\r
1205 Size padding=Size());
\r
1207 void detectMultiScale(const GpuMat& img, vector<Rect>& found_locations,
\r
1208 double hit_threshold=0, Size win_stride=Size(),
\r
1209 Size padding=Size(), double scale0=1.05,
\r
1210 int group_threshold=2);
\r
1212 void getDescriptors(const GpuMat& img, Size win_stride,
\r
1213 GpuMat& descriptors,
\r
1214 int descr_format=DESCR_FORMAT_COL_BY_COL);
\r
1218 Size block_stride;
\r
1222 double threshold_L2hys;
\r
1223 bool gamma_correction;
\r
1227 void computeBlockHistograms(const GpuMat& img);
\r
1228 void computeGradient(const GpuMat& img, GpuMat& grad, GpuMat& qangle);
\r
1230 double getWinSigma() const;
\r
1231 bool checkDetectorSize() const;
\r
1233 static int numPartsWithin(int size, int part_size, int stride);
\r
1234 static Size numPartsWithin(Size size, Size part_size, Size stride);
\r
1236 // Coefficients of the separating plane
\r
1240 // Results of the last classification step
\r
1244 // Results of the last histogram evaluation step
\r
1245 GpuMat block_hists;
\r
1247 // Gradients conputation results
\r
1248 GpuMat grad, qangle;
\r
1252 ////////////////////////////////// BruteForceMatcher //////////////////////////////////
\r
1254 class CV_EXPORTS BruteForceMatcher_GPU_base
\r
1257 enum DistType {L1Dist = 0, L2Dist};
\r
1259 explicit BruteForceMatcher_GPU_base(DistType distType = L2Dist);
\r
1261 // Add descriptors to train descriptor collection.
\r
1262 void add(const std::vector<GpuMat>& descCollection);
\r
1264 // Get train descriptors collection.
\r
1265 const std::vector<GpuMat>& getTrainDescriptors() const;
\r
1267 // Clear train descriptors collection.
\r
1270 // Return true if there are not train descriptors in collection.
\r
1271 bool empty() const;
\r
1273 // Return true if the matcher supports mask in match methods.
\r
1274 bool isMaskSupported() const;
\r
1276 // Find one best match for each query descriptor.
\r
1277 // trainIdx.at<int>(0, queryIdx) will contain best train index for queryIdx
\r
1278 // distance.at<float>(0, queryIdx) will contain distance
\r
1279 void matchSingle(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1280 GpuMat& trainIdx, GpuMat& distance,
\r
1281 const GpuMat& mask = GpuMat());
\r
1283 // Download trainIdx and distance to CPU vector with DMatch
\r
1284 static void matchDownload(const GpuMat& trainIdx, const GpuMat& distance, std::vector<DMatch>& matches);
\r
1286 // Find one best match for each query descriptor.
\r
1287 void match(const GpuMat& queryDescs, const GpuMat& trainDescs, std::vector<DMatch>& matches,
\r
1288 const GpuMat& mask = GpuMat());
\r
1290 // Make gpu collection of trains and masks in suitable format for matchCollection function
\r
1291 void makeGpuCollection(GpuMat& trainCollection, GpuMat& maskCollection,
\r
1292 const vector<GpuMat>& masks = std::vector<GpuMat>());
\r
1294 // Find one best match from train collection for each query descriptor.
\r
1295 // trainIdx.at<int>(0, queryIdx) will contain best train index for queryIdx
\r
1296 // imgIdx.at<int>(0, queryIdx) will contain best image index for queryIdx
\r
1297 // distance.at<float>(0, queryIdx) will contain distance
\r
1298 void matchCollection(const GpuMat& queryDescs, const GpuMat& trainCollection,
\r
1299 GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance,
\r
1300 const GpuMat& maskCollection);
\r
1302 // Download trainIdx, imgIdx and distance to CPU vector with DMatch
\r
1303 static void matchDownload(const GpuMat& trainIdx, GpuMat& imgIdx, const GpuMat& distance,
\r
1304 std::vector<DMatch>& matches);
\r
1306 // Find one best match from train collection for each query descriptor.
\r
1307 void match(const GpuMat& queryDescs, std::vector<DMatch>& matches,
\r
1308 const std::vector<GpuMat>& masks = std::vector<GpuMat>());
\r
1310 // Find k best matches for each query descriptor (in increasing order of distances).
\r
1311 // trainIdx.at<int>(queryIdx, i) will contain index of i'th best trains (i < k).
\r
1312 // distance.at<float>(queryIdx, i) will contain distance.
\r
1313 // allDist is a buffer to store all distance between query descriptors and train descriptors
\r
1314 // it have size (nQuery,nTrain) and CV_32F type
\r
1315 // allDist.at<float>(queryIdx, trainIdx) will contain FLT_MAX, if trainIdx is one from k best,
\r
1316 // otherwise it will contain distance between queryIdx and trainIdx descriptors
\r
1317 void knnMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1318 GpuMat& trainIdx, GpuMat& distance, GpuMat& allDist, int k, const GpuMat& mask = GpuMat());
\r
1320 // Download trainIdx and distance to CPU vector with DMatch
\r
1321 // compactResult is used when mask is not empty. If compactResult is false matches
\r
1322 // vector will have the same size as queryDescriptors rows. If compactResult is true
\r
1323 // matches vector will not contain matches for fully masked out query descriptors.
\r
1324 static void knnMatchDownload(const GpuMat& trainIdx, const GpuMat& distance,
\r
1325 std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
\r
1327 // Find k best matches for each query descriptor (in increasing order of distances).
\r
1328 // compactResult is used when mask is not empty. If compactResult is false matches
\r
1329 // vector will have the same size as queryDescriptors rows. If compactResult is true
\r
1330 // matches vector will not contain matches for fully masked out query descriptors.
\r
1331 void knnMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1332 std::vector< std::vector<DMatch> >& matches, int k, const GpuMat& mask = GpuMat(),
\r
1333 bool compactResult = false);
\r
1335 // Find k best matches for each query descriptor (in increasing order of distances).
\r
1336 // compactResult is used when mask is not empty. If compactResult is false matches
\r
1337 // vector will have the same size as queryDescriptors rows. If compactResult is true
\r
1338 // matches vector will not contain matches for fully masked out query descriptors.
\r
1339 void knnMatch(const GpuMat& queryDescs, std::vector< std::vector<DMatch> >& matches, int knn,
\r
1340 const std::vector<GpuMat>& masks = std::vector<GpuMat>(), bool compactResult = false );
\r
1342 // Find best matches for each query descriptor which have distance less than maxDistance.
\r
1343 // nMatches.at<unsigned int>(0, queruIdx) will contain matches count for queryIdx.
\r
1344 // carefully nMatches can be greater than trainIdx.cols - it means that matcher didn't find all matches,
\r
1345 // because it didn't have enough memory.
\r
1346 // trainIdx.at<int>(queruIdx, i) will contain ith train index (i < min(nMatches.at<unsigned int>(0, queruIdx), trainIdx.cols))
\r
1347 // distance.at<int>(queruIdx, i) will contain ith distance (i < min(nMatches.at<unsigned int>(0, queruIdx), trainIdx.cols))
\r
1348 // If trainIdx is empty, then trainIdx and distance will be created with size nQuery x nTrain,
\r
1349 // otherwize user can pass own allocated trainIdx and distance with size nQuery x nMaxMatches
\r
1350 // Matches doesn't sorted.
\r
1351 void radiusMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1352 GpuMat& trainIdx, GpuMat& nMatches, GpuMat& distance, float maxDistance,
\r
1353 const GpuMat& mask = GpuMat());
\r
1355 // Download trainIdx, nMatches and distance to CPU vector with DMatch.
\r
1356 // matches will be sorted in increasing order of distances.
\r
1357 // compactResult is used when mask is not empty. If compactResult is false matches
\r
1358 // vector will have the same size as queryDescriptors rows. If compactResult is true
\r
1359 // matches vector will not contain matches for fully masked out query descriptors.
\r
1360 static void radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& nMatches, const GpuMat& distance,
\r
1361 std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
\r
1363 // Find best matches for each query descriptor which have distance less than maxDistance
\r
1364 // in increasing order of distances).
\r
1365 void radiusMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1366 std::vector< std::vector<DMatch> >& matches, float maxDistance,
\r
1367 const GpuMat& mask = GpuMat(), bool compactResult = false);
\r
1369 // Find best matches from train collection for each query descriptor which have distance less than
\r
1370 // maxDistance (in increasing order of distances).
\r
1371 void radiusMatch(const GpuMat& queryDescs, std::vector< std::vector<DMatch> >& matches, float maxDistance,
\r
1372 const std::vector<GpuMat>& masks = std::vector<GpuMat>(), bool compactResult = false);
\r
1375 DistType distType;
\r
1377 std::vector<GpuMat> trainDescCollection;
\r
1380 template <class Distance>
\r
1381 class CV_EXPORTS BruteForceMatcher_GPU;
\r
1383 template <typename T>
\r
1384 class CV_EXPORTS BruteForceMatcher_GPU< L1<T> > : public BruteForceMatcher_GPU_base
\r
1387 explicit BruteForceMatcher_GPU() : BruteForceMatcher_GPU_base(L1Dist) {}
\r
1388 explicit BruteForceMatcher_GPU(L1<T> /*d*/) : BruteForceMatcher_GPU_base(L1Dist) {}
\r
1390 template <typename T>
\r
1391 class CV_EXPORTS BruteForceMatcher_GPU< L2<T> > : public BruteForceMatcher_GPU_base
\r
1394 explicit BruteForceMatcher_GPU() : BruteForceMatcher_GPU_base(L2Dist) {}
\r
1395 explicit BruteForceMatcher_GPU(L2<T> /*d*/) : BruteForceMatcher_GPU_base(L2Dist) {}
\r
1398 ////////////////////////////////// CascadeClassifier_GPU //////////////////////////////////////////
\r
1399 // The cascade classifier class for object detection.
\r
1400 class CV_EXPORTS CascadeClassifier_GPU
\r
1403 CascadeClassifier_GPU();
\r
1404 CascadeClassifier_GPU(const string& filename);
\r
1405 ~CascadeClassifier_GPU();
\r
1407 bool empty() const;
\r
1408 bool load(const string& filename);
\r
1411 /* returns number of detected objects */
\r
1412 int detectMultiScale( const GpuMat& image, GpuMat& objectsBuf, double scaleFactor=1.2, int minNeighbors=4, Size minSize=Size());
\r
1414 bool findLargestObject;
\r
1415 bool visualizeInPlace;
\r
1417 Size getClassifierSize() const;
\r
1420 struct CascadeClassifierImpl;
\r
1421 CascadeClassifierImpl* impl;
\r
1424 ////////////////////////////////// SURF //////////////////////////////////////////
\r
1426 struct CV_EXPORTS SURFParams_GPU
\r
1428 SURFParams_GPU() : threshold(0.1f), nOctaves(4), nIntervals(4), initialScale(2.f),
\r
1429 l1(3.f/1.5f), l2(5.f/1.5f), l3(3.f/1.5f), l4(1.f/1.5f),
\r
1430 edgeScale(0.81f), initialStep(1), extended(true), featuresRatio(0.01f) {}
\r
1432 //! The interest operator threshold
\r
1434 //! The number of octaves to process
\r
1436 //! The number of intervals in each octave
\r
1438 //! The scale associated with the first interval of the first octave
\r
1439 float initialScale;
\r
1441 //! mask parameter l_1
\r
1443 //! mask parameter l_2
\r
1445 //! mask parameter l_3
\r
1447 //! mask parameter l_4
\r
1449 //! The amount to scale the edge rejection mask
\r
1451 //! The initial sampling step in pixels.
\r
1454 //! True, if generate 128-len descriptors, false - 64-len descriptors
\r
1457 //! max features = featuresRatio * img.size().srea()
\r
1458 float featuresRatio;
\r
1461 class CV_EXPORTS SURF_GPU : public SURFParams_GPU
\r
1464 //! returns the descriptor size in float's (64 or 128)
\r
1465 int descriptorSize() const;
\r
1467 //! upload host keypoints to device memory
\r
1468 static void uploadKeypoints(const vector<KeyPoint>& keypoints, GpuMat& keypointsGPU);
\r
1469 //! download keypoints from device to host memory
\r
1470 static void downloadKeypoints(const GpuMat& keypointsGPU, vector<KeyPoint>& keypoints);
\r
1472 //! download descriptors from device to host memory
\r
1473 static void downloadDescriptors(const GpuMat& descriptorsGPU, vector<float>& descriptors);
\r
1475 //! finds the keypoints using fast hessian detector used in SURF
\r
1476 //! supports CV_8UC1 images
\r
1477 //! keypoints will have 1 row and type CV_32FC(6)
\r
1478 //! keypoints.at<float[6]>(1, i) contains i'th keypoint
\r
1479 //! format: (x, y, size, response, angle, octave)
\r
1480 void operator()(const GpuMat& img, const GpuMat& mask, GpuMat& keypoints);
\r
1481 //! finds the keypoints and computes their descriptors.
\r
1482 //! Optionally it can compute descriptors for the user-provided keypoints and recompute keypoints direction
\r
1483 void operator()(const GpuMat& img, const GpuMat& mask, GpuMat& keypoints, GpuMat& descriptors,
\r
1484 bool useProvidedKeypoints = false, bool calcOrientation = true);
\r
1486 void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints);
\r
1487 void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, GpuMat& descriptors,
\r
1488 bool useProvidedKeypoints = false, bool calcOrientation = true);
\r
1490 void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, std::vector<float>& descriptors,
\r
1491 bool useProvidedKeypoints = false, bool calcOrientation = true);
\r
1499 GpuMat hessianBuffer;
\r
1500 GpuMat maxPosBuffer;
\r
1501 GpuMat featuresBuffer;
\r
1506 //! Speckle filtering - filters small connected components on diparity image.
\r
1507 //! It sets pixel (x,y) to newVal if it coresponds to small CC with size < maxSpeckleSize.
\r
1508 //! Threshold for border between CC is diffThreshold;
\r
1509 CV_EXPORTS void filterSpeckles( Mat& img, uchar newVal, int maxSpeckleSize, uchar diffThreshold, Mat& buf);
\r
1512 #include "opencv2/gpu/matrix_operations.hpp"
\r
1514 #endif /* __OPENCV_GPU_HPP__ */
\r