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 //////////////////////////////// Error handling ////////////////////////
\r
77 CV_EXPORTS void error(const char *error_string, const char *file, const int line, const char *func);
\r
78 CV_EXPORTS void nppError( int err, const char *file, const int line, const char *func);
\r
80 //////////////////////////////// GpuMat ////////////////////////////////
\r
84 //! Smart pointer for GPU memory with reference counting. Its interface is mostly similar with cv::Mat.
\r
85 class CV_EXPORTS GpuMat
\r
88 //! default constructor
\r
90 //! constructs GpuMatrix of the specified size and type (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.)
\r
91 GpuMat(int rows, int cols, int type);
\r
92 GpuMat(Size size, int type);
\r
93 //! constucts GpuMatrix and fills it with the specified value _s.
\r
94 GpuMat(int rows, int cols, int type, const Scalar& s);
\r
95 GpuMat(Size size, int type, const Scalar& s);
\r
96 //! copy constructor
\r
97 GpuMat(const GpuMat& m);
\r
99 //! constructor for GpuMatrix headers pointing to user-allocated data
\r
100 GpuMat(int rows, int cols, int type, void* data, size_t step = Mat::AUTO_STEP);
\r
101 GpuMat(Size size, int type, void* data, size_t step = Mat::AUTO_STEP);
\r
103 //! creates a matrix header for a part of the bigger matrix
\r
104 GpuMat(const GpuMat& m, const Range& rowRange, const Range& colRange);
\r
105 GpuMat(const GpuMat& m, const Rect& roi);
\r
107 //! builds GpuMat from Mat. Perfom blocking upload to device.
\r
108 explicit GpuMat (const Mat& m);
\r
110 //! destructor - calls release()
\r
113 //! assignment operators
\r
114 GpuMat& operator = (const GpuMat& m);
\r
115 //! assignment operator. Perfom blocking upload to device.
\r
116 GpuMat& operator = (const Mat& m);
\r
118 //! returns lightweight DevMem2D_ structure for passing to nvcc-compiled code.
\r
119 // Contains just image size, data ptr and step.
\r
120 template <class T> operator DevMem2D_<T>() const;
\r
121 template <class T> operator PtrStep_<T>() const;
\r
123 //! pefroms blocking upload data to GpuMat.
\r
124 void upload(const cv::Mat& m);
\r
127 void upload(const CudaMem& m, Stream& stream);
\r
129 //! downloads data from device to host memory. Blocking calls.
\r
130 operator Mat() const;
\r
131 void download(cv::Mat& m) const;
\r
134 void download(CudaMem& m, Stream& stream) const;
\r
136 //! returns a new GpuMatrix header for the specified row
\r
137 GpuMat row(int y) const;
\r
138 //! returns a new GpuMatrix header for the specified column
\r
139 GpuMat col(int x) const;
\r
140 //! ... for the specified row span
\r
141 GpuMat rowRange(int startrow, int endrow) const;
\r
142 GpuMat rowRange(const Range& r) const;
\r
143 //! ... for the specified column span
\r
144 GpuMat colRange(int startcol, int endcol) const;
\r
145 GpuMat colRange(const Range& r) const;
\r
147 //! returns deep copy of the GpuMatrix, i.e. the data is copied
\r
148 GpuMat clone() const;
\r
149 //! copies the GpuMatrix content to "m".
\r
150 // It calls m.create(this->size(), this->type()).
\r
151 void copyTo( GpuMat& m ) const;
\r
152 //! copies those GpuMatrix elements to "m" that are marked with non-zero mask elements.
\r
153 void copyTo( GpuMat& m, const GpuMat& mask ) const;
\r
154 //! converts GpuMatrix to another datatype with optional scalng. See cvConvertScale.
\r
155 void convertTo( GpuMat& m, int rtype, double alpha=1, double beta=0 ) const;
\r
157 void assignTo( GpuMat& m, int type=-1 ) const;
\r
159 //! sets every GpuMatrix element to s
\r
160 GpuMat& operator = (const Scalar& s);
\r
161 //! sets some of the GpuMatrix elements to s, according to the mask
\r
162 GpuMat& setTo(const Scalar& s, const GpuMat& mask = GpuMat());
\r
163 //! creates alternative GpuMatrix header for the same data, with different
\r
164 // number of channels and/or different number of rows. see cvReshape.
\r
165 GpuMat reshape(int cn, int rows = 0) const;
\r
167 //! allocates new GpuMatrix data unless the GpuMatrix already has specified size and type.
\r
168 // previous data is unreferenced if needed.
\r
169 void create(int rows, int cols, int type);
\r
170 void create(Size size, int type);
\r
171 //! decreases reference counter;
\r
172 // deallocate the data when reference counter reaches 0.
\r
175 //! swaps with other smart pointer
\r
176 void swap(GpuMat& mat);
\r
178 //! locates GpuMatrix header within a parent GpuMatrix. See below
\r
179 void locateROI( Size& wholeSize, Point& ofs ) const;
\r
180 //! moves/resizes the current GpuMatrix ROI inside the parent GpuMatrix.
\r
181 GpuMat& adjustROI( int dtop, int dbottom, int dleft, int dright );
\r
182 //! extracts a rectangular sub-GpuMatrix
\r
183 // (this is a generalized form of row, rowRange etc.)
\r
184 GpuMat operator()( Range rowRange, Range colRange ) const;
\r
185 GpuMat operator()( const Rect& roi ) const;
\r
187 //! returns true iff the GpuMatrix data is continuous
\r
188 // (i.e. when there are no gaps between successive rows).
\r
189 // similar to CV_IS_GpuMat_CONT(cvGpuMat->type)
\r
190 bool isContinuous() const;
\r
191 //! returns element size in bytes,
\r
192 // similar to CV_ELEM_SIZE(cvMat->type)
\r
193 size_t elemSize() const;
\r
194 //! returns the size of element channel in bytes.
\r
195 size_t elemSize1() const;
\r
196 //! returns element type, similar to CV_MAT_TYPE(cvMat->type)
\r
198 //! returns element type, similar to CV_MAT_DEPTH(cvMat->type)
\r
200 //! returns element type, similar to CV_MAT_CN(cvMat->type)
\r
201 int channels() const;
\r
202 //! returns step/elemSize1()
\r
203 size_t step1() const;
\r
204 //! returns GpuMatrix size:
\r
205 // width == number of columns, height == number of rows
\r
207 //! returns true if GpuMatrix data is NULL
\r
208 bool empty() const;
\r
210 //! returns pointer to y-th row
\r
211 uchar* ptr(int y = 0);
\r
212 const uchar* ptr(int y = 0) const;
\r
214 //! template version of the above method
\r
215 template<typename _Tp> _Tp* ptr(int y = 0);
\r
216 template<typename _Tp> const _Tp* ptr(int y = 0) const;
\r
218 //! matrix transposition
\r
221 /*! includes several bit-fields:
\r
222 - the magic signature
\r
225 - number of channels
\r
228 //! the number of rows and columns
\r
230 //! a distance between successive rows in bytes; includes the gap if any
\r
232 //! pointer to the data
\r
235 //! pointer to the reference counter;
\r
236 // when GpuMatrix points to user-allocated data, the pointer is NULL
\r
239 //! helper fields used in locateROI and adjustROI
\r
244 //#define TemplatedGpuMat // experimental now, deprecated to use
\r
245 #ifdef TemplatedGpuMat
\r
246 #include "GpuMat_BetaDeprecated.hpp"
\r
249 //! creates continuous GPU matrix
\r
250 CV_EXPORTS void createContinuous(int rows, int cols, int type, GpuMat& m);
\r
252 //////////////////////////////// CudaMem ////////////////////////////////
\r
253 // CudaMem is limited cv::Mat with page locked memory allocation.
\r
254 // Page locked memory is only needed for async and faster coping to GPU.
\r
255 // It is convertable to cv::Mat header without reference counting
\r
256 // so you can use it with other opencv functions.
\r
258 class CV_EXPORTS CudaMem
\r
261 enum { ALLOC_PAGE_LOCKED = 1, ALLOC_ZEROCOPY = 2, ALLOC_WRITE_COMBINED = 4 };
\r
264 CudaMem(const CudaMem& m);
\r
266 CudaMem(int rows, int cols, int type, int _alloc_type = ALLOC_PAGE_LOCKED);
\r
267 CudaMem(Size size, int type, int alloc_type = ALLOC_PAGE_LOCKED);
\r
270 //! creates from cv::Mat with coping data
\r
271 explicit CudaMem(const Mat& m, int alloc_type = ALLOC_PAGE_LOCKED);
\r
275 CudaMem& operator = (const CudaMem& m);
\r
277 //! returns deep copy of the matrix, i.e. the data is copied
\r
278 CudaMem clone() const;
\r
280 //! allocates new matrix data unless the matrix already has specified size and type.
\r
281 void create(int rows, int cols, int type, int alloc_type = ALLOC_PAGE_LOCKED);
\r
282 void create(Size size, int type, int alloc_type = ALLOC_PAGE_LOCKED);
\r
284 //! decrements reference counter and released memory if needed.
\r
287 //! returns matrix header with disabled reference counting for CudaMem data.
\r
288 Mat createMatHeader() const;
\r
289 operator Mat() const;
\r
291 //! maps host memory into device address space and returns GpuMat header for it. Throws exception if not supported by hardware.
\r
292 GpuMat createGpuMatHeader() const;
\r
293 operator GpuMat() const;
\r
295 //returns if host memory can be mapperd to gpu address space;
\r
296 static bool canMapHostMemory();
\r
298 // Please see cv::Mat for descriptions
\r
299 bool isContinuous() const;
\r
300 size_t elemSize() const;
\r
301 size_t elemSize1() const;
\r
304 int channels() const;
\r
305 size_t step1() const;
\r
307 bool empty() const;
\r
310 // Please see cv::Mat for descriptions
\r
324 //////////////////////////////// CudaStream ////////////////////////////////
\r
325 // Encapculates Cuda Stream. Provides interface for async coping.
\r
326 // Passed to each function that supports async kernel execution.
\r
327 // Reference counting is enabled
\r
329 class CV_EXPORTS Stream
\r
335 Stream(const Stream&);
\r
336 Stream& operator=(const Stream&);
\r
338 bool queryIfComplete();
\r
339 void waitForCompletion();
\r
341 //! downloads asynchronously.
\r
342 // Warning! cv::Mat must point to page locked memory (i.e. to CudaMem data or to its subMat)
\r
343 void enqueueDownload(const GpuMat& src, CudaMem& dst);
\r
344 void enqueueDownload(const GpuMat& src, Mat& dst);
\r
346 //! uploads asynchronously.
\r
347 // Warning! cv::Mat must point to page locked memory (i.e. to CudaMem data or to its ROI)
\r
348 void enqueueUpload(const CudaMem& src, GpuMat& dst);
\r
349 void enqueueUpload(const Mat& src, GpuMat& dst);
\r
351 void enqueueCopy(const GpuMat& src, GpuMat& dst);
\r
353 void enqueueMemSet(const GpuMat& src, Scalar val);
\r
354 void enqueueMemSet(const GpuMat& src, Scalar val, const GpuMat& mask);
\r
356 // converts matrix type, ex from float to uchar depending on type
\r
357 void enqueueConvert(const GpuMat& src, GpuMat& dst, int type, double a = 1, double b = 0);
\r
363 friend struct StreamAccessor;
\r
367 ////////////////////////////// Arithmetics ///////////////////////////////////
\r
369 //! transposes the matrix
\r
370 //! supports matrix with element size = 1, 4 and 8 bytes (CV_8UC1, CV_8UC4, CV_16UC2, CV_32FC1, etc)
\r
371 CV_EXPORTS void transpose(const GpuMat& src1, GpuMat& dst);
\r
373 //! reverses the order of the rows, columns or both in a matrix
\r
374 //! supports CV_8UC1, CV_8UC4 types
\r
375 CV_EXPORTS void flip(const GpuMat& a, GpuMat& b, int flipCode);
\r
377 //! transforms 8-bit unsigned integers using lookup table: dst(i)=lut(src(i))
\r
378 //! destination array will have the depth type as lut and the same channels number as source
\r
379 //! supports CV_8UC1, CV_8UC3 types
\r
380 CV_EXPORTS void LUT(const GpuMat& src, const Mat& lut, GpuMat& dst);
\r
382 //! makes multi-channel array out of several single-channel arrays
\r
383 CV_EXPORTS void merge(const GpuMat* src, size_t n, GpuMat& dst);
\r
385 //! makes multi-channel array out of several single-channel arrays
\r
386 CV_EXPORTS void merge(const vector<GpuMat>& src, GpuMat& dst);
\r
388 //! makes multi-channel array out of several single-channel arrays (async version)
\r
389 CV_EXPORTS void merge(const GpuMat* src, size_t n, GpuMat& dst, const Stream& stream);
\r
391 //! makes multi-channel array out of several single-channel arrays (async version)
\r
392 CV_EXPORTS void merge(const vector<GpuMat>& src, GpuMat& dst, const Stream& stream);
\r
394 //! copies each plane of a multi-channel array to a dedicated array
\r
395 CV_EXPORTS void split(const GpuMat& src, GpuMat* dst);
\r
397 //! copies each plane of a multi-channel array to a dedicated array
\r
398 CV_EXPORTS void split(const GpuMat& src, vector<GpuMat>& dst);
\r
400 //! copies each plane of a multi-channel array to a dedicated array (async version)
\r
401 CV_EXPORTS void split(const GpuMat& src, GpuMat* dst, const Stream& stream);
\r
403 //! copies each plane of a multi-channel array to a dedicated array (async version)
\r
404 CV_EXPORTS void split(const GpuMat& src, vector<GpuMat>& dst, const Stream& stream);
\r
406 //! computes magnitude of complex (x(i).re, x(i).im) vector
\r
407 //! supports only CV_32FC2 type
\r
408 CV_EXPORTS void magnitude(const GpuMat& x, GpuMat& magnitude);
\r
410 //! computes squared magnitude of complex (x(i).re, x(i).im) vector
\r
411 //! supports only CV_32FC2 type
\r
412 CV_EXPORTS void magnitudeSqr(const GpuMat& x, GpuMat& magnitude);
\r
414 //! computes magnitude of each (x(i), y(i)) vector
\r
415 //! supports only floating-point source
\r
416 CV_EXPORTS void magnitude(const GpuMat& x, const GpuMat& y, GpuMat& magnitude);
\r
418 CV_EXPORTS void magnitude(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, const Stream& stream);
\r
420 //! computes squared magnitude of each (x(i), y(i)) vector
\r
421 //! supports only floating-point source
\r
422 CV_EXPORTS void magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& magnitude);
\r
424 CV_EXPORTS void magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, const Stream& stream);
\r
426 //! computes angle (angle(i)) of each (x(i), y(i)) vector
\r
427 //! supports only floating-point source
\r
428 CV_EXPORTS void phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees = false);
\r
430 CV_EXPORTS void phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees, const Stream& stream);
\r
432 //! converts Cartesian coordinates to polar
\r
433 //! supports only floating-point source
\r
434 CV_EXPORTS void cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, GpuMat& angle, bool angleInDegrees = false);
\r
436 CV_EXPORTS void cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, GpuMat& angle, bool angleInDegrees, const Stream& stream);
\r
438 //! converts polar coordinates to Cartesian
\r
439 //! supports only floating-point source
\r
440 CV_EXPORTS void polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees = false);
\r
442 CV_EXPORTS void polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees, const Stream& stream);
\r
445 //////////////////////////// Per-element operations ////////////////////////////////////
\r
447 //! adds one matrix to another (c = a + b)
\r
448 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
449 CV_EXPORTS void add(const GpuMat& a, const GpuMat& b, GpuMat& c);
\r
450 //! adds scalar to a matrix (c = a + s)
\r
451 //! supports CV_32FC1 and CV_32FC2 type
\r
452 CV_EXPORTS void add(const GpuMat& a, const Scalar& sc, GpuMat& c);
\r
454 //! subtracts one matrix from another (c = a - b)
\r
455 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
456 CV_EXPORTS void subtract(const GpuMat& a, const GpuMat& b, GpuMat& c);
\r
457 //! subtracts scalar from a matrix (c = a - s)
\r
458 //! supports CV_32FC1 and CV_32FC2 type
\r
459 CV_EXPORTS void subtract(const GpuMat& a, const Scalar& sc, GpuMat& c);
\r
461 //! computes element-wise product of the two arrays (c = a * b)
\r
462 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
463 CV_EXPORTS void multiply(const GpuMat& a, const GpuMat& b, GpuMat& c);
\r
464 //! multiplies matrix to a scalar (c = a * s)
\r
465 //! supports CV_32FC1 and CV_32FC2 type
\r
466 CV_EXPORTS void multiply(const GpuMat& a, const Scalar& sc, GpuMat& c);
\r
468 //! computes element-wise quotient of the two arrays (c = a / b)
\r
469 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
470 CV_EXPORTS void divide(const GpuMat& a, const GpuMat& b, GpuMat& c);
\r
471 //! computes element-wise quotient of matrix and scalar (c = a / s)
\r
472 //! supports CV_32FC1 and CV_32FC2 type
\r
473 CV_EXPORTS void divide(const GpuMat& a, const Scalar& sc, GpuMat& c);
\r
475 //! computes exponent of each matrix element (b = e**a)
\r
476 //! supports only CV_32FC1 type
\r
477 CV_EXPORTS void exp(const GpuMat& a, GpuMat& b);
\r
479 //! computes natural logarithm of absolute value of each matrix element: b = log(abs(a))
\r
480 //! supports only CV_32FC1 type
\r
481 CV_EXPORTS void log(const GpuMat& a, GpuMat& b);
\r
483 //! computes element-wise absolute difference of two arrays (c = abs(a - b))
\r
484 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
485 CV_EXPORTS void absdiff(const GpuMat& a, const GpuMat& b, GpuMat& c);
\r
486 //! computes element-wise absolute difference of array and scalar (c = abs(a - s))
\r
487 //! supports only CV_32FC1 type
\r
488 CV_EXPORTS void absdiff(const GpuMat& a, const Scalar& s, GpuMat& c);
\r
490 //! compares elements of two arrays (c = a <cmpop> b)
\r
491 //! supports CV_8UC4, CV_32FC1 types
\r
492 CV_EXPORTS void compare(const GpuMat& a, const GpuMat& b, GpuMat& c, int cmpop);
\r
494 //! performs per-elements bit-wise inversion
\r
495 CV_EXPORTS void bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask=GpuMat());
\r
497 CV_EXPORTS void bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask, const Stream& stream);
\r
499 //! calculates per-element bit-wise disjunction of two arrays
\r
500 CV_EXPORTS void bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat());
\r
502 CV_EXPORTS void bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, const Stream& stream);
\r
504 //! calculates per-element bit-wise conjunction of two arrays
\r
505 CV_EXPORTS void bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat());
\r
507 CV_EXPORTS void bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, const Stream& stream);
\r
509 //! calculates per-element bit-wise "exclusive or" operation
\r
510 CV_EXPORTS void bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat());
\r
512 CV_EXPORTS void bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, const Stream& stream);
\r
514 //! computes per-element minimum of two arrays (dst = min(src1, src2))
\r
515 CV_EXPORTS void min(const GpuMat& src1, const GpuMat& src2, GpuMat& dst);
\r
517 CV_EXPORTS void min(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const Stream& stream);
\r
519 //! computes per-element minimum of array and scalar (dst = min(src1, src2))
\r
520 CV_EXPORTS void min(const GpuMat& src1, double src2, GpuMat& dst);
\r
522 CV_EXPORTS void min(const GpuMat& src1, double src2, GpuMat& dst, const Stream& stream);
\r
524 //! computes per-element maximum of two arrays (dst = max(src1, src2))
\r
525 CV_EXPORTS void max(const GpuMat& src1, const GpuMat& src2, GpuMat& dst);
\r
527 CV_EXPORTS void max(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const Stream& stream);
\r
529 //! computes per-element maximum of array and scalar (dst = max(src1, src2))
\r
530 CV_EXPORTS void max(const GpuMat& src1, double src2, GpuMat& dst);
\r
532 CV_EXPORTS void max(const GpuMat& src1, double src2, GpuMat& dst, const Stream& stream);
\r
535 ////////////////////////////// Image processing //////////////////////////////
\r
537 //! DST[x,y] = SRC[xmap[x,y],ymap[x,y]] with bilinear interpolation.
\r
538 //! supports CV_8UC1, CV_8UC3 source types and CV_32FC1 map type
\r
539 CV_EXPORTS void remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap);
\r
541 //! Does mean shift filtering on GPU.
\r
542 CV_EXPORTS void meanShiftFiltering(const GpuMat& src, GpuMat& dst, int sp, int sr,
\r
543 TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
\r
545 //! Does mean shift procedure on GPU.
\r
546 CV_EXPORTS void meanShiftProc(const GpuMat& src, GpuMat& dstr, GpuMat& dstsp, int sp, int sr,
\r
547 TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
\r
549 //! Does mean shift segmentation with elimiation of small regions.
\r
550 CV_EXPORTS void meanShiftSegmentation(const GpuMat& src, Mat& dst, int sp, int sr, int minsize,
\r
551 TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
\r
553 //! Does coloring of disparity image: [0..ndisp) -> [0..240, 1, 1] in HSV.
\r
554 //! Supported types of input disparity: CV_8U, CV_16S.
\r
555 //! Output disparity has CV_8UC4 type in BGRA format (alpha = 255).
\r
556 CV_EXPORTS void drawColorDisp(const GpuMat& src_disp, GpuMat& dst_disp, int ndisp);
\r
558 CV_EXPORTS void drawColorDisp(const GpuMat& src_disp, GpuMat& dst_disp, int ndisp, const Stream& stream);
\r
560 //! Reprojects disparity image to 3D space.
\r
561 //! Supports CV_8U and CV_16S types of input disparity.
\r
562 //! The output is a 4-channel floating-point (CV_32FC4) matrix.
\r
563 //! Each element of this matrix will contain the 3D coordinates of the point (x,y,z,1), computed from the disparity map.
\r
564 //! Q is the 4x4 perspective transformation matrix that can be obtained with cvStereoRectify.
\r
565 CV_EXPORTS void reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q);
\r
567 CV_EXPORTS void reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q, const Stream& stream);
\r
569 //! converts image from one color space to another
\r
570 CV_EXPORTS void cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn = 0);
\r
572 CV_EXPORTS void cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn, const Stream& stream);
\r
574 //! applies fixed threshold to the image.
\r
575 //! Now supports only THRESH_TRUNC threshold type and one channels float source.
\r
576 CV_EXPORTS double threshold(const GpuMat& src, GpuMat& dst, double thresh);
\r
578 //! resizes the image
\r
579 //! Supports INTER_NEAREST, INTER_LINEAR
\r
580 //! supports CV_8UC1, CV_8UC4 types
\r
581 CV_EXPORTS void resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx=0, double fy=0, int interpolation = INTER_LINEAR);
\r
583 //! warps the image using affine transformation
\r
584 //! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
\r
585 CV_EXPORTS void warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR);
\r
587 //! warps the image using perspective transformation
\r
588 //! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
\r
589 CV_EXPORTS void warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR);
\r
591 //! rotate 8bit single or four channel image
\r
592 //! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
\r
593 //! supports CV_8UC1, CV_8UC4 types
\r
594 CV_EXPORTS void rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift = 0, double yShift = 0, int interpolation = INTER_LINEAR);
\r
596 //! copies 2D array to a larger destination array and pads borders with user-specifiable constant
\r
597 //! supports CV_8UC1, CV_8UC4, CV_32SC1 and CV_32FC1 types
\r
598 CV_EXPORTS void copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, const Scalar& value = Scalar());
\r
600 //! computes the integral image
\r
601 //! sum will have CV_32S type, but will contain unsigned int values
\r
602 //! supports only CV_8UC1 source type
\r
603 CV_EXPORTS void integral(const GpuMat& src, GpuMat& sum);
\r
605 //! computes the integral image and integral for the squared image
\r
606 //! sum will have CV_32S type, sqsum - CV32F type
\r
607 //! supports only CV_8UC1 source type
\r
608 CV_EXPORTS void integral(const GpuMat& src, GpuMat& sum, GpuMat& sqsum);
\r
610 //! computes squared integral image
\r
611 //! result matrix will have 64F type, but will contain 64U values
\r
612 //! supports source images of 8UC1 type only
\r
613 CV_EXPORTS void sqrIntegral(const GpuMat& src, GpuMat& sqsum);
\r
615 //! computes vertical sum, supports only CV_32FC1 images
\r
616 CV_EXPORTS void columnSum(const GpuMat& src, GpuMat& sum);
\r
618 //! computes the standard deviation of integral images
\r
619 //! supports only CV_32SC1 source type and CV_32FC1 sqr type
\r
620 //! output will have CV_32FC1 type
\r
621 CV_EXPORTS void rectStdDev(const GpuMat& src, const GpuMat& sqr, GpuMat& dst, const Rect& rect);
\r
623 //! applies Canny edge detector and produces the edge map
\r
624 //! supprots only CV_8UC1 source type
\r
625 //! disabled until fix crash
\r
626 CV_EXPORTS void Canny(const GpuMat& image, GpuMat& edges, double threshold1, double threshold2, int apertureSize = 3);
\r
628 //! computes Harris cornerness criteria at each image pixel
\r
629 CV_EXPORTS void cornerHarris(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, double k, int borderType=BORDER_REFLECT101);
\r
631 //! computes minimum eigen value of 2x2 derivative covariation matrix at each pixel - the cornerness criteria
\r
632 CV_EXPORTS void cornerMinEigenVal(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, int borderType=BORDER_REFLECT101);
\r
634 //! performs per-element multiplication of two full (not packed) Fourier spectrums
\r
635 //! supports 32FC2 matrixes only (interleaved format)
\r
636 CV_EXPORTS void mulSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flags, bool conjB=false);
\r
638 //! performs per-element multiplication of two full (not packed) Fourier spectrums
\r
639 //! supports 32FC2 matrixes only (interleaved format)
\r
640 CV_EXPORTS void mulAndScaleSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flags,
\r
641 float scale, bool conjB=false);
\r
643 //! Performs a forward or inverse discrete Fourier transform (1D or 2D) of floating point matrix.
\r
644 //! Param dft_size is the size of DFT transform.
\r
646 //! If the source matrix is not continous, then additional copy will be done,
\r
647 //! so to avoid copying ensure the source matrix is continous one. If you want to use
\r
648 //! preallocated output ensure it is continuous too, otherwise it will be reallocated.
\r
650 //! Being implemented via CUFFT real-to-complex transform result contains only non-redundant values
\r
651 //! in CUFFT's format. Result as full complex matrix for such kind of transform cannot be retrieved.
\r
653 //! For complex-to-real transform it is assumed that the source matrix is packed in CUFFT's format.
\r
654 CV_EXPORTS void dft(const GpuMat& src, GpuMat& dst, Size dft_size, int flags=0);
\r
656 //! computes convolution (or cross-correlation) of two images using discrete Fourier transform
\r
657 //! supports source images of 32FC1 type only
\r
658 //! result matrix will have 32FC1 type
\r
659 CV_EXPORTS void convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result,
\r
662 struct CV_EXPORTS ConvolveBuf;
\r
664 //! buffered version
\r
665 CV_EXPORTS void convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result,
\r
666 bool ccorr, ConvolveBuf& buf);
\r
668 struct CV_EXPORTS ConvolveBuf
\r
671 ConvolveBuf(Size image_size, Size templ_size)
\r
672 { create(image_size, templ_size); }
\r
673 void create(Size image_size, Size templ_size);
\r
676 static Size estimateBlockSize(Size result_size, Size templ_size);
\r
677 friend void convolve(const GpuMat&, const GpuMat&, GpuMat&, bool, ConvolveBuf&);
\r
684 GpuMat image_spect, templ_spect, result_spect;
\r
685 GpuMat image_block, templ_block, result_data;
\r
688 //! computes the proximity map for the raster template and the image where the template is searched for
\r
689 CV_EXPORTS void matchTemplate(const GpuMat& image, const GpuMat& templ, GpuMat& result, int method);
\r
692 ////////////////////////////// Matrix reductions //////////////////////////////
\r
694 //! computes mean value and standard deviation of all or selected array elements
\r
695 //! supports only CV_8UC1 type
\r
696 CV_EXPORTS void meanStdDev(const GpuMat& mtx, Scalar& mean, Scalar& stddev);
\r
698 //! computes norm of array
\r
699 //! supports NORM_INF, NORM_L1, NORM_L2
\r
700 //! supports only CV_8UC1 type
\r
701 CV_EXPORTS double norm(const GpuMat& src1, int normType=NORM_L2);
\r
703 //! computes norm of the difference between two arrays
\r
704 //! supports NORM_INF, NORM_L1, NORM_L2
\r
705 //! supports only CV_8UC1 type
\r
706 CV_EXPORTS double norm(const GpuMat& src1, const GpuMat& src2, int normType=NORM_L2);
\r
708 //! computes sum of array elements
\r
709 //! supports only single channel images
\r
710 CV_EXPORTS Scalar sum(const GpuMat& src);
\r
712 //! computes sum of array elements
\r
713 //! supports only single channel images
\r
714 CV_EXPORTS Scalar sum(const GpuMat& src, GpuMat& buf);
\r
716 //! computes squared sum of array elements
\r
717 //! supports only single channel images
\r
718 CV_EXPORTS Scalar sqrSum(const GpuMat& src);
\r
720 //! computes squared sum of array elements
\r
721 //! supports only single channel images
\r
722 CV_EXPORTS Scalar sqrSum(const GpuMat& src, GpuMat& buf);
\r
724 //! finds global minimum and maximum array elements and returns their values
\r
725 CV_EXPORTS void minMax(const GpuMat& src, double* minVal, double* maxVal=0, const GpuMat& mask=GpuMat());
\r
727 //! finds global minimum and maximum array elements and returns their values
\r
728 CV_EXPORTS void minMax(const GpuMat& src, double* minVal, double* maxVal, const GpuMat& mask, GpuMat& buf);
\r
730 //! finds global minimum and maximum array elements and returns their values with locations
\r
731 CV_EXPORTS void minMaxLoc(const GpuMat& src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0,
\r
732 const GpuMat& mask=GpuMat());
\r
734 //! finds global minimum and maximum array elements and returns their values with locations
\r
735 CV_EXPORTS void minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point* minLoc, Point* maxLoc,
\r
736 const GpuMat& mask, GpuMat& valbuf, GpuMat& locbuf);
\r
738 //! counts non-zero array elements
\r
739 CV_EXPORTS int countNonZero(const GpuMat& src);
\r
741 //! counts non-zero array elements
\r
742 CV_EXPORTS int countNonZero(const GpuMat& src, GpuMat& buf);
\r
745 //////////////////////////////// Filter Engine ////////////////////////////////
\r
748 The Base Class for 1D or Row-wise Filters
\r
750 This is the base class for linear or non-linear filters that process 1D data.
\r
751 In particular, such filters are used for the "horizontal" filtering parts in separable filters.
\r
753 class CV_EXPORTS BaseRowFilter_GPU
\r
756 BaseRowFilter_GPU(int ksize_, int anchor_) : ksize(ksize_), anchor(anchor_) {}
\r
757 virtual ~BaseRowFilter_GPU() {}
\r
758 virtual void operator()(const GpuMat& src, GpuMat& dst) = 0;
\r
763 The Base Class for Column-wise Filters
\r
765 This is the base class for linear or non-linear filters that process columns of 2D arrays.
\r
766 Such filters are used for the "vertical" filtering parts in separable filters.
\r
768 class CV_EXPORTS BaseColumnFilter_GPU
\r
771 BaseColumnFilter_GPU(int ksize_, int anchor_) : ksize(ksize_), anchor(anchor_) {}
\r
772 virtual ~BaseColumnFilter_GPU() {}
\r
773 virtual void operator()(const GpuMat& src, GpuMat& dst) = 0;
\r
778 The Base Class for Non-Separable 2D Filters.
\r
780 This is the base class for linear or non-linear 2D filters.
\r
782 class CV_EXPORTS BaseFilter_GPU
\r
785 BaseFilter_GPU(const Size& ksize_, const Point& anchor_) : ksize(ksize_), anchor(anchor_) {}
\r
786 virtual ~BaseFilter_GPU() {}
\r
787 virtual void operator()(const GpuMat& src, GpuMat& dst) = 0;
\r
793 The Base Class for Filter Engine.
\r
795 The class can be used to apply an arbitrary filtering operation to an image.
\r
796 It contains all the necessary intermediate buffers.
\r
798 class CV_EXPORTS FilterEngine_GPU
\r
801 virtual ~FilterEngine_GPU() {}
\r
803 virtual void apply(const GpuMat& src, GpuMat& dst, Rect roi = Rect(0,0,-1,-1)) = 0;
\r
806 //! returns the non-separable filter engine with the specified filter
\r
807 CV_EXPORTS Ptr<FilterEngine_GPU> createFilter2D_GPU(const Ptr<BaseFilter_GPU> filter2D, int srcType, int dstType);
\r
809 //! returns the separable filter engine with the specified filters
\r
810 CV_EXPORTS Ptr<FilterEngine_GPU> createSeparableFilter_GPU(const Ptr<BaseRowFilter_GPU>& rowFilter,
\r
811 const Ptr<BaseColumnFilter_GPU>& columnFilter, int srcType, int bufType, int dstType);
\r
813 //! returns horizontal 1D box filter
\r
814 //! supports only CV_8UC1 source type and CV_32FC1 sum type
\r
815 CV_EXPORTS Ptr<BaseRowFilter_GPU> getRowSumFilter_GPU(int srcType, int sumType, int ksize, int anchor = -1);
\r
817 //! returns vertical 1D box filter
\r
818 //! supports only CV_8UC1 sum type and CV_32FC1 dst type
\r
819 CV_EXPORTS Ptr<BaseColumnFilter_GPU> getColumnSumFilter_GPU(int sumType, int dstType, int ksize, int anchor = -1);
\r
821 //! returns 2D box filter
\r
822 //! supports CV_8UC1 and CV_8UC4 source type, dst type must be the same as source type
\r
823 CV_EXPORTS Ptr<BaseFilter_GPU> getBoxFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1, -1));
\r
825 //! returns box filter engine
\r
826 CV_EXPORTS Ptr<FilterEngine_GPU> createBoxFilter_GPU(int srcType, int dstType, const Size& ksize,
\r
827 const Point& anchor = Point(-1,-1));
\r
829 //! returns 2D morphological filter
\r
830 //! only MORPH_ERODE and MORPH_DILATE are supported
\r
831 //! supports CV_8UC1 and CV_8UC4 types
\r
832 //! kernel must have CV_8UC1 type, one rows and cols == ksize.width * ksize.height
\r
833 CV_EXPORTS Ptr<BaseFilter_GPU> getMorphologyFilter_GPU(int op, int type, const Mat& kernel, const Size& ksize,
\r
834 Point anchor=Point(-1,-1));
\r
836 //! returns morphological filter engine. Only MORPH_ERODE and MORPH_DILATE are supported.
\r
837 CV_EXPORTS Ptr<FilterEngine_GPU> createMorphologyFilter_GPU(int op, int type, const Mat& kernel,
\r
838 const Point& anchor = Point(-1,-1), int iterations = 1);
\r
840 //! returns 2D filter with the specified kernel
\r
841 //! supports CV_8UC1 and CV_8UC4 types
\r
842 CV_EXPORTS Ptr<BaseFilter_GPU> getLinearFilter_GPU(int srcType, int dstType, const Mat& kernel, const Size& ksize,
\r
843 Point anchor = Point(-1, -1));
\r
845 //! returns the non-separable linear filter engine
\r
846 CV_EXPORTS Ptr<FilterEngine_GPU> createLinearFilter_GPU(int srcType, int dstType, const Mat& kernel,
\r
847 const Point& anchor = Point(-1,-1));
\r
849 //! returns the primitive row filter with the specified kernel.
\r
850 //! supports only CV_8UC1, CV_8UC4, CV_16SC1, CV_16SC2, CV_32SC1, CV_32FC1 source type.
\r
851 //! there are two version of algorithm: NPP and OpenCV.
\r
852 //! NPP calls when srcType == CV_8UC1 or srcType == CV_8UC4 and bufType == srcType,
\r
853 //! otherwise calls OpenCV version.
\r
854 //! NPP supports only BORDER_CONSTANT border type.
\r
855 //! OpenCV version supports only CV_32F as buffer depth and
\r
856 //! BORDER_REFLECT101, BORDER_REPLICATE and BORDER_CONSTANT border types.
\r
857 CV_EXPORTS Ptr<BaseRowFilter_GPU> getLinearRowFilter_GPU(int srcType, int bufType, const Mat& rowKernel,
\r
858 int anchor = -1, int borderType = BORDER_CONSTANT);
\r
860 //! returns the primitive column filter with the specified kernel.
\r
861 //! supports only CV_8UC1, CV_8UC4, CV_16SC1, CV_16SC2, CV_32SC1, CV_32FC1 dst type.
\r
862 //! there are two version of algorithm: NPP and OpenCV.
\r
863 //! NPP calls when dstType == CV_8UC1 or dstType == CV_8UC4 and bufType == dstType,
\r
864 //! otherwise calls OpenCV version.
\r
865 //! NPP supports only BORDER_CONSTANT border type.
\r
866 //! OpenCV version supports only CV_32F as buffer depth and
\r
867 //! BORDER_REFLECT101, BORDER_REPLICATE and BORDER_CONSTANT border types.
\r
868 CV_EXPORTS Ptr<BaseColumnFilter_GPU> getLinearColumnFilter_GPU(int bufType, int dstType, const Mat& columnKernel,
\r
869 int anchor = -1, int borderType = BORDER_CONSTANT);
\r
871 //! returns the separable linear filter engine
\r
872 CV_EXPORTS Ptr<FilterEngine_GPU> createSeparableLinearFilter_GPU(int srcType, int dstType, const Mat& rowKernel,
\r
873 const Mat& columnKernel, const Point& anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT,
\r
874 int columnBorderType = -1);
\r
876 //! returns filter engine for the generalized Sobel operator
\r
877 CV_EXPORTS Ptr<FilterEngine_GPU> createDerivFilter_GPU(int srcType, int dstType, int dx, int dy, int ksize,
\r
878 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
880 //! returns the Gaussian filter engine
\r
881 CV_EXPORTS Ptr<FilterEngine_GPU> createGaussianFilter_GPU(int type, Size ksize, double sigma1, double sigma2 = 0,
\r
882 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
884 //! returns maximum filter
\r
885 CV_EXPORTS Ptr<BaseFilter_GPU> getMaxFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1,-1));
\r
887 //! returns minimum filter
\r
888 CV_EXPORTS Ptr<BaseFilter_GPU> getMinFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1,-1));
\r
890 //! smooths the image using the normalized box filter
\r
891 //! supports CV_8UC1, CV_8UC4 types
\r
892 CV_EXPORTS void boxFilter(const GpuMat& src, GpuMat& dst, int ddepth, Size ksize, Point anchor = Point(-1,-1));
\r
894 //! a synonym for normalized box filter
\r
895 static inline void blur(const GpuMat& src, GpuMat& dst, Size ksize, Point anchor = Point(-1,-1)) { boxFilter(src, dst, -1, ksize, anchor); }
\r
897 //! erodes the image (applies the local minimum operator)
\r
898 CV_EXPORTS void erode( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1);
\r
900 //! dilates the image (applies the local maximum operator)
\r
901 CV_EXPORTS void dilate( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1);
\r
903 //! applies an advanced morphological operation to the image
\r
904 CV_EXPORTS void morphologyEx( const GpuMat& src, GpuMat& dst, int op, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1);
\r
906 //! applies non-separable 2D linear filter to the image
\r
907 CV_EXPORTS void filter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernel, Point anchor=Point(-1,-1));
\r
909 //! applies separable 2D linear filter to the image
\r
910 CV_EXPORTS void sepFilter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernelX, const Mat& kernelY,
\r
911 Point anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
913 //! applies generalized Sobel operator to the image
\r
914 CV_EXPORTS void Sobel(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, int ksize = 3, double scale = 1,
\r
915 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
917 //! applies the vertical or horizontal Scharr operator to the image
\r
918 CV_EXPORTS void Scharr(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, double scale = 1,
\r
919 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
921 //! smooths the image using Gaussian filter.
\r
922 CV_EXPORTS void GaussianBlur(const GpuMat& src, GpuMat& dst, Size ksize, double sigma1, double sigma2 = 0,
\r
923 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
925 //! applies Laplacian operator to the image
\r
926 //! supports only ksize = 1 and ksize = 3
\r
927 CV_EXPORTS void Laplacian(const GpuMat& src, GpuMat& dst, int ddepth, int ksize = 1, double scale = 1);
\r
929 //////////////////////////////// Image Labeling ////////////////////////////////
\r
931 //!performs labeling via graph cuts
\r
932 CV_EXPORTS void graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTransp, GpuMat& top, GpuMat& bottom, GpuMat& labels, GpuMat& buf);
\r
934 ////////////////////////////////// Histograms //////////////////////////////////
\r
936 //! Compute levels with even distribution. levels will have 1 row and nLevels cols and CV_32SC1 type.
\r
937 CV_EXPORTS void evenLevels(GpuMat& levels, int nLevels, int lowerLevel, int upperLevel);
\r
938 //! Calculates histogram with evenly distributed bins for signle channel source.
\r
939 //! Supports CV_8UC1, CV_16UC1 and CV_16SC1 source types.
\r
940 //! Output hist will have one row and histSize cols and CV_32SC1 type.
\r
941 CV_EXPORTS void histEven(const GpuMat& src, GpuMat& hist, int histSize, int lowerLevel, int upperLevel);
\r
942 //! Calculates histogram with evenly distributed bins for four-channel source.
\r
943 //! All channels of source are processed separately.
\r
944 //! Supports CV_8UC4, CV_16UC4 and CV_16SC4 source types.
\r
945 //! Output hist[i] will have one row and histSize[i] cols and CV_32SC1 type.
\r
946 CV_EXPORTS void histEven(const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4]);
\r
947 //! Calculates histogram with bins determined by levels array.
\r
948 //! levels must have one row and CV_32SC1 type if source has integer type or CV_32FC1 otherwise.
\r
949 //! Supports CV_8UC1, CV_16UC1, CV_16SC1 and CV_32FC1 source types.
\r
950 //! Output hist will have one row and (levels.cols-1) cols and CV_32SC1 type.
\r
951 CV_EXPORTS void histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels);
\r
952 //! Calculates histogram with bins determined by levels array.
\r
953 //! All levels must have one row and CV_32SC1 type if source has integer type or CV_32FC1 otherwise.
\r
954 //! All channels of source are processed separately.
\r
955 //! Supports CV_8UC4, CV_16UC4, CV_16SC4 and CV_32FC4 source types.
\r
956 //! Output hist[i] will have one row and (levels[i].cols-1) cols and CV_32SC1 type.
\r
957 CV_EXPORTS void histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4]);
\r
959 //////////////////////////////// StereoBM_GPU ////////////////////////////////
\r
961 class CV_EXPORTS StereoBM_GPU
\r
964 enum { BASIC_PRESET = 0, PREFILTER_XSOBEL = 1 };
\r
966 enum { DEFAULT_NDISP = 64, DEFAULT_WINSZ = 19 };
\r
968 //! the default constructor
\r
970 //! the full constructor taking the camera-specific preset, number of disparities and the SAD window size. ndisparities must be multiple of 8.
\r
971 StereoBM_GPU(int preset, int ndisparities = DEFAULT_NDISP, int winSize = DEFAULT_WINSZ);
\r
973 //! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair
\r
974 //! Output disparity has CV_8U type.
\r
975 void operator() ( const GpuMat& left, const GpuMat& right, GpuMat& disparity);
\r
978 void operator() ( const GpuMat& left, const GpuMat& right, GpuMat& disparity, const Stream & stream);
\r
980 //! Some heuristics that tries to estmate
\r
981 // if current GPU will be faster then CPU in this algorithm.
\r
982 // It queries current active device.
\r
983 static bool checkIfGpuCallReasonable();
\r
989 // If avergeTexThreshold == 0 => post procesing is disabled
\r
990 // If avergeTexThreshold != 0 then disparity is set 0 in each point (x,y) where for left image
\r
991 // SumOfHorizontalGradiensInWindow(x, y, winSize) < (winSize * winSize) * avergeTexThreshold
\r
992 // i.e. input left image is low textured.
\r
993 float avergeTexThreshold;
\r
995 GpuMat minSSD, leBuf, riBuf;
\r
998 ////////////////////////// StereoBeliefPropagation ///////////////////////////
\r
999 // "Efficient Belief Propagation for Early Vision"
\r
1002 class CV_EXPORTS StereoBeliefPropagation
\r
1005 enum { DEFAULT_NDISP = 64 };
\r
1006 enum { DEFAULT_ITERS = 5 };
\r
1007 enum { DEFAULT_LEVELS = 5 };
\r
1009 static void estimateRecommendedParams(int width, int height, int& ndisp, int& iters, int& levels);
\r
1011 //! the default constructor
\r
1012 explicit StereoBeliefPropagation(int ndisp = DEFAULT_NDISP,
\r
1013 int iters = DEFAULT_ITERS,
\r
1014 int levels = DEFAULT_LEVELS,
\r
1015 int msg_type = CV_32F);
\r
1017 //! the full constructor taking the number of disparities, number of BP iterations on each level,
\r
1018 //! number of levels, truncation of data cost, data weight,
\r
1019 //! truncation of discontinuity cost and discontinuity single jump
\r
1020 //! DataTerm = data_weight * min(fabs(I2-I1), max_data_term)
\r
1021 //! DiscTerm = min(disc_single_jump * fabs(f1-f2), max_disc_term)
\r
1022 //! please see paper for more details
\r
1023 StereoBeliefPropagation(int ndisp, int iters, int levels,
\r
1024 float max_data_term, float data_weight,
\r
1025 float max_disc_term, float disc_single_jump,
\r
1026 int msg_type = CV_32F);
\r
1028 //! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair,
\r
1029 //! if disparity is empty output type will be CV_16S else output type will be disparity.type().
\r
1030 void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity);
\r
1033 void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream);
\r
1036 //! version for user specified data term
\r
1037 void operator()(const GpuMat& data, GpuMat& disparity);
\r
1038 void operator()(const GpuMat& data, GpuMat& disparity, Stream& stream);
\r
1045 float max_data_term;
\r
1046 float data_weight;
\r
1047 float max_disc_term;
\r
1048 float disc_single_jump;
\r
1052 GpuMat u, d, l, r, u2, d2, l2, r2;
\r
1053 std::vector<GpuMat> datas;
\r
1057 /////////////////////////// StereoConstantSpaceBP ///////////////////////////
\r
1058 // "A Constant-Space Belief Propagation Algorithm for Stereo Matching"
\r
1059 // Qingxiong Yang, Liang Wang
\86, Narendra Ahuja
\r
1060 // http://vision.ai.uiuc.edu/~qyang6/
\r
1062 class CV_EXPORTS StereoConstantSpaceBP
\r
1065 enum { DEFAULT_NDISP = 128 };
\r
1066 enum { DEFAULT_ITERS = 8 };
\r
1067 enum { DEFAULT_LEVELS = 4 };
\r
1068 enum { DEFAULT_NR_PLANE = 4 };
\r
1070 static void estimateRecommendedParams(int width, int height, int& ndisp, int& iters, int& levels, int& nr_plane);
\r
1072 //! the default constructor
\r
1073 explicit StereoConstantSpaceBP(int ndisp = DEFAULT_NDISP,
\r
1074 int iters = DEFAULT_ITERS,
\r
1075 int levels = DEFAULT_LEVELS,
\r
1076 int nr_plane = DEFAULT_NR_PLANE,
\r
1077 int msg_type = CV_32F);
\r
1079 //! the full constructor taking the number of disparities, number of BP iterations on each level,
\r
1080 //! number of levels, number of active disparity on the first level, truncation of data cost, data weight,
\r
1081 //! truncation of discontinuity cost, discontinuity single jump and minimum disparity threshold
\r
1082 StereoConstantSpaceBP(int ndisp, int iters, int levels, int nr_plane,
\r
1083 float max_data_term, float data_weight, float max_disc_term, float disc_single_jump,
\r
1084 int min_disp_th = 0,
\r
1085 int msg_type = CV_32F);
\r
1087 //! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair,
\r
1088 //! if disparity is empty output type will be CV_16S else output type will be disparity.type().
\r
1089 void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity);
\r
1092 void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream);
\r
1101 float max_data_term;
\r
1102 float data_weight;
\r
1103 float max_disc_term;
\r
1104 float disc_single_jump;
\r
1110 bool use_local_init_data_cost;
\r
1112 GpuMat u[2], d[2], l[2], r[2];
\r
1113 GpuMat disp_selected_pyr[2];
\r
1116 GpuMat data_cost_selected;
\r
1123 /////////////////////////// DisparityBilateralFilter ///////////////////////////
\r
1124 // Disparity map refinement using joint bilateral filtering given a single color image.
\r
1125 // Qingxiong Yang, Liang Wang
\86, Narendra Ahuja
\r
1126 // http://vision.ai.uiuc.edu/~qyang6/
\r
1128 class CV_EXPORTS DisparityBilateralFilter
\r
1131 enum { DEFAULT_NDISP = 64 };
\r
1132 enum { DEFAULT_RADIUS = 3 };
\r
1133 enum { DEFAULT_ITERS = 1 };
\r
1135 //! the default constructor
\r
1136 explicit DisparityBilateralFilter(int ndisp = DEFAULT_NDISP, int radius = DEFAULT_RADIUS, int iters = DEFAULT_ITERS);
\r
1138 //! the full constructor taking the number of disparities, filter radius,
\r
1139 //! number of iterations, truncation of data continuity, truncation of disparity continuity
\r
1140 //! and filter range sigma
\r
1141 DisparityBilateralFilter(int ndisp, int radius, int iters, float edge_threshold, float max_disc_threshold, float sigma_range);
\r
1143 //! the disparity map refinement operator. Refine disparity map using joint bilateral filtering given a single color image.
\r
1144 //! disparity must have CV_8U or CV_16S type, image must have CV_8UC1 or CV_8UC3 type.
\r
1145 void operator()(const GpuMat& disparity, const GpuMat& image, GpuMat& dst);
\r
1148 void operator()(const GpuMat& disparity, const GpuMat& image, GpuMat& dst, Stream& stream);
\r
1155 float edge_threshold;
\r
1156 float max_disc_threshold;
\r
1157 float sigma_range;
\r
1159 GpuMat table_color;
\r
1160 GpuMat table_space;
\r
1164 //////////////// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector //////////////
\r
1166 struct CV_EXPORTS HOGDescriptor
\r
1169 enum { DEFAULT_WIN_SIGMA = -1 };
\r
1170 enum { DEFAULT_NLEVELS = 64 };
\r
1171 enum { DESCR_FORMAT_ROW_BY_ROW, DESCR_FORMAT_COL_BY_COL };
\r
1173 HOGDescriptor(Size win_size=Size(64, 128), Size block_size=Size(16, 16),
\r
1174 Size block_stride=Size(8, 8), Size cell_size=Size(8, 8),
\r
1175 int nbins=9, double win_sigma=DEFAULT_WIN_SIGMA,
\r
1176 double threshold_L2hys=0.2, bool gamma_correction=true,
\r
1177 int nlevels=DEFAULT_NLEVELS);
\r
1179 size_t getDescriptorSize() const;
\r
1180 size_t getBlockHistogramSize() const;
\r
1182 void setSVMDetector(const vector<float>& detector);
\r
1184 static vector<float> getDefaultPeopleDetector();
\r
1185 static vector<float> getPeopleDetector48x96();
\r
1186 static vector<float> getPeopleDetector64x128();
\r
1188 void detect(const GpuMat& img, vector<Point>& found_locations,
\r
1189 double hit_threshold=0, Size win_stride=Size(),
\r
1190 Size padding=Size());
\r
1192 void detectMultiScale(const GpuMat& img, vector<Rect>& found_locations,
\r
1193 double hit_threshold=0, Size win_stride=Size(),
\r
1194 Size padding=Size(), double scale0=1.05,
\r
1195 int group_threshold=2);
\r
1197 void getDescriptors(const GpuMat& img, Size win_stride,
\r
1198 GpuMat& descriptors,
\r
1199 int descr_format=DESCR_FORMAT_COL_BY_COL);
\r
1203 Size block_stride;
\r
1207 double threshold_L2hys;
\r
1208 bool gamma_correction;
\r
1212 void computeBlockHistograms(const GpuMat& img);
\r
1213 void computeGradient(const GpuMat& img, GpuMat& grad, GpuMat& qangle);
\r
1215 double getWinSigma() const;
\r
1216 bool checkDetectorSize() const;
\r
1218 static int numPartsWithin(int size, int part_size, int stride);
\r
1219 static Size numPartsWithin(Size size, Size part_size, Size stride);
\r
1221 // Coefficients of the separating plane
\r
1225 // Results of the last classification step
\r
1229 // Results of the last histogram evaluation step
\r
1230 GpuMat block_hists;
\r
1232 // Gradients conputation results
\r
1233 GpuMat grad, qangle;
\r
1237 ////////////////////////////////// BruteForceMatcher //////////////////////////////////
\r
1239 class CV_EXPORTS BruteForceMatcher_GPU_base
\r
1242 enum DistType {L1Dist = 0, L2Dist};
\r
1244 explicit BruteForceMatcher_GPU_base(DistType distType = L2Dist);
\r
1246 // Add descriptors to train descriptor collection.
\r
1247 void add(const std::vector<GpuMat>& descCollection);
\r
1249 // Get train descriptors collection.
\r
1250 const std::vector<GpuMat>& getTrainDescriptors() const;
\r
1252 // Clear train descriptors collection.
\r
1255 // Return true if there are not train descriptors in collection.
\r
1256 bool empty() const;
\r
1258 // Return true if the matcher supports mask in match methods.
\r
1259 bool isMaskSupported() const;
\r
1261 // Find one best match for each query descriptor.
\r
1262 // trainIdx.at<int>(0, queryIdx) will contain best train index for queryIdx
\r
1263 // distance.at<float>(0, queryIdx) will contain distance
\r
1264 void matchSingle(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1265 GpuMat& trainIdx, GpuMat& distance,
\r
1266 const GpuMat& mask = GpuMat());
\r
1268 // Download trainIdx and distance to CPU vector with DMatch
\r
1269 static void matchDownload(const GpuMat& trainIdx, const GpuMat& distance, std::vector<DMatch>& matches);
\r
1271 // Find one best match for each query descriptor.
\r
1272 void match(const GpuMat& queryDescs, const GpuMat& trainDescs, std::vector<DMatch>& matches,
\r
1273 const GpuMat& mask = GpuMat());
\r
1275 // Make gpu collection of trains and masks in suitable format for matchCollection function
\r
1276 void makeGpuCollection(GpuMat& trainCollection, GpuMat& maskCollection,
\r
1277 const vector<GpuMat>& masks = std::vector<GpuMat>());
\r
1279 // Find one best match from train collection for each query descriptor.
\r
1280 // trainIdx.at<int>(0, queryIdx) will contain best train index for queryIdx
\r
1281 // imgIdx.at<int>(0, queryIdx) will contain best image index for queryIdx
\r
1282 // distance.at<float>(0, queryIdx) will contain distance
\r
1283 void matchCollection(const GpuMat& queryDescs, const GpuMat& trainCollection,
\r
1284 GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance,
\r
1285 const GpuMat& maskCollection);
\r
1287 // Download trainIdx, imgIdx and distance to CPU vector with DMatch
\r
1288 static void matchDownload(const GpuMat& trainIdx, GpuMat& imgIdx, const GpuMat& distance,
\r
1289 std::vector<DMatch>& matches);
\r
1291 // Find one best match from train collection for each query descriptor.
\r
1292 void match(const GpuMat& queryDescs, std::vector<DMatch>& matches,
\r
1293 const std::vector<GpuMat>& masks = std::vector<GpuMat>());
\r
1295 // Find k best matches for each query descriptor (in increasing order of distances).
\r
1296 // trainIdx.at<int>(queryIdx, i) will contain index of i'th best trains (i < k).
\r
1297 // distance.at<float>(queryIdx, i) will contain distance.
\r
1298 // allDist is a buffer to store all distance between query descriptors and train descriptors
\r
1299 // it have size (nQuery,nTrain) and CV_32F type
\r
1300 // allDist.at<float>(queryIdx, trainIdx) will contain FLT_MAX, if trainIdx is one from k best,
\r
1301 // otherwise it will contain distance between queryIdx and trainIdx descriptors
\r
1302 void knnMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1303 GpuMat& trainIdx, GpuMat& distance, GpuMat& allDist, int k, const GpuMat& mask = GpuMat());
\r
1305 // Download trainIdx and distance to CPU vector with DMatch
\r
1306 // compactResult is used when mask is not empty. If compactResult is false matches
\r
1307 // vector will have the same size as queryDescriptors rows. If compactResult is true
\r
1308 // matches vector will not contain matches for fully masked out query descriptors.
\r
1309 static void knnMatchDownload(const GpuMat& trainIdx, const GpuMat& distance,
\r
1310 std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
\r
1312 // Find k best matches for each query descriptor (in increasing order of distances).
\r
1313 // compactResult is used when mask is not empty. If compactResult is false matches
\r
1314 // vector will have the same size as queryDescriptors rows. If compactResult is true
\r
1315 // matches vector will not contain matches for fully masked out query descriptors.
\r
1316 void knnMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1317 std::vector< std::vector<DMatch> >& matches, int k, const GpuMat& mask = GpuMat(),
\r
1318 bool compactResult = false);
\r
1320 // Find k best matches for each query descriptor (in increasing order of distances).
\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 void knnMatch(const GpuMat& queryDescs, std::vector< std::vector<DMatch> >& matches, int knn,
\r
1325 const std::vector<GpuMat>& masks = std::vector<GpuMat>(), bool compactResult = false );
\r
1327 // Find best matches for each query descriptor which have distance less than maxDistance.
\r
1328 // nMatches.at<unsigned int>(0, queruIdx) will contain matches count for queryIdx.
\r
1329 // carefully nMatches can be greater than trainIdx.cols - it means that matcher didn't find all matches,
\r
1330 // because it didn't have enough memory.
\r
1331 // trainIdx.at<int>(queruIdx, i) will contain ith train index (i < min(nMatches.at<unsigned int>(0, queruIdx), trainIdx.cols))
\r
1332 // distance.at<int>(queruIdx, i) will contain ith distance (i < min(nMatches.at<unsigned int>(0, queruIdx), trainIdx.cols))
\r
1333 // If trainIdx is empty, then trainIdx and distance will be created with size nQuery x nTrain,
\r
1334 // otherwize user can pass own allocated trainIdx and distance with size nQuery x nMaxMatches
\r
1335 // Matches doesn't sorted.
\r
1336 void radiusMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1337 GpuMat& trainIdx, GpuMat& nMatches, GpuMat& distance, float maxDistance,
\r
1338 const GpuMat& mask = GpuMat());
\r
1340 // Download trainIdx, nMatches and distance to CPU vector with DMatch.
\r
1341 // matches will be sorted in increasing order of distances.
\r
1342 // compactResult is used when mask is not empty. If compactResult is false matches
\r
1343 // vector will have the same size as queryDescriptors rows. If compactResult is true
\r
1344 // matches vector will not contain matches for fully masked out query descriptors.
\r
1345 static void radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& nMatches, const GpuMat& distance,
\r
1346 std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
\r
1348 // Find best matches for each query descriptor which have distance less than maxDistance
\r
1349 // in increasing order of distances).
\r
1350 void radiusMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1351 std::vector< std::vector<DMatch> >& matches, float maxDistance,
\r
1352 const GpuMat& mask = GpuMat(), bool compactResult = false);
\r
1354 // Find best matches from train collection for each query descriptor which have distance less than
\r
1355 // maxDistance (in increasing order of distances).
\r
1356 void radiusMatch(const GpuMat& queryDescs, std::vector< std::vector<DMatch> >& matches, float maxDistance,
\r
1357 const std::vector<GpuMat>& masks = std::vector<GpuMat>(), bool compactResult = false);
\r
1360 DistType distType;
\r
1362 std::vector<GpuMat> trainDescCollection;
\r
1365 template <class Distance>
\r
1366 class CV_EXPORTS BruteForceMatcher_GPU;
\r
1368 template <typename T>
\r
1369 class CV_EXPORTS BruteForceMatcher_GPU< L1<T> > : public BruteForceMatcher_GPU_base
\r
1372 explicit BruteForceMatcher_GPU() : BruteForceMatcher_GPU_base(L1Dist) {}
\r
1373 explicit BruteForceMatcher_GPU(L1<T> /*d*/) : BruteForceMatcher_GPU_base(L1Dist) {}
\r
1375 template <typename T>
\r
1376 class CV_EXPORTS BruteForceMatcher_GPU< L2<T> > : public BruteForceMatcher_GPU_base
\r
1379 explicit BruteForceMatcher_GPU() : BruteForceMatcher_GPU_base(L2Dist) {}
\r
1380 explicit BruteForceMatcher_GPU(L2<T> /*d*/) : BruteForceMatcher_GPU_base(L2Dist) {}
\r
1383 ////////////////////////////////// CascadeClassifier //////////////////////////////////////////
\r
1384 // The cascade classifier class for object detection.
\r
1385 class CV_EXPORTS CascadeClassifier
\r
1388 struct CV_EXPORTS DTreeNode
\r
1391 float threshold; // for ordered features only
\r
1396 struct CV_EXPORTS DTree
\r
1401 struct CV_EXPORTS Stage
\r
1408 enum { BOOST = 0 };
\r
1409 enum { DO_CANNY_PRUNING = 1, SCALE_IMAGE = 2,FIND_BIGGEST_OBJECT = 4, DO_ROUGH_SEARCH = 8 };
\r
1411 CascadeClassifier();
\r
1412 CascadeClassifier(const string& filename);
\r
1413 ~CascadeClassifier();
\r
1415 bool empty() const;
\r
1416 bool load(const string& filename);
\r
1417 bool read(const FileNode& node);
\r
1419 void detectMultiScale( const Mat& image, vector<Rect>& objects, double scaleFactor=1.1,
\r
1420 int minNeighbors=3, int flags=0, Size minSize=Size(), Size maxSize=Size());
\r
1422 bool setImage( Ptr<FeatureEvaluator>&, const Mat& );
\r
1423 int runAt( Ptr<FeatureEvaluator>&, Point );
\r
1425 bool isStumpBased;
\r
1432 vector<Stage> stages;
\r
1433 vector<DTree> classifiers;
\r
1434 vector<DTreeNode> nodes;
\r
1435 vector<float> leaves;
\r
1436 vector<int> subsets;
\r
1438 Ptr<FeatureEvaluator> feval;
\r
1439 Ptr<CvHaarClassifierCascade> oldCascade;
\r
1442 ////////////////////////////////// SURF //////////////////////////////////////////
\r
1444 struct CV_EXPORTS SURFParams_GPU
\r
1446 SURFParams_GPU() :
\r
1450 initialScale(2.f),
\r
1461 featuresRatio(0.01f)
\r
1465 //! The interest operator threshold
\r
1467 //! The number of octaves to process
\r
1469 //! The number of intervals in each octave
\r
1471 //! The scale associated with the first interval of the first octave
\r
1472 float initialScale;
\r
1474 //! mask parameter l_1
\r
1476 //! mask parameter l_2
\r
1478 //! mask parameter l_3
\r
1480 //! mask parameter l_4
\r
1482 //! The amount to scale the edge rejection mask
\r
1484 //! The initial sampling step in pixels.
\r
1487 //! True, if generate 128-len descriptors, false - 64-len descriptors
\r
1490 //! max features = featuresRatio * img.size().srea()
\r
1491 float featuresRatio;
\r
1494 class CV_EXPORTS SURF_GPU : public SURFParams_GPU
\r
1497 //! returns the descriptor size in float's (64 or 128)
\r
1498 int descriptorSize() const;
\r
1500 //! upload host keypoints to device memory
\r
1501 static void uploadKeypoints(const vector<KeyPoint>& keypoints, GpuMat& keypointsGPU);
\r
1502 //! download keypoints from device to host memory
\r
1503 static void downloadKeypoints(const GpuMat& keypointsGPU, vector<KeyPoint>& keypoints);
\r
1505 //! download descriptors from device to host memory
\r
1506 static void downloadDescriptors(const GpuMat& descriptorsGPU, vector<float>& descriptors);
\r
1508 //! finds the keypoints using fast hessian detector used in SURF
\r
1509 //! supports CV_8UC1 images
\r
1510 //! keypoints will have 1 row and type CV_32FC(6)
\r
1511 //! keypoints.at<float[6]>(1, i) contains i'th keypoint
\r
1512 //! format: (x, y, size, response, angle, octave)
\r
1513 void operator()(const GpuMat& img, const GpuMat& mask, GpuMat& keypoints);
\r
1514 //! finds the keypoints and computes their descriptors.
\r
1515 //! Optionally it can compute descriptors for the user-provided keypoints and recompute keypoints direction
\r
1516 void operator()(const GpuMat& img, const GpuMat& mask, GpuMat& keypoints, GpuMat& descriptors,
\r
1517 bool useProvidedKeypoints = false, bool calcOrientation = true);
\r
1519 void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints);
\r
1520 void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, GpuMat& descriptors,
\r
1521 bool useProvidedKeypoints = false, bool calcOrientation = true);
\r
1523 void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, std::vector<float>& descriptors,
\r
1524 bool useProvidedKeypoints = false, bool calcOrientation = true);
\r
1532 GpuMat hessianBuffer;
\r
1533 GpuMat maxPosBuffer;
\r
1534 GpuMat featuresBuffer;
\r
1539 //! Speckle filtering - filters small connected components on diparity image.
\r
1540 //! It sets pixel (x,y) to newVal if it coresponds to small CC with size < maxSpeckleSize.
\r
1541 //! Threshold for border between CC is diffThreshold;
\r
1542 CV_EXPORTS void filterSpeckles( Mat& img, uchar newVal, int maxSpeckleSize, uchar diffThreshold, Mat& buf);
\r
1545 #include "opencv2/gpu/matrix_operations.hpp"
\r
1547 #endif /* __OPENCV_GPU_HPP__ */
\r