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 template <unsigned int cmp_op>
\r
76 CV_EXPORTS bool checkPtxVersion(int major, int minor);
\r
78 //! Checks if the GPU module is PTX compatible with the given NVIDIA device
\r
79 CV_EXPORTS bool isCompatibleWith(int device);
\r
81 //////////////////////////////// Error handling ////////////////////////
\r
83 CV_EXPORTS void error(const char *error_string, const char *file, const int line, const char *func);
\r
84 CV_EXPORTS void nppError( int err, const char *file, const int line, const char *func);
\r
86 //////////////////////////////// GpuMat ////////////////////////////////
\r
90 //! Smart pointer for GPU memory with reference counting. Its interface is mostly similar with cv::Mat.
\r
91 class CV_EXPORTS GpuMat
\r
94 //! default constructor
\r
96 //! constructs GpuMatrix of the specified size and type (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.)
\r
97 GpuMat(int rows, int cols, int type);
\r
98 GpuMat(Size size, int type);
\r
99 //! constucts GpuMatrix and fills it with the specified value _s.
\r
100 GpuMat(int rows, int cols, int type, const Scalar& s);
\r
101 GpuMat(Size size, int type, const Scalar& s);
\r
102 //! copy constructor
\r
103 GpuMat(const GpuMat& m);
\r
105 //! constructor for GpuMatrix headers pointing to user-allocated data
\r
106 GpuMat(int rows, int cols, int type, void* data, size_t step = Mat::AUTO_STEP);
\r
107 GpuMat(Size size, int type, void* data, size_t step = Mat::AUTO_STEP);
\r
109 //! creates a matrix header for a part of the bigger matrix
\r
110 GpuMat(const GpuMat& m, const Range& rowRange, const Range& colRange);
\r
111 GpuMat(const GpuMat& m, const Rect& roi);
\r
113 //! builds GpuMat from Mat. Perfom blocking upload to device.
\r
114 explicit GpuMat (const Mat& m);
\r
116 //! destructor - calls release()
\r
119 //! assignment operators
\r
120 GpuMat& operator = (const GpuMat& m);
\r
121 //! assignment operator. Perfom blocking upload to device.
\r
122 GpuMat& operator = (const Mat& m);
\r
124 //! returns lightweight DevMem2D_ structure for passing to nvcc-compiled code.
\r
125 // Contains just image size, data ptr and step.
\r
126 template <class T> operator DevMem2D_<T>() const;
\r
127 template <class T> operator PtrStep_<T>() const;
\r
129 //! pefroms blocking upload data to GpuMat.
\r
130 void upload(const cv::Mat& m);
\r
133 void upload(const CudaMem& m, Stream& stream);
\r
135 //! downloads data from device to host memory. Blocking calls.
\r
136 operator Mat() const;
\r
137 void download(cv::Mat& m) const;
\r
140 void download(CudaMem& m, Stream& stream) const;
\r
142 //! returns a new GpuMatrix header for the specified row
\r
143 GpuMat row(int y) const;
\r
144 //! returns a new GpuMatrix header for the specified column
\r
145 GpuMat col(int x) const;
\r
146 //! ... for the specified row span
\r
147 GpuMat rowRange(int startrow, int endrow) const;
\r
148 GpuMat rowRange(const Range& r) const;
\r
149 //! ... for the specified column span
\r
150 GpuMat colRange(int startcol, int endcol) const;
\r
151 GpuMat colRange(const Range& r) const;
\r
153 //! returns deep copy of the GpuMatrix, i.e. the data is copied
\r
154 GpuMat clone() const;
\r
155 //! copies the GpuMatrix content to "m".
\r
156 // It calls m.create(this->size(), this->type()).
\r
157 void copyTo( GpuMat& m ) const;
\r
158 //! copies those GpuMatrix elements to "m" that are marked with non-zero mask elements.
\r
159 void copyTo( GpuMat& m, const GpuMat& mask ) const;
\r
160 //! converts GpuMatrix to another datatype with optional scalng. See cvConvertScale.
\r
161 void convertTo( GpuMat& m, int rtype, double alpha=1, double beta=0 ) const;
\r
163 void assignTo( GpuMat& m, int type=-1 ) const;
\r
165 //! sets every GpuMatrix element to s
\r
166 GpuMat& operator = (const Scalar& s);
\r
167 //! sets some of the GpuMatrix elements to s, according to the mask
\r
168 GpuMat& setTo(const Scalar& s, const GpuMat& mask = GpuMat());
\r
169 //! creates alternative GpuMatrix header for the same data, with different
\r
170 // number of channels and/or different number of rows. see cvReshape.
\r
171 GpuMat reshape(int cn, int rows = 0) const;
\r
173 //! allocates new GpuMatrix data unless the GpuMatrix already has specified size and type.
\r
174 // previous data is unreferenced if needed.
\r
175 void create(int rows, int cols, int type);
\r
176 void create(Size size, int type);
\r
177 //! decreases reference counter;
\r
178 // deallocate the data when reference counter reaches 0.
\r
181 //! swaps with other smart pointer
\r
182 void swap(GpuMat& mat);
\r
184 //! locates GpuMatrix header within a parent GpuMatrix. See below
\r
185 void locateROI( Size& wholeSize, Point& ofs ) const;
\r
186 //! moves/resizes the current GpuMatrix ROI inside the parent GpuMatrix.
\r
187 GpuMat& adjustROI( int dtop, int dbottom, int dleft, int dright );
\r
188 //! extracts a rectangular sub-GpuMatrix
\r
189 // (this is a generalized form of row, rowRange etc.)
\r
190 GpuMat operator()( Range rowRange, Range colRange ) const;
\r
191 GpuMat operator()( const Rect& roi ) const;
\r
193 //! returns true iff the GpuMatrix data is continuous
\r
194 // (i.e. when there are no gaps between successive rows).
\r
195 // similar to CV_IS_GpuMat_CONT(cvGpuMat->type)
\r
196 bool isContinuous() const;
\r
197 //! returns element size in bytes,
\r
198 // similar to CV_ELEM_SIZE(cvMat->type)
\r
199 size_t elemSize() const;
\r
200 //! returns the size of element channel in bytes.
\r
201 size_t elemSize1() const;
\r
202 //! returns element type, similar to CV_MAT_TYPE(cvMat->type)
\r
204 //! returns element type, similar to CV_MAT_DEPTH(cvMat->type)
\r
206 //! returns element type, similar to CV_MAT_CN(cvMat->type)
\r
207 int channels() const;
\r
208 //! returns step/elemSize1()
\r
209 size_t step1() const;
\r
210 //! returns GpuMatrix size:
\r
211 // width == number of columns, height == number of rows
\r
213 //! returns true if GpuMatrix data is NULL
\r
214 bool empty() const;
\r
216 //! returns pointer to y-th row
\r
217 uchar* ptr(int y = 0);
\r
218 const uchar* ptr(int y = 0) const;
\r
220 //! template version of the above method
\r
221 template<typename _Tp> _Tp* ptr(int y = 0);
\r
222 template<typename _Tp> const _Tp* ptr(int y = 0) const;
\r
224 //! matrix transposition
\r
227 /*! includes several bit-fields:
\r
228 - the magic signature
\r
231 - number of channels
\r
234 //! the number of rows and columns
\r
236 //! a distance between successive rows in bytes; includes the gap if any
\r
238 //! pointer to the data
\r
241 //! pointer to the reference counter;
\r
242 // when GpuMatrix points to user-allocated data, the pointer is NULL
\r
245 //! helper fields used in locateROI and adjustROI
\r
250 //#define TemplatedGpuMat // experimental now, deprecated to use
\r
251 #ifdef TemplatedGpuMat
\r
252 #include "GpuMat_BetaDeprecated.hpp"
\r
255 //! Creates continuous GPU matrix
\r
256 CV_EXPORTS void createContinuous(int rows, int cols, int type, GpuMat& m);
\r
258 //! Ensures that size of the given matrix is not less than (rows, cols) size
\r
259 //! and matrix type is match specified one too
\r
260 CV_EXPORTS void ensureSizeIsEnough(int rows, int cols, int type, GpuMat& m);
\r
262 //////////////////////////////// CudaMem ////////////////////////////////
\r
263 // CudaMem is limited cv::Mat with page locked memory allocation.
\r
264 // Page locked memory is only needed for async and faster coping to GPU.
\r
265 // It is convertable to cv::Mat header without reference counting
\r
266 // so you can use it with other opencv functions.
\r
268 class CV_EXPORTS CudaMem
\r
271 enum { ALLOC_PAGE_LOCKED = 1, ALLOC_ZEROCOPY = 2, ALLOC_WRITE_COMBINED = 4 };
\r
274 CudaMem(const CudaMem& m);
\r
276 CudaMem(int rows, int cols, int type, int _alloc_type = ALLOC_PAGE_LOCKED);
\r
277 CudaMem(Size size, int type, int alloc_type = ALLOC_PAGE_LOCKED);
\r
280 //! creates from cv::Mat with coping data
\r
281 explicit CudaMem(const Mat& m, int alloc_type = ALLOC_PAGE_LOCKED);
\r
285 CudaMem& operator = (const CudaMem& m);
\r
287 //! returns deep copy of the matrix, i.e. the data is copied
\r
288 CudaMem clone() const;
\r
290 //! allocates new matrix data unless the matrix already has specified size and type.
\r
291 void create(int rows, int cols, int type, int alloc_type = ALLOC_PAGE_LOCKED);
\r
292 void create(Size size, int type, int alloc_type = ALLOC_PAGE_LOCKED);
\r
294 //! decrements reference counter and released memory if needed.
\r
297 //! returns matrix header with disabled reference counting for CudaMem data.
\r
298 Mat createMatHeader() const;
\r
299 operator Mat() const;
\r
301 //! maps host memory into device address space and returns GpuMat header for it. Throws exception if not supported by hardware.
\r
302 GpuMat createGpuMatHeader() const;
\r
303 operator GpuMat() const;
\r
305 //returns if host memory can be mapperd to gpu address space;
\r
306 static bool canMapHostMemory();
\r
308 // Please see cv::Mat for descriptions
\r
309 bool isContinuous() const;
\r
310 size_t elemSize() const;
\r
311 size_t elemSize1() const;
\r
314 int channels() const;
\r
315 size_t step1() const;
\r
317 bool empty() const;
\r
320 // Please see cv::Mat for descriptions
\r
334 //////////////////////////////// CudaStream ////////////////////////////////
\r
335 // Encapculates Cuda Stream. Provides interface for async coping.
\r
336 // Passed to each function that supports async kernel execution.
\r
337 // Reference counting is enabled
\r
339 class CV_EXPORTS Stream
\r
345 Stream(const Stream&);
\r
346 Stream& operator=(const Stream&);
\r
348 bool queryIfComplete();
\r
349 void waitForCompletion();
\r
351 //! downloads asynchronously.
\r
352 // Warning! cv::Mat must point to page locked memory (i.e. to CudaMem data or to its subMat)
\r
353 void enqueueDownload(const GpuMat& src, CudaMem& dst);
\r
354 void enqueueDownload(const GpuMat& src, Mat& dst);
\r
356 //! uploads asynchronously.
\r
357 // Warning! cv::Mat must point to page locked memory (i.e. to CudaMem data or to its ROI)
\r
358 void enqueueUpload(const CudaMem& src, GpuMat& dst);
\r
359 void enqueueUpload(const Mat& src, GpuMat& dst);
\r
361 void enqueueCopy(const GpuMat& src, GpuMat& dst);
\r
363 void enqueueMemSet(const GpuMat& src, Scalar val);
\r
364 void enqueueMemSet(const GpuMat& src, Scalar val, const GpuMat& mask);
\r
366 // converts matrix type, ex from float to uchar depending on type
\r
367 void enqueueConvert(const GpuMat& src, GpuMat& dst, int type, double a = 1, double b = 0);
\r
373 friend struct StreamAccessor;
\r
377 ////////////////////////////// Arithmetics ///////////////////////////////////
\r
379 //! transposes the matrix
\r
380 //! supports matrix with element size = 1, 4 and 8 bytes (CV_8UC1, CV_8UC4, CV_16UC2, CV_32FC1, etc)
\r
381 CV_EXPORTS void transpose(const GpuMat& src1, GpuMat& dst);
\r
383 //! reverses the order of the rows, columns or both in a matrix
\r
384 //! supports CV_8UC1, CV_8UC4 types
\r
385 CV_EXPORTS void flip(const GpuMat& a, GpuMat& b, int flipCode);
\r
387 //! transforms 8-bit unsigned integers using lookup table: dst(i)=lut(src(i))
\r
388 //! destination array will have the depth type as lut and the same channels number as source
\r
389 //! supports CV_8UC1, CV_8UC3 types
\r
390 CV_EXPORTS void LUT(const GpuMat& src, const Mat& lut, GpuMat& dst);
\r
392 //! makes multi-channel array out of several single-channel arrays
\r
393 CV_EXPORTS void merge(const GpuMat* src, size_t n, GpuMat& dst);
\r
395 //! makes multi-channel array out of several single-channel arrays
\r
396 CV_EXPORTS void merge(const vector<GpuMat>& src, GpuMat& dst);
\r
398 //! makes multi-channel array out of several single-channel arrays (async version)
\r
399 CV_EXPORTS void merge(const GpuMat* src, size_t n, GpuMat& dst, const Stream& stream);
\r
401 //! makes multi-channel array out of several single-channel arrays (async version)
\r
402 CV_EXPORTS void merge(const vector<GpuMat>& src, GpuMat& dst, const Stream& stream);
\r
404 //! copies each plane of a multi-channel array to a dedicated array
\r
405 CV_EXPORTS void split(const GpuMat& src, GpuMat* dst);
\r
407 //! copies each plane of a multi-channel array to a dedicated array
\r
408 CV_EXPORTS void split(const GpuMat& src, vector<GpuMat>& dst);
\r
410 //! copies each plane of a multi-channel array to a dedicated array (async version)
\r
411 CV_EXPORTS void split(const GpuMat& src, GpuMat* dst, const Stream& stream);
\r
413 //! copies each plane of a multi-channel array to a dedicated array (async version)
\r
414 CV_EXPORTS void split(const GpuMat& src, vector<GpuMat>& dst, const Stream& stream);
\r
416 //! computes magnitude of complex (x(i).re, x(i).im) vector
\r
417 //! supports only CV_32FC2 type
\r
418 CV_EXPORTS void magnitude(const GpuMat& x, GpuMat& magnitude);
\r
420 //! computes squared magnitude of complex (x(i).re, x(i).im) vector
\r
421 //! supports only CV_32FC2 type
\r
422 CV_EXPORTS void magnitudeSqr(const GpuMat& x, GpuMat& magnitude);
\r
424 //! computes magnitude of each (x(i), y(i)) vector
\r
425 //! supports only floating-point source
\r
426 CV_EXPORTS void magnitude(const GpuMat& x, const GpuMat& y, GpuMat& magnitude);
\r
428 CV_EXPORTS void magnitude(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, const Stream& stream);
\r
430 //! computes squared magnitude of each (x(i), y(i)) vector
\r
431 //! supports only floating-point source
\r
432 CV_EXPORTS void magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& magnitude);
\r
434 CV_EXPORTS void magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, const Stream& stream);
\r
436 //! computes angle (angle(i)) of each (x(i), y(i)) vector
\r
437 //! supports only floating-point source
\r
438 CV_EXPORTS void phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees = false);
\r
440 CV_EXPORTS void phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees, const Stream& stream);
\r
442 //! converts Cartesian coordinates to polar
\r
443 //! supports only floating-point source
\r
444 CV_EXPORTS void cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, GpuMat& angle, bool angleInDegrees = false);
\r
446 CV_EXPORTS void cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, GpuMat& angle, bool angleInDegrees, const Stream& stream);
\r
448 //! converts polar coordinates to Cartesian
\r
449 //! supports only floating-point source
\r
450 CV_EXPORTS void polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees = false);
\r
452 CV_EXPORTS void polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees, const Stream& stream);
\r
455 //////////////////////////// Per-element operations ////////////////////////////////////
\r
457 //! adds one matrix to another (c = a + b)
\r
458 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
459 CV_EXPORTS void add(const GpuMat& a, const GpuMat& b, GpuMat& c);
\r
460 //! adds scalar to a matrix (c = a + s)
\r
461 //! supports CV_32FC1 and CV_32FC2 type
\r
462 CV_EXPORTS void add(const GpuMat& a, const Scalar& sc, GpuMat& c);
\r
464 //! subtracts one matrix from another (c = a - b)
\r
465 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
466 CV_EXPORTS void subtract(const GpuMat& a, const GpuMat& b, GpuMat& c);
\r
467 //! subtracts scalar from a matrix (c = a - s)
\r
468 //! supports CV_32FC1 and CV_32FC2 type
\r
469 CV_EXPORTS void subtract(const GpuMat& a, const Scalar& sc, GpuMat& c);
\r
471 //! computes element-wise product of the two arrays (c = a * b)
\r
472 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
473 CV_EXPORTS void multiply(const GpuMat& a, const GpuMat& b, GpuMat& c);
\r
474 //! multiplies matrix to a scalar (c = a * s)
\r
475 //! supports CV_32FC1 and CV_32FC2 type
\r
476 CV_EXPORTS void multiply(const GpuMat& a, const Scalar& sc, GpuMat& c);
\r
478 //! computes element-wise quotient of the two arrays (c = a / b)
\r
479 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
480 CV_EXPORTS void divide(const GpuMat& a, const GpuMat& b, GpuMat& c);
\r
481 //! computes element-wise quotient of matrix and scalar (c = a / s)
\r
482 //! supports CV_32FC1 and CV_32FC2 type
\r
483 CV_EXPORTS void divide(const GpuMat& a, const Scalar& sc, GpuMat& c);
\r
485 //! computes exponent of each matrix element (b = e**a)
\r
486 //! supports only CV_32FC1 type
\r
487 CV_EXPORTS void exp(const GpuMat& a, GpuMat& b);
\r
489 //! computes natural logarithm of absolute value of each matrix element: b = log(abs(a))
\r
490 //! supports only CV_32FC1 type
\r
491 CV_EXPORTS void log(const GpuMat& a, GpuMat& b);
\r
493 //! computes element-wise absolute difference of two arrays (c = abs(a - b))
\r
494 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
495 CV_EXPORTS void absdiff(const GpuMat& a, const GpuMat& b, GpuMat& c);
\r
496 //! computes element-wise absolute difference of array and scalar (c = abs(a - s))
\r
497 //! supports only CV_32FC1 type
\r
498 CV_EXPORTS void absdiff(const GpuMat& a, const Scalar& s, GpuMat& c);
\r
500 //! compares elements of two arrays (c = a <cmpop> b)
\r
501 //! supports CV_8UC4, CV_32FC1 types
\r
502 CV_EXPORTS void compare(const GpuMat& a, const GpuMat& b, GpuMat& c, int cmpop);
\r
504 //! performs per-elements bit-wise inversion
\r
505 CV_EXPORTS void bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask=GpuMat());
\r
507 CV_EXPORTS void bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask, const Stream& stream);
\r
509 //! calculates per-element bit-wise disjunction of two arrays
\r
510 CV_EXPORTS void bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat());
\r
512 CV_EXPORTS void bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, const Stream& stream);
\r
514 //! calculates per-element bit-wise conjunction of two arrays
\r
515 CV_EXPORTS void bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat());
\r
517 CV_EXPORTS void bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, const Stream& stream);
\r
519 //! calculates per-element bit-wise "exclusive or" operation
\r
520 CV_EXPORTS void bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat());
\r
522 CV_EXPORTS void bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, const Stream& stream);
\r
524 //! computes per-element minimum of two arrays (dst = min(src1, src2))
\r
525 CV_EXPORTS void min(const GpuMat& src1, const GpuMat& src2, GpuMat& dst);
\r
527 CV_EXPORTS void min(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const Stream& stream);
\r
529 //! computes per-element minimum of array and scalar (dst = min(src1, src2))
\r
530 CV_EXPORTS void min(const GpuMat& src1, double src2, GpuMat& dst);
\r
532 CV_EXPORTS void min(const GpuMat& src1, double src2, GpuMat& dst, const Stream& stream);
\r
534 //! computes per-element maximum of two arrays (dst = max(src1, src2))
\r
535 CV_EXPORTS void max(const GpuMat& src1, const GpuMat& src2, GpuMat& dst);
\r
537 CV_EXPORTS void max(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const Stream& stream);
\r
539 //! computes per-element maximum of array and scalar (dst = max(src1, src2))
\r
540 CV_EXPORTS void max(const GpuMat& src1, double src2, GpuMat& dst);
\r
542 CV_EXPORTS void max(const GpuMat& src1, double src2, GpuMat& dst, const Stream& stream);
\r
545 ////////////////////////////// Image processing //////////////////////////////
\r
547 //! DST[x,y] = SRC[xmap[x,y],ymap[x,y]] with bilinear interpolation.
\r
548 //! supports CV_8UC1, CV_8UC3 source types and CV_32FC1 map type
\r
549 CV_EXPORTS void remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap);
\r
551 //! Does mean shift filtering on GPU.
\r
552 CV_EXPORTS void meanShiftFiltering(const GpuMat& src, GpuMat& dst, int sp, int sr,
\r
553 TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
\r
555 //! Does mean shift procedure on GPU.
\r
556 CV_EXPORTS void meanShiftProc(const GpuMat& src, GpuMat& dstr, GpuMat& dstsp, int sp, int sr,
\r
557 TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
\r
559 //! Does mean shift segmentation with elimination of small regions.
\r
560 CV_EXPORTS void meanShiftSegmentation(const GpuMat& src, Mat& dst, int sp, int sr, int minsize,
\r
561 TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
\r
563 //! Does coloring of disparity image: [0..ndisp) -> [0..240, 1, 1] in HSV.
\r
564 //! Supported types of input disparity: CV_8U, CV_16S.
\r
565 //! Output disparity has CV_8UC4 type in BGRA format (alpha = 255).
\r
566 CV_EXPORTS void drawColorDisp(const GpuMat& src_disp, GpuMat& dst_disp, int ndisp);
\r
568 CV_EXPORTS void drawColorDisp(const GpuMat& src_disp, GpuMat& dst_disp, int ndisp, const Stream& stream);
\r
570 //! Reprojects disparity image to 3D space.
\r
571 //! Supports CV_8U and CV_16S types of input disparity.
\r
572 //! The output is a 4-channel floating-point (CV_32FC4) matrix.
\r
573 //! Each element of this matrix will contain the 3D coordinates of the point (x,y,z,1), computed from the disparity map.
\r
574 //! Q is the 4x4 perspective transformation matrix that can be obtained with cvStereoRectify.
\r
575 CV_EXPORTS void reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q);
\r
577 CV_EXPORTS void reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q, const Stream& stream);
\r
579 //! converts image from one color space to another
\r
580 CV_EXPORTS void cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn = 0);
\r
582 CV_EXPORTS void cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn, const Stream& stream);
\r
584 //! applies fixed threshold to the image.
\r
585 //! Now supports only THRESH_TRUNC threshold type and one channels float source.
\r
586 CV_EXPORTS double threshold(const GpuMat& src, GpuMat& dst, double thresh);
\r
588 //! resizes the image
\r
589 //! Supports INTER_NEAREST, INTER_LINEAR
\r
590 //! supports CV_8UC1, CV_8UC4 types
\r
591 CV_EXPORTS void resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx=0, double fy=0, int interpolation = INTER_LINEAR);
\r
593 //! warps the image using affine transformation
\r
594 //! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
\r
595 CV_EXPORTS void warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR);
\r
597 //! warps the image using perspective transformation
\r
598 //! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
\r
599 CV_EXPORTS void warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR);
\r
601 //! rotate 8bit single or four channel image
\r
602 //! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
\r
603 //! supports CV_8UC1, CV_8UC4 types
\r
604 CV_EXPORTS void rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift = 0, double yShift = 0, int interpolation = INTER_LINEAR);
\r
606 //! copies 2D array to a larger destination array and pads borders with user-specifiable constant
\r
607 //! supports CV_8UC1, CV_8UC4, CV_32SC1 and CV_32FC1 types
\r
608 CV_EXPORTS void copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, const Scalar& value = Scalar());
\r
610 //! computes the integral image
\r
611 //! sum will have CV_32S type, but will contain unsigned int values
\r
612 //! supports only CV_8UC1 source type
\r
613 CV_EXPORTS void integral(const GpuMat& src, GpuMat& sum);
\r
615 //! computes the integral image and integral for the squared image
\r
616 //! sum will have CV_32S type, sqsum - CV32F type
\r
617 //! supports only CV_8UC1 source type
\r
618 CV_EXPORTS void integral(const GpuMat& src, GpuMat& sum, GpuMat& sqsum);
\r
620 //! computes squared integral image
\r
621 //! result matrix will have 64F type, but will contain 64U values
\r
622 //! supports source images of 8UC1 type only
\r
623 CV_EXPORTS void sqrIntegral(const GpuMat& src, GpuMat& sqsum);
\r
625 //! computes vertical sum, supports only CV_32FC1 images
\r
626 CV_EXPORTS void columnSum(const GpuMat& src, GpuMat& sum);
\r
628 //! computes the standard deviation of integral images
\r
629 //! supports only CV_32SC1 source type and CV_32FC1 sqr type
\r
630 //! output will have CV_32FC1 type
\r
631 CV_EXPORTS void rectStdDev(const GpuMat& src, const GpuMat& sqr, GpuMat& dst, const Rect& rect);
\r
633 //! applies Canny edge detector and produces the edge map
\r
634 //! supprots only CV_8UC1 source type
\r
635 //! disabled until fix crash
\r
636 CV_EXPORTS void Canny(const GpuMat& image, GpuMat& edges, double threshold1, double threshold2, int apertureSize = 3);
\r
638 //! computes Harris cornerness criteria at each image pixel
\r
639 CV_EXPORTS void cornerHarris(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, double k, int borderType=BORDER_REFLECT101);
\r
641 //! computes minimum eigen value of 2x2 derivative covariation matrix at each pixel - the cornerness criteria
\r
642 CV_EXPORTS void cornerMinEigenVal(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, int borderType=BORDER_REFLECT101);
\r
644 //! performs per-element multiplication of two full (not packed) Fourier spectrums
\r
645 //! supports 32FC2 matrixes only (interleaved format)
\r
646 CV_EXPORTS void mulSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flags, bool conjB=false);
\r
648 //! performs per-element multiplication of two full (not packed) Fourier spectrums
\r
649 //! supports 32FC2 matrixes only (interleaved format)
\r
650 CV_EXPORTS void mulAndScaleSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flags,
\r
651 float scale, bool conjB=false);
\r
653 //! Performs a forward or inverse discrete Fourier transform (1D or 2D) of floating point matrix.
\r
654 //! Param dft_size is the size of DFT transform.
\r
656 //! If the source matrix is not continous, then additional copy will be done,
\r
657 //! so to avoid copying ensure the source matrix is continous one. If you want to use
\r
658 //! preallocated output ensure it is continuous too, otherwise it will be reallocated.
\r
660 //! Being implemented via CUFFT real-to-complex transform result contains only non-redundant values
\r
661 //! in CUFFT's format. Result as full complex matrix for such kind of transform cannot be retrieved.
\r
663 //! For complex-to-real transform it is assumed that the source matrix is packed in CUFFT's format.
\r
664 CV_EXPORTS void dft(const GpuMat& src, GpuMat& dst, Size dft_size, int flags=0);
\r
666 //! computes convolution (or cross-correlation) of two images using discrete Fourier transform
\r
667 //! supports source images of 32FC1 type only
\r
668 //! result matrix will have 32FC1 type
\r
669 CV_EXPORTS void convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result,
\r
672 struct CV_EXPORTS ConvolveBuf;
\r
674 //! buffered version
\r
675 CV_EXPORTS void convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result,
\r
676 bool ccorr, ConvolveBuf& buf);
\r
678 struct CV_EXPORTS ConvolveBuf
\r
681 ConvolveBuf(Size image_size, Size templ_size)
\r
682 { create(image_size, templ_size); }
\r
683 void create(Size image_size, Size templ_size);
\r
686 static Size estimateBlockSize(Size result_size, Size templ_size);
\r
687 friend void convolve(const GpuMat&, const GpuMat&, GpuMat&, bool, ConvolveBuf&);
\r
694 GpuMat image_spect, templ_spect, result_spect;
\r
695 GpuMat image_block, templ_block, result_data;
\r
698 //! computes the proximity map for the raster template and the image where the template is searched for
\r
699 CV_EXPORTS void matchTemplate(const GpuMat& image, const GpuMat& templ, GpuMat& result, int method);
\r
702 ////////////////////////////// Matrix reductions //////////////////////////////
\r
704 //! computes mean value and standard deviation of all or selected array elements
\r
705 //! supports only CV_8UC1 type
\r
706 CV_EXPORTS void meanStdDev(const GpuMat& mtx, Scalar& mean, Scalar& stddev);
\r
708 //! computes norm of array
\r
709 //! supports NORM_INF, NORM_L1, NORM_L2
\r
710 //! supports only CV_8UC1 type
\r
711 CV_EXPORTS double norm(const GpuMat& src1, int normType=NORM_L2);
\r
713 //! computes norm of the difference between two arrays
\r
714 //! supports NORM_INF, NORM_L1, NORM_L2
\r
715 //! supports only CV_8UC1 type
\r
716 CV_EXPORTS double norm(const GpuMat& src1, const GpuMat& src2, int normType=NORM_L2);
\r
718 //! computes sum of array elements
\r
719 //! supports only single channel images
\r
720 CV_EXPORTS Scalar sum(const GpuMat& src);
\r
722 //! computes sum of array elements
\r
723 //! supports only single channel images
\r
724 CV_EXPORTS Scalar sum(const GpuMat& src, GpuMat& buf);
\r
726 //! computes squared sum of array elements
\r
727 //! supports only single channel images
\r
728 CV_EXPORTS Scalar sqrSum(const GpuMat& src);
\r
730 //! computes squared sum of array elements
\r
731 //! supports only single channel images
\r
732 CV_EXPORTS Scalar sqrSum(const GpuMat& src, GpuMat& buf);
\r
734 //! finds global minimum and maximum array elements and returns their values
\r
735 CV_EXPORTS void minMax(const GpuMat& src, double* minVal, double* maxVal=0, const GpuMat& mask=GpuMat());
\r
737 //! finds global minimum and maximum array elements and returns their values
\r
738 CV_EXPORTS void minMax(const GpuMat& src, double* minVal, double* maxVal, const GpuMat& mask, GpuMat& buf);
\r
740 //! finds global minimum and maximum array elements and returns their values with locations
\r
741 CV_EXPORTS void minMaxLoc(const GpuMat& src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0,
\r
742 const GpuMat& mask=GpuMat());
\r
744 //! finds global minimum and maximum array elements and returns their values with locations
\r
745 CV_EXPORTS void minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point* minLoc, Point* maxLoc,
\r
746 const GpuMat& mask, GpuMat& valbuf, GpuMat& locbuf);
\r
748 //! counts non-zero array elements
\r
749 CV_EXPORTS int countNonZero(const GpuMat& src);
\r
751 //! counts non-zero array elements
\r
752 CV_EXPORTS int countNonZero(const GpuMat& src, GpuMat& buf);
\r
755 //////////////////////////////// Filter Engine ////////////////////////////////
\r
758 The Base Class for 1D or Row-wise Filters
\r
760 This is the base class for linear or non-linear filters that process 1D data.
\r
761 In particular, such filters are used for the "horizontal" filtering parts in separable filters.
\r
763 class CV_EXPORTS BaseRowFilter_GPU
\r
766 BaseRowFilter_GPU(int ksize_, int anchor_) : ksize(ksize_), anchor(anchor_) {}
\r
767 virtual ~BaseRowFilter_GPU() {}
\r
768 virtual void operator()(const GpuMat& src, GpuMat& dst) = 0;
\r
773 The Base Class for Column-wise Filters
\r
775 This is the base class for linear or non-linear filters that process columns of 2D arrays.
\r
776 Such filters are used for the "vertical" filtering parts in separable filters.
\r
778 class CV_EXPORTS BaseColumnFilter_GPU
\r
781 BaseColumnFilter_GPU(int ksize_, int anchor_) : ksize(ksize_), anchor(anchor_) {}
\r
782 virtual ~BaseColumnFilter_GPU() {}
\r
783 virtual void operator()(const GpuMat& src, GpuMat& dst) = 0;
\r
788 The Base Class for Non-Separable 2D Filters.
\r
790 This is the base class for linear or non-linear 2D filters.
\r
792 class CV_EXPORTS BaseFilter_GPU
\r
795 BaseFilter_GPU(const Size& ksize_, const Point& anchor_) : ksize(ksize_), anchor(anchor_) {}
\r
796 virtual ~BaseFilter_GPU() {}
\r
797 virtual void operator()(const GpuMat& src, GpuMat& dst) = 0;
\r
803 The Base Class for Filter Engine.
\r
805 The class can be used to apply an arbitrary filtering operation to an image.
\r
806 It contains all the necessary intermediate buffers.
\r
808 class CV_EXPORTS FilterEngine_GPU
\r
811 virtual ~FilterEngine_GPU() {}
\r
813 virtual void apply(const GpuMat& src, GpuMat& dst, Rect roi = Rect(0,0,-1,-1)) = 0;
\r
816 //! returns the non-separable filter engine with the specified filter
\r
817 CV_EXPORTS Ptr<FilterEngine_GPU> createFilter2D_GPU(const Ptr<BaseFilter_GPU>& filter2D, int srcType, int dstType);
\r
819 //! returns the separable filter engine with the specified filters
\r
820 CV_EXPORTS Ptr<FilterEngine_GPU> createSeparableFilter_GPU(const Ptr<BaseRowFilter_GPU>& rowFilter,
\r
821 const Ptr<BaseColumnFilter_GPU>& columnFilter, int srcType, int bufType, int dstType);
\r
823 //! returns horizontal 1D box filter
\r
824 //! supports only CV_8UC1 source type and CV_32FC1 sum type
\r
825 CV_EXPORTS Ptr<BaseRowFilter_GPU> getRowSumFilter_GPU(int srcType, int sumType, int ksize, int anchor = -1);
\r
827 //! returns vertical 1D box filter
\r
828 //! supports only CV_8UC1 sum type and CV_32FC1 dst type
\r
829 CV_EXPORTS Ptr<BaseColumnFilter_GPU> getColumnSumFilter_GPU(int sumType, int dstType, int ksize, int anchor = -1);
\r
831 //! returns 2D box filter
\r
832 //! supports CV_8UC1 and CV_8UC4 source type, dst type must be the same as source type
\r
833 CV_EXPORTS Ptr<BaseFilter_GPU> getBoxFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1, -1));
\r
835 //! returns box filter engine
\r
836 CV_EXPORTS Ptr<FilterEngine_GPU> createBoxFilter_GPU(int srcType, int dstType, const Size& ksize,
\r
837 const Point& anchor = Point(-1,-1));
\r
839 //! returns 2D morphological filter
\r
840 //! only MORPH_ERODE and MORPH_DILATE are supported
\r
841 //! supports CV_8UC1 and CV_8UC4 types
\r
842 //! kernel must have CV_8UC1 type, one rows and cols == ksize.width * ksize.height
\r
843 CV_EXPORTS Ptr<BaseFilter_GPU> getMorphologyFilter_GPU(int op, int type, const Mat& kernel, const Size& ksize,
\r
844 Point anchor=Point(-1,-1));
\r
846 //! returns morphological filter engine. Only MORPH_ERODE and MORPH_DILATE are supported.
\r
847 CV_EXPORTS Ptr<FilterEngine_GPU> createMorphologyFilter_GPU(int op, int type, const Mat& kernel,
\r
848 const Point& anchor = Point(-1,-1), int iterations = 1);
\r
850 //! returns 2D filter with the specified kernel
\r
851 //! supports CV_8UC1 and CV_8UC4 types
\r
852 CV_EXPORTS Ptr<BaseFilter_GPU> getLinearFilter_GPU(int srcType, int dstType, const Mat& kernel, const Size& ksize,
\r
853 Point anchor = Point(-1, -1));
\r
855 //! returns the non-separable linear filter engine
\r
856 CV_EXPORTS Ptr<FilterEngine_GPU> createLinearFilter_GPU(int srcType, int dstType, const Mat& kernel,
\r
857 const Point& anchor = Point(-1,-1));
\r
859 //! returns the primitive row filter with the specified kernel.
\r
860 //! supports only CV_8UC1, CV_8UC4, CV_16SC1, CV_16SC2, CV_32SC1, CV_32FC1 source type.
\r
861 //! there are two version of algorithm: NPP and OpenCV.
\r
862 //! NPP calls when srcType == CV_8UC1 or srcType == CV_8UC4 and bufType == srcType,
\r
863 //! otherwise calls OpenCV version.
\r
864 //! NPP supports only BORDER_CONSTANT border type.
\r
865 //! OpenCV version supports only CV_32F as buffer depth and
\r
866 //! BORDER_REFLECT101, BORDER_REPLICATE and BORDER_CONSTANT border types.
\r
867 CV_EXPORTS Ptr<BaseRowFilter_GPU> getLinearRowFilter_GPU(int srcType, int bufType, const Mat& rowKernel,
\r
868 int anchor = -1, int borderType = BORDER_CONSTANT);
\r
870 //! returns the primitive column filter with the specified kernel.
\r
871 //! supports only CV_8UC1, CV_8UC4, CV_16SC1, CV_16SC2, CV_32SC1, CV_32FC1 dst type.
\r
872 //! there are two version of algorithm: NPP and OpenCV.
\r
873 //! NPP calls when dstType == CV_8UC1 or dstType == CV_8UC4 and bufType == dstType,
\r
874 //! otherwise calls OpenCV version.
\r
875 //! NPP supports only BORDER_CONSTANT border type.
\r
876 //! OpenCV version supports only CV_32F as buffer depth and
\r
877 //! BORDER_REFLECT101, BORDER_REPLICATE and BORDER_CONSTANT border types.
\r
878 CV_EXPORTS Ptr<BaseColumnFilter_GPU> getLinearColumnFilter_GPU(int bufType, int dstType, const Mat& columnKernel,
\r
879 int anchor = -1, int borderType = BORDER_CONSTANT);
\r
881 //! returns the separable linear filter engine
\r
882 CV_EXPORTS Ptr<FilterEngine_GPU> createSeparableLinearFilter_GPU(int srcType, int dstType, const Mat& rowKernel,
\r
883 const Mat& columnKernel, const Point& anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT,
\r
884 int columnBorderType = -1);
\r
886 //! returns filter engine for the generalized Sobel operator
\r
887 CV_EXPORTS Ptr<FilterEngine_GPU> createDerivFilter_GPU(int srcType, int dstType, int dx, int dy, int ksize,
\r
888 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
890 //! returns the Gaussian filter engine
\r
891 CV_EXPORTS Ptr<FilterEngine_GPU> createGaussianFilter_GPU(int type, Size ksize, double sigma1, double sigma2 = 0,
\r
892 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
894 //! returns maximum filter
\r
895 CV_EXPORTS Ptr<BaseFilter_GPU> getMaxFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1,-1));
\r
897 //! returns minimum filter
\r
898 CV_EXPORTS Ptr<BaseFilter_GPU> getMinFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1,-1));
\r
900 //! smooths the image using the normalized box filter
\r
901 //! supports CV_8UC1, CV_8UC4 types
\r
902 CV_EXPORTS void boxFilter(const GpuMat& src, GpuMat& dst, int ddepth, Size ksize, Point anchor = Point(-1,-1));
\r
904 //! a synonym for normalized box filter
\r
905 static inline void blur(const GpuMat& src, GpuMat& dst, Size ksize, Point anchor = Point(-1,-1)) { boxFilter(src, dst, -1, ksize, anchor); }
\r
907 //! erodes the image (applies the local minimum operator)
\r
908 CV_EXPORTS void erode( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1);
\r
910 //! dilates the image (applies the local maximum operator)
\r
911 CV_EXPORTS void dilate( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1);
\r
913 //! applies an advanced morphological operation to the image
\r
914 CV_EXPORTS void morphologyEx( const GpuMat& src, GpuMat& dst, int op, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1);
\r
916 //! applies non-separable 2D linear filter to the image
\r
917 CV_EXPORTS void filter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernel, Point anchor=Point(-1,-1));
\r
919 //! applies separable 2D linear filter to the image
\r
920 CV_EXPORTS void sepFilter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernelX, const Mat& kernelY,
\r
921 Point anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
923 //! applies generalized Sobel operator to the image
\r
924 CV_EXPORTS void Sobel(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, int ksize = 3, double scale = 1,
\r
925 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
927 //! applies the vertical or horizontal Scharr operator to the image
\r
928 CV_EXPORTS void Scharr(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, double scale = 1,
\r
929 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
931 //! smooths the image using Gaussian filter.
\r
932 CV_EXPORTS void GaussianBlur(const GpuMat& src, GpuMat& dst, Size ksize, double sigma1, double sigma2 = 0,
\r
933 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
935 //! applies Laplacian operator to the image
\r
936 //! supports only ksize = 1 and ksize = 3
\r
937 CV_EXPORTS void Laplacian(const GpuMat& src, GpuMat& dst, int ddepth, int ksize = 1, double scale = 1);
\r
939 //////////////////////////////// Image Labeling ////////////////////////////////
\r
941 //!performs labeling via graph cuts
\r
942 CV_EXPORTS void graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTransp, GpuMat& top, GpuMat& bottom, GpuMat& labels, GpuMat& buf);
\r
944 ////////////////////////////////// Histograms //////////////////////////////////
\r
946 //! Compute levels with even distribution. levels will have 1 row and nLevels cols and CV_32SC1 type.
\r
947 CV_EXPORTS void evenLevels(GpuMat& levels, int nLevels, int lowerLevel, int upperLevel);
\r
948 //! Calculates histogram with evenly distributed bins for signle channel source.
\r
949 //! Supports CV_8UC1, CV_16UC1 and CV_16SC1 source types.
\r
950 //! Output hist will have one row and histSize cols and CV_32SC1 type.
\r
951 CV_EXPORTS void histEven(const GpuMat& src, GpuMat& hist, int histSize, int lowerLevel, int upperLevel);
\r
952 //! Calculates histogram with evenly distributed bins for four-channel source.
\r
953 //! All channels of source are processed separately.
\r
954 //! Supports CV_8UC4, CV_16UC4 and CV_16SC4 source types.
\r
955 //! Output hist[i] will have one row and histSize[i] cols and CV_32SC1 type.
\r
956 CV_EXPORTS void histEven(const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4]);
\r
957 //! Calculates histogram with bins determined by levels array.
\r
958 //! levels must have one row and CV_32SC1 type if source has integer type or CV_32FC1 otherwise.
\r
959 //! Supports CV_8UC1, CV_16UC1, CV_16SC1 and CV_32FC1 source types.
\r
960 //! Output hist will have one row and (levels.cols-1) cols and CV_32SC1 type.
\r
961 CV_EXPORTS void histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels);
\r
962 //! Calculates histogram with bins determined by levels array.
\r
963 //! All levels must have one row and CV_32SC1 type if source has integer type or CV_32FC1 otherwise.
\r
964 //! All channels of source are processed separately.
\r
965 //! Supports CV_8UC4, CV_16UC4, CV_16SC4 and CV_32FC4 source types.
\r
966 //! Output hist[i] will have one row and (levels[i].cols-1) cols and CV_32SC1 type.
\r
967 CV_EXPORTS void histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4]);
\r
969 //////////////////////////////// StereoBM_GPU ////////////////////////////////
\r
971 class CV_EXPORTS StereoBM_GPU
\r
974 enum { BASIC_PRESET = 0, PREFILTER_XSOBEL = 1 };
\r
976 enum { DEFAULT_NDISP = 64, DEFAULT_WINSZ = 19 };
\r
978 //! the default constructor
\r
980 //! the full constructor taking the camera-specific preset, number of disparities and the SAD window size. ndisparities must be multiple of 8.
\r
981 StereoBM_GPU(int preset, int ndisparities = DEFAULT_NDISP, int winSize = DEFAULT_WINSZ);
\r
983 //! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair
\r
984 //! Output disparity has CV_8U type.
\r
985 void operator() ( const GpuMat& left, const GpuMat& right, GpuMat& disparity);
\r
988 void operator() ( const GpuMat& left, const GpuMat& right, GpuMat& disparity, const Stream & stream);
\r
990 //! Some heuristics that tries to estmate
\r
991 // if current GPU will be faster then CPU in this algorithm.
\r
992 // It queries current active device.
\r
993 static bool checkIfGpuCallReasonable();
\r
999 // If avergeTexThreshold == 0 => post procesing is disabled
\r
1000 // If avergeTexThreshold != 0 then disparity is set 0 in each point (x,y) where for left image
\r
1001 // SumOfHorizontalGradiensInWindow(x, y, winSize) < (winSize * winSize) * avergeTexThreshold
\r
1002 // i.e. input left image is low textured.
\r
1003 float avergeTexThreshold;
\r
1005 GpuMat minSSD, leBuf, riBuf;
\r
1008 ////////////////////////// StereoBeliefPropagation ///////////////////////////
\r
1009 // "Efficient Belief Propagation for Early Vision"
\r
1012 class CV_EXPORTS StereoBeliefPropagation
\r
1015 enum { DEFAULT_NDISP = 64 };
\r
1016 enum { DEFAULT_ITERS = 5 };
\r
1017 enum { DEFAULT_LEVELS = 5 };
\r
1019 static void estimateRecommendedParams(int width, int height, int& ndisp, int& iters, int& levels);
\r
1021 //! the default constructor
\r
1022 explicit StereoBeliefPropagation(int ndisp = DEFAULT_NDISP,
\r
1023 int iters = DEFAULT_ITERS,
\r
1024 int levels = DEFAULT_LEVELS,
\r
1025 int msg_type = CV_32F);
\r
1027 //! the full constructor taking the number of disparities, number of BP iterations on each level,
\r
1028 //! number of levels, truncation of data cost, data weight,
\r
1029 //! truncation of discontinuity cost and discontinuity single jump
\r
1030 //! DataTerm = data_weight * min(fabs(I2-I1), max_data_term)
\r
1031 //! DiscTerm = min(disc_single_jump * fabs(f1-f2), max_disc_term)
\r
1032 //! please see paper for more details
\r
1033 StereoBeliefPropagation(int ndisp, int iters, int levels,
\r
1034 float max_data_term, float data_weight,
\r
1035 float max_disc_term, float disc_single_jump,
\r
1036 int msg_type = CV_32F);
\r
1038 //! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair,
\r
1039 //! if disparity is empty output type will be CV_16S else output type will be disparity.type().
\r
1040 void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity);
\r
1043 void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream);
\r
1046 //! version for user specified data term
\r
1047 void operator()(const GpuMat& data, GpuMat& disparity);
\r
1048 void operator()(const GpuMat& data, GpuMat& disparity, Stream& stream);
\r
1055 float max_data_term;
\r
1056 float data_weight;
\r
1057 float max_disc_term;
\r
1058 float disc_single_jump;
\r
1062 GpuMat u, d, l, r, u2, d2, l2, r2;
\r
1063 std::vector<GpuMat> datas;
\r
1067 /////////////////////////// StereoConstantSpaceBP ///////////////////////////
\r
1068 // "A Constant-Space Belief Propagation Algorithm for Stereo Matching"
\r
1069 // Qingxiong Yang, Liang Wang
\86, Narendra Ahuja
\r
1070 // http://vision.ai.uiuc.edu/~qyang6/
\r
1072 class CV_EXPORTS StereoConstantSpaceBP
\r
1075 enum { DEFAULT_NDISP = 128 };
\r
1076 enum { DEFAULT_ITERS = 8 };
\r
1077 enum { DEFAULT_LEVELS = 4 };
\r
1078 enum { DEFAULT_NR_PLANE = 4 };
\r
1080 static void estimateRecommendedParams(int width, int height, int& ndisp, int& iters, int& levels, int& nr_plane);
\r
1082 //! the default constructor
\r
1083 explicit StereoConstantSpaceBP(int ndisp = DEFAULT_NDISP,
\r
1084 int iters = DEFAULT_ITERS,
\r
1085 int levels = DEFAULT_LEVELS,
\r
1086 int nr_plane = DEFAULT_NR_PLANE,
\r
1087 int msg_type = CV_32F);
\r
1089 //! the full constructor taking the number of disparities, number of BP iterations on each level,
\r
1090 //! number of levels, number of active disparity on the first level, truncation of data cost, data weight,
\r
1091 //! truncation of discontinuity cost, discontinuity single jump and minimum disparity threshold
\r
1092 StereoConstantSpaceBP(int ndisp, int iters, int levels, int nr_plane,
\r
1093 float max_data_term, float data_weight, float max_disc_term, float disc_single_jump,
\r
1094 int min_disp_th = 0,
\r
1095 int msg_type = CV_32F);
\r
1097 //! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair,
\r
1098 //! if disparity is empty output type will be CV_16S else output type will be disparity.type().
\r
1099 void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity);
\r
1102 void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream);
\r
1111 float max_data_term;
\r
1112 float data_weight;
\r
1113 float max_disc_term;
\r
1114 float disc_single_jump;
\r
1120 bool use_local_init_data_cost;
\r
1122 GpuMat u[2], d[2], l[2], r[2];
\r
1123 GpuMat disp_selected_pyr[2];
\r
1126 GpuMat data_cost_selected;
\r
1133 /////////////////////////// DisparityBilateralFilter ///////////////////////////
\r
1134 // Disparity map refinement using joint bilateral filtering given a single color image.
\r
1135 // Qingxiong Yang, Liang Wang
\86, Narendra Ahuja
\r
1136 // http://vision.ai.uiuc.edu/~qyang6/
\r
1138 class CV_EXPORTS DisparityBilateralFilter
\r
1141 enum { DEFAULT_NDISP = 64 };
\r
1142 enum { DEFAULT_RADIUS = 3 };
\r
1143 enum { DEFAULT_ITERS = 1 };
\r
1145 //! the default constructor
\r
1146 explicit DisparityBilateralFilter(int ndisp = DEFAULT_NDISP, int radius = DEFAULT_RADIUS, int iters = DEFAULT_ITERS);
\r
1148 //! the full constructor taking the number of disparities, filter radius,
\r
1149 //! number of iterations, truncation of data continuity, truncation of disparity continuity
\r
1150 //! and filter range sigma
\r
1151 DisparityBilateralFilter(int ndisp, int radius, int iters, float edge_threshold, float max_disc_threshold, float sigma_range);
\r
1153 //! the disparity map refinement operator. Refine disparity map using joint bilateral filtering given a single color image.
\r
1154 //! disparity must have CV_8U or CV_16S type, image must have CV_8UC1 or CV_8UC3 type.
\r
1155 void operator()(const GpuMat& disparity, const GpuMat& image, GpuMat& dst);
\r
1158 void operator()(const GpuMat& disparity, const GpuMat& image, GpuMat& dst, Stream& stream);
\r
1165 float edge_threshold;
\r
1166 float max_disc_threshold;
\r
1167 float sigma_range;
\r
1169 GpuMat table_color;
\r
1170 GpuMat table_space;
\r
1174 //////////////// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector //////////////
\r
1176 struct CV_EXPORTS HOGDescriptor
\r
1178 enum { DEFAULT_WIN_SIGMA = -1 };
\r
1179 enum { DEFAULT_NLEVELS = 64 };
\r
1180 enum { DESCR_FORMAT_ROW_BY_ROW, DESCR_FORMAT_COL_BY_COL };
\r
1182 HOGDescriptor(Size win_size=Size(64, 128), Size block_size=Size(16, 16),
\r
1183 Size block_stride=Size(8, 8), Size cell_size=Size(8, 8),
\r
1184 int nbins=9, double win_sigma=DEFAULT_WIN_SIGMA,
\r
1185 double threshold_L2hys=0.2, bool gamma_correction=true,
\r
1186 int nlevels=DEFAULT_NLEVELS);
\r
1188 size_t getDescriptorSize() const;
\r
1189 size_t getBlockHistogramSize() const;
\r
1191 void setSVMDetector(const vector<float>& detector);
\r
1193 static vector<float> getDefaultPeopleDetector();
\r
1194 static vector<float> getPeopleDetector48x96();
\r
1195 static vector<float> getPeopleDetector64x128();
\r
1197 void detect(const GpuMat& img, vector<Point>& found_locations,
\r
1198 double hit_threshold=0, Size win_stride=Size(),
\r
1199 Size padding=Size());
\r
1201 void detectMultiScale(const GpuMat& img, vector<Rect>& found_locations,
\r
1202 double hit_threshold=0, Size win_stride=Size(),
\r
1203 Size padding=Size(), double scale0=1.05,
\r
1204 int group_threshold=2);
\r
1206 void getDescriptors(const GpuMat& img, Size win_stride,
\r
1207 GpuMat& descriptors,
\r
1208 int descr_format=DESCR_FORMAT_COL_BY_COL);
\r
1212 Size block_stride;
\r
1216 double threshold_L2hys;
\r
1217 bool gamma_correction;
\r
1221 void computeBlockHistograms(const GpuMat& img);
\r
1222 void computeGradient(const GpuMat& img, GpuMat& grad, GpuMat& qangle);
\r
1224 double getWinSigma() const;
\r
1225 bool checkDetectorSize() const;
\r
1227 static int numPartsWithin(int size, int part_size, int stride);
\r
1228 static Size numPartsWithin(Size size, Size part_size, Size stride);
\r
1230 // Coefficients of the separating plane
\r
1234 // Results of the last classification step
\r
1238 // Results of the last histogram evaluation step
\r
1239 GpuMat block_hists;
\r
1241 // Gradients conputation results
\r
1242 GpuMat grad, qangle;
\r
1246 ////////////////////////////////// BruteForceMatcher //////////////////////////////////
\r
1248 class CV_EXPORTS BruteForceMatcher_GPU_base
\r
1251 enum DistType {L1Dist = 0, L2Dist};
\r
1253 explicit BruteForceMatcher_GPU_base(DistType distType = L2Dist);
\r
1255 // Add descriptors to train descriptor collection.
\r
1256 void add(const std::vector<GpuMat>& descCollection);
\r
1258 // Get train descriptors collection.
\r
1259 const std::vector<GpuMat>& getTrainDescriptors() const;
\r
1261 // Clear train descriptors collection.
\r
1264 // Return true if there are not train descriptors in collection.
\r
1265 bool empty() const;
\r
1267 // Return true if the matcher supports mask in match methods.
\r
1268 bool isMaskSupported() const;
\r
1270 // Find one best match for each query descriptor.
\r
1271 // trainIdx.at<int>(0, queryIdx) will contain best train index for queryIdx
\r
1272 // distance.at<float>(0, queryIdx) will contain distance
\r
1273 void matchSingle(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1274 GpuMat& trainIdx, GpuMat& distance,
\r
1275 const GpuMat& mask = GpuMat());
\r
1277 // Download trainIdx and distance to CPU vector with DMatch
\r
1278 static void matchDownload(const GpuMat& trainIdx, const GpuMat& distance, std::vector<DMatch>& matches);
\r
1280 // Find one best match for each query descriptor.
\r
1281 void match(const GpuMat& queryDescs, const GpuMat& trainDescs, std::vector<DMatch>& matches,
\r
1282 const GpuMat& mask = GpuMat());
\r
1284 // Make gpu collection of trains and masks in suitable format for matchCollection function
\r
1285 void makeGpuCollection(GpuMat& trainCollection, GpuMat& maskCollection,
\r
1286 const vector<GpuMat>& masks = std::vector<GpuMat>());
\r
1288 // Find one best match from train collection for each query descriptor.
\r
1289 // trainIdx.at<int>(0, queryIdx) will contain best train index for queryIdx
\r
1290 // imgIdx.at<int>(0, queryIdx) will contain best image index for queryIdx
\r
1291 // distance.at<float>(0, queryIdx) will contain distance
\r
1292 void matchCollection(const GpuMat& queryDescs, const GpuMat& trainCollection,
\r
1293 GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance,
\r
1294 const GpuMat& maskCollection);
\r
1296 // Download trainIdx, imgIdx and distance to CPU vector with DMatch
\r
1297 static void matchDownload(const GpuMat& trainIdx, GpuMat& imgIdx, const GpuMat& distance,
\r
1298 std::vector<DMatch>& matches);
\r
1300 // Find one best match from train collection for each query descriptor.
\r
1301 void match(const GpuMat& queryDescs, std::vector<DMatch>& matches,
\r
1302 const std::vector<GpuMat>& masks = std::vector<GpuMat>());
\r
1304 // Find k best matches for each query descriptor (in increasing order of distances).
\r
1305 // trainIdx.at<int>(queryIdx, i) will contain index of i'th best trains (i < k).
\r
1306 // distance.at<float>(queryIdx, i) will contain distance.
\r
1307 // allDist is a buffer to store all distance between query descriptors and train descriptors
\r
1308 // it have size (nQuery,nTrain) and CV_32F type
\r
1309 // allDist.at<float>(queryIdx, trainIdx) will contain FLT_MAX, if trainIdx is one from k best,
\r
1310 // otherwise it will contain distance between queryIdx and trainIdx descriptors
\r
1311 void knnMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1312 GpuMat& trainIdx, GpuMat& distance, GpuMat& allDist, int k, const GpuMat& mask = GpuMat());
\r
1314 // Download trainIdx and distance to CPU vector with DMatch
\r
1315 // compactResult is used when mask is not empty. If compactResult is false matches
\r
1316 // vector will have the same size as queryDescriptors rows. If compactResult is true
\r
1317 // matches vector will not contain matches for fully masked out query descriptors.
\r
1318 static void knnMatchDownload(const GpuMat& trainIdx, const GpuMat& distance,
\r
1319 std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
\r
1321 // Find k best matches for each query descriptor (in increasing order of distances).
\r
1322 // compactResult is used when mask is not empty. If compactResult is false matches
\r
1323 // vector will have the same size as queryDescriptors rows. If compactResult is true
\r
1324 // matches vector will not contain matches for fully masked out query descriptors.
\r
1325 void knnMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1326 std::vector< std::vector<DMatch> >& matches, int k, const GpuMat& mask = GpuMat(),
\r
1327 bool compactResult = false);
\r
1329 // Find k best matches for each query descriptor (in increasing order of distances).
\r
1330 // compactResult is used when mask is not empty. If compactResult is false matches
\r
1331 // vector will have the same size as queryDescriptors rows. If compactResult is true
\r
1332 // matches vector will not contain matches for fully masked out query descriptors.
\r
1333 void knnMatch(const GpuMat& queryDescs, std::vector< std::vector<DMatch> >& matches, int knn,
\r
1334 const std::vector<GpuMat>& masks = std::vector<GpuMat>(), bool compactResult = false );
\r
1336 // Find best matches for each query descriptor which have distance less than maxDistance.
\r
1337 // nMatches.at<unsigned int>(0, queruIdx) will contain matches count for queryIdx.
\r
1338 // carefully nMatches can be greater than trainIdx.cols - it means that matcher didn't find all matches,
\r
1339 // because it didn't have enough memory.
\r
1340 // trainIdx.at<int>(queruIdx, i) will contain ith train index (i < min(nMatches.at<unsigned int>(0, queruIdx), trainIdx.cols))
\r
1341 // distance.at<int>(queruIdx, i) will contain ith distance (i < min(nMatches.at<unsigned int>(0, queruIdx), trainIdx.cols))
\r
1342 // If trainIdx is empty, then trainIdx and distance will be created with size nQuery x nTrain,
\r
1343 // otherwize user can pass own allocated trainIdx and distance with size nQuery x nMaxMatches
\r
1344 // Matches doesn't sorted.
\r
1345 void radiusMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1346 GpuMat& trainIdx, GpuMat& nMatches, GpuMat& distance, float maxDistance,
\r
1347 const GpuMat& mask = GpuMat());
\r
1349 // Download trainIdx, nMatches and distance to CPU vector with DMatch.
\r
1350 // matches will be sorted in increasing order of distances.
\r
1351 // compactResult is used when mask is not empty. If compactResult is false matches
\r
1352 // vector will have the same size as queryDescriptors rows. If compactResult is true
\r
1353 // matches vector will not contain matches for fully masked out query descriptors.
\r
1354 static void radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& nMatches, const GpuMat& distance,
\r
1355 std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
\r
1357 // Find best matches for each query descriptor which have distance less than maxDistance
\r
1358 // in increasing order of distances).
\r
1359 void radiusMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1360 std::vector< std::vector<DMatch> >& matches, float maxDistance,
\r
1361 const GpuMat& mask = GpuMat(), bool compactResult = false);
\r
1363 // Find best matches from train collection for each query descriptor which have distance less than
\r
1364 // maxDistance (in increasing order of distances).
\r
1365 void radiusMatch(const GpuMat& queryDescs, std::vector< std::vector<DMatch> >& matches, float maxDistance,
\r
1366 const std::vector<GpuMat>& masks = std::vector<GpuMat>(), bool compactResult = false);
\r
1369 DistType distType;
\r
1371 std::vector<GpuMat> trainDescCollection;
\r
1374 template <class Distance>
\r
1375 class CV_EXPORTS BruteForceMatcher_GPU;
\r
1377 template <typename T>
\r
1378 class CV_EXPORTS BruteForceMatcher_GPU< L1<T> > : public BruteForceMatcher_GPU_base
\r
1381 explicit BruteForceMatcher_GPU() : BruteForceMatcher_GPU_base(L1Dist) {}
\r
1382 explicit BruteForceMatcher_GPU(L1<T> /*d*/) : BruteForceMatcher_GPU_base(L1Dist) {}
\r
1384 template <typename T>
\r
1385 class CV_EXPORTS BruteForceMatcher_GPU< L2<T> > : public BruteForceMatcher_GPU_base
\r
1388 explicit BruteForceMatcher_GPU() : BruteForceMatcher_GPU_base(L2Dist) {}
\r
1389 explicit BruteForceMatcher_GPU(L2<T> /*d*/) : BruteForceMatcher_GPU_base(L2Dist) {}
\r
1392 ////////////////////////////////// CascadeClassifier_GPU //////////////////////////////////////////
\r
1393 // The cascade classifier class for object detection.
\r
1394 class CV_EXPORTS CascadeClassifier_GPU
\r
1397 CascadeClassifier_GPU();
\r
1398 CascadeClassifier_GPU(const string& filename);
\r
1399 ~CascadeClassifier_GPU();
\r
1401 bool empty() const;
\r
1402 bool load(const string& filename);
\r
1405 /* returns number of detected objects */
\r
1406 int detectMultiScale( const GpuMat& image, GpuMat& objectsBuf, double scaleFactor=1.2, int minNeighbors=4, Size minSize=Size());
\r
1408 bool findLargestObject;
\r
1409 bool visualizeInPlace;
\r
1411 Size getClassifierSize() const;
\r
1414 struct CascadeClassifierImpl;
\r
1415 CascadeClassifierImpl* impl;
\r
1418 ////////////////////////////////// SURF //////////////////////////////////////////
\r
1420 struct CV_EXPORTS SURFParams_GPU
\r
1422 SURFParams_GPU() : threshold(0.1f), nOctaves(4), nIntervals(4), initialScale(2.f),
\r
1423 l1(3.f/1.5f), l2(5.f/1.5f), l3(3.f/1.5f), l4(1.f/1.5f),
\r
1424 edgeScale(0.81f), initialStep(1), extended(true), featuresRatio(0.01f) {}
\r
1426 //! The interest operator threshold
\r
1428 //! The number of octaves to process
\r
1430 //! The number of intervals in each octave
\r
1432 //! The scale associated with the first interval of the first octave
\r
1433 float initialScale;
\r
1435 //! mask parameter l_1
\r
1437 //! mask parameter l_2
\r
1439 //! mask parameter l_3
\r
1441 //! mask parameter l_4
\r
1443 //! The amount to scale the edge rejection mask
\r
1445 //! The initial sampling step in pixels.
\r
1448 //! True, if generate 128-len descriptors, false - 64-len descriptors
\r
1451 //! max features = featuresRatio * img.size().srea()
\r
1452 float featuresRatio;
\r
1455 class CV_EXPORTS SURF_GPU : public SURFParams_GPU
\r
1458 //! returns the descriptor size in float's (64 or 128)
\r
1459 int descriptorSize() const;
\r
1461 //! upload host keypoints to device memory
\r
1462 static void uploadKeypoints(const vector<KeyPoint>& keypoints, GpuMat& keypointsGPU);
\r
1463 //! download keypoints from device to host memory
\r
1464 static void downloadKeypoints(const GpuMat& keypointsGPU, vector<KeyPoint>& keypoints);
\r
1466 //! download descriptors from device to host memory
\r
1467 static void downloadDescriptors(const GpuMat& descriptorsGPU, vector<float>& descriptors);
\r
1469 //! finds the keypoints using fast hessian detector used in SURF
\r
1470 //! supports CV_8UC1 images
\r
1471 //! keypoints will have 1 row and type CV_32FC(6)
\r
1472 //! keypoints.at<float[6]>(1, i) contains i'th keypoint
\r
1473 //! format: (x, y, size, response, angle, octave)
\r
1474 void operator()(const GpuMat& img, const GpuMat& mask, GpuMat& keypoints);
\r
1475 //! finds the keypoints and computes their descriptors.
\r
1476 //! Optionally it can compute descriptors for the user-provided keypoints and recompute keypoints direction
\r
1477 void operator()(const GpuMat& img, const GpuMat& mask, GpuMat& keypoints, GpuMat& descriptors,
\r
1478 bool useProvidedKeypoints = false, bool calcOrientation = true);
\r
1480 void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints);
\r
1481 void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, GpuMat& descriptors,
\r
1482 bool useProvidedKeypoints = false, bool calcOrientation = true);
\r
1484 void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, std::vector<float>& descriptors,
\r
1485 bool useProvidedKeypoints = false, bool calcOrientation = true);
\r
1493 GpuMat hessianBuffer;
\r
1494 GpuMat maxPosBuffer;
\r
1495 GpuMat featuresBuffer;
\r
1500 //! Speckle filtering - filters small connected components on diparity image.
\r
1501 //! It sets pixel (x,y) to newVal if it coresponds to small CC with size < maxSpeckleSize.
\r
1502 //! Threshold for border between CC is diffThreshold;
\r
1503 CV_EXPORTS void filterSpeckles( Mat& img, uchar newVal, int maxSpeckleSize, uchar diffThreshold, Mat& buf);
\r
1506 #include "opencv2/gpu/matrix_operations.hpp"
\r
1508 #endif /* __OPENCV_GPU_HPP__ */
\r