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/features2d/features2d.hpp"
\r
51 #include "opencv2/gpu/gpumat.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
64 CV_EXPORTS void setDevice(int device);
\r
65 CV_EXPORTS int getDevice();
\r
67 //! Explicitly destroys and cleans up all resources associated with the current device in the current process.
\r
68 //! Any subsequent API call to this device will reinitialize the device.
\r
69 CV_EXPORTS void resetDevice();
\r
73 FEATURE_SET_COMPUTE_10 = 10,
\r
74 FEATURE_SET_COMPUTE_11 = 11,
\r
75 FEATURE_SET_COMPUTE_12 = 12,
\r
76 FEATURE_SET_COMPUTE_13 = 13,
\r
77 FEATURE_SET_COMPUTE_20 = 20,
\r
78 FEATURE_SET_COMPUTE_21 = 21,
\r
79 GLOBAL_ATOMICS = FEATURE_SET_COMPUTE_11,
\r
80 SHARED_ATOMICS = FEATURE_SET_COMPUTE_12,
\r
81 NATIVE_DOUBLE = FEATURE_SET_COMPUTE_13
\r
84 // Gives information about what GPU archs this OpenCV GPU module was
\r
86 class CV_EXPORTS TargetArchs
\r
89 static bool builtWith(FeatureSet feature_set);
\r
90 static bool has(int major, int minor);
\r
91 static bool hasPtx(int major, int minor);
\r
92 static bool hasBin(int major, int minor);
\r
93 static bool hasEqualOrLessPtx(int major, int minor);
\r
94 static bool hasEqualOrGreater(int major, int minor);
\r
95 static bool hasEqualOrGreaterPtx(int major, int minor);
\r
96 static bool hasEqualOrGreaterBin(int major, int minor);
\r
101 // Gives information about the given GPU
\r
102 class CV_EXPORTS DeviceInfo
\r
105 // Creates DeviceInfo object for the current GPU
\r
106 DeviceInfo() : device_id_(getDevice()) { query(); }
\r
108 // Creates DeviceInfo object for the given GPU
\r
109 DeviceInfo(int device_id) : device_id_(device_id) { query(); }
\r
111 string name() const { return name_; }
\r
113 // Return compute capability versions
\r
114 int majorVersion() const { return majorVersion_; }
\r
115 int minorVersion() const { return minorVersion_; }
\r
117 int multiProcessorCount() const { return multi_processor_count_; }
\r
119 size_t freeMemory() const;
\r
120 size_t totalMemory() const;
\r
122 // Checks whether device supports the given feature
\r
123 bool supports(FeatureSet feature_set) const;
\r
125 // Checks whether the GPU module can be run on the given device
\r
126 bool isCompatible() const;
\r
128 int deviceID() const { return device_id_; }
\r
132 void queryMemory(size_t& free_memory, size_t& total_memory) const;
\r
137 int multi_processor_count_;
\r
142 //////////////////////////////// Error handling ////////////////////////
\r
144 CV_EXPORTS void error(const char *error_string, const char *file, const int line, const char *func);
\r
145 CV_EXPORTS void nppError( int err, const char *file, const int line, const char *func);
\r
147 //////////////////////////////// CudaMem ////////////////////////////////
\r
148 // CudaMem is limited cv::Mat with page locked memory allocation.
\r
149 // Page locked memory is only needed for async and faster coping to GPU.
\r
150 // It is convertable to cv::Mat header without reference counting
\r
151 // so you can use it with other opencv functions.
\r
153 // Page-locks the matrix m memory and maps it for the device(s)
\r
154 CV_EXPORTS void registerPageLocked(Mat& m);
\r
155 // Unmaps the memory of matrix m, and makes it pageable again.
\r
156 CV_EXPORTS void unregisterPageLocked(Mat& m);
\r
158 class CV_EXPORTS CudaMem
\r
161 enum { ALLOC_PAGE_LOCKED = 1, ALLOC_ZEROCOPY = 2, ALLOC_WRITE_COMBINED = 4 };
\r
164 CudaMem(const CudaMem& m);
\r
166 CudaMem(int rows, int cols, int type, int _alloc_type = ALLOC_PAGE_LOCKED);
\r
167 CudaMem(Size size, int type, int alloc_type = ALLOC_PAGE_LOCKED);
\r
170 //! creates from cv::Mat with coping data
\r
171 explicit CudaMem(const Mat& m, int alloc_type = ALLOC_PAGE_LOCKED);
\r
175 CudaMem& operator = (const CudaMem& m);
\r
177 //! returns deep copy of the matrix, i.e. the data is copied
\r
178 CudaMem clone() const;
\r
180 //! allocates new matrix data unless the matrix already has specified size and type.
\r
181 void create(int rows, int cols, int type, int alloc_type = ALLOC_PAGE_LOCKED);
\r
182 void create(Size size, int type, int alloc_type = ALLOC_PAGE_LOCKED);
\r
184 //! decrements reference counter and released memory if needed.
\r
187 //! returns matrix header with disabled reference counting for CudaMem data.
\r
188 Mat createMatHeader() const;
\r
189 operator Mat() const;
\r
191 //! maps host memory into device address space and returns GpuMat header for it. Throws exception if not supported by hardware.
\r
192 GpuMat createGpuMatHeader() const;
\r
193 operator GpuMat() const;
\r
195 //returns if host memory can be mapperd to gpu address space;
\r
196 static bool canMapHostMemory();
\r
198 // Please see cv::Mat for descriptions
\r
199 bool isContinuous() const;
\r
200 size_t elemSize() const;
\r
201 size_t elemSize1() const;
\r
204 int channels() const;
\r
205 size_t step1() const;
\r
207 bool empty() const;
\r
210 // Please see cv::Mat for descriptions
\r
224 //////////////////////////////// CudaStream ////////////////////////////////
\r
225 // Encapculates Cuda Stream. Provides interface for async coping.
\r
226 // Passed to each function that supports async kernel execution.
\r
227 // Reference counting is enabled
\r
229 class CV_EXPORTS Stream
\r
235 Stream(const Stream&);
\r
236 Stream& operator=(const Stream&);
\r
238 bool queryIfComplete();
\r
239 void waitForCompletion();
\r
241 //! downloads asynchronously.
\r
242 // Warning! cv::Mat must point to page locked memory (i.e. to CudaMem data or to its subMat)
\r
243 void enqueueDownload(const GpuMat& src, CudaMem& dst);
\r
244 void enqueueDownload(const GpuMat& src, Mat& dst);
\r
246 //! uploads asynchronously.
\r
247 // Warning! cv::Mat must point to page locked memory (i.e. to CudaMem data or to its ROI)
\r
248 void enqueueUpload(const CudaMem& src, GpuMat& dst);
\r
249 void enqueueUpload(const Mat& src, GpuMat& dst);
\r
251 void enqueueCopy(const GpuMat& src, GpuMat& dst);
\r
253 void enqueueMemSet(GpuMat& src, Scalar val);
\r
254 void enqueueMemSet(GpuMat& src, Scalar val, const GpuMat& mask);
\r
256 // converts matrix type, ex from float to uchar depending on type
\r
257 void enqueueConvert(const GpuMat& src, GpuMat& dst, int type, double a = 1, double b = 0);
\r
259 static Stream& Null();
\r
261 operator bool() const;
\r
270 friend struct StreamAccessor;
\r
272 explicit Stream(Impl* impl);
\r
276 //////////////////////////////// Filter Engine ////////////////////////////////
\r
279 The Base Class for 1D or Row-wise Filters
\r
281 This is the base class for linear or non-linear filters that process 1D data.
\r
282 In particular, such filters are used for the "horizontal" filtering parts in separable filters.
\r
284 class CV_EXPORTS BaseRowFilter_GPU
\r
287 BaseRowFilter_GPU(int ksize_, int anchor_) : ksize(ksize_), anchor(anchor_) {}
\r
288 virtual ~BaseRowFilter_GPU() {}
\r
289 virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null()) = 0;
\r
294 The Base Class for Column-wise Filters
\r
296 This is the base class for linear or non-linear filters that process columns of 2D arrays.
\r
297 Such filters are used for the "vertical" filtering parts in separable filters.
\r
299 class CV_EXPORTS BaseColumnFilter_GPU
\r
302 BaseColumnFilter_GPU(int ksize_, int anchor_) : ksize(ksize_), anchor(anchor_) {}
\r
303 virtual ~BaseColumnFilter_GPU() {}
\r
304 virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null()) = 0;
\r
309 The Base Class for Non-Separable 2D Filters.
\r
311 This is the base class for linear or non-linear 2D filters.
\r
313 class CV_EXPORTS BaseFilter_GPU
\r
316 BaseFilter_GPU(const Size& ksize_, const Point& anchor_) : ksize(ksize_), anchor(anchor_) {}
\r
317 virtual ~BaseFilter_GPU() {}
\r
318 virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null()) = 0;
\r
324 The Base Class for Filter Engine.
\r
326 The class can be used to apply an arbitrary filtering operation to an image.
\r
327 It contains all the necessary intermediate buffers.
\r
329 class CV_EXPORTS FilterEngine_GPU
\r
332 virtual ~FilterEngine_GPU() {}
\r
334 virtual void apply(const GpuMat& src, GpuMat& dst, Rect roi = Rect(0,0,-1,-1), Stream& stream = Stream::Null()) = 0;
\r
337 //! returns the non-separable filter engine with the specified filter
\r
338 CV_EXPORTS Ptr<FilterEngine_GPU> createFilter2D_GPU(const Ptr<BaseFilter_GPU>& filter2D, int srcType, int dstType);
\r
340 //! returns the separable filter engine with the specified filters
\r
341 CV_EXPORTS Ptr<FilterEngine_GPU> createSeparableFilter_GPU(const Ptr<BaseRowFilter_GPU>& rowFilter,
\r
342 const Ptr<BaseColumnFilter_GPU>& columnFilter, int srcType, int bufType, int dstType);
\r
344 //! returns horizontal 1D box filter
\r
345 //! supports only CV_8UC1 source type and CV_32FC1 sum type
\r
346 CV_EXPORTS Ptr<BaseRowFilter_GPU> getRowSumFilter_GPU(int srcType, int sumType, int ksize, int anchor = -1);
\r
348 //! returns vertical 1D box filter
\r
349 //! supports only CV_8UC1 sum type and CV_32FC1 dst type
\r
350 CV_EXPORTS Ptr<BaseColumnFilter_GPU> getColumnSumFilter_GPU(int sumType, int dstType, int ksize, int anchor = -1);
\r
352 //! returns 2D box filter
\r
353 //! supports CV_8UC1 and CV_8UC4 source type, dst type must be the same as source type
\r
354 CV_EXPORTS Ptr<BaseFilter_GPU> getBoxFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1, -1));
\r
356 //! returns box filter engine
\r
357 CV_EXPORTS Ptr<FilterEngine_GPU> createBoxFilter_GPU(int srcType, int dstType, const Size& ksize,
\r
358 const Point& anchor = Point(-1,-1));
\r
360 //! returns 2D morphological filter
\r
361 //! only MORPH_ERODE and MORPH_DILATE are supported
\r
362 //! supports CV_8UC1 and CV_8UC4 types
\r
363 //! kernel must have CV_8UC1 type, one rows and cols == ksize.width * ksize.height
\r
364 CV_EXPORTS Ptr<BaseFilter_GPU> getMorphologyFilter_GPU(int op, int type, const Mat& kernel, const Size& ksize,
\r
365 Point anchor=Point(-1,-1));
\r
367 //! returns morphological filter engine. Only MORPH_ERODE and MORPH_DILATE are supported.
\r
368 CV_EXPORTS Ptr<FilterEngine_GPU> createMorphologyFilter_GPU(int op, int type, const Mat& kernel,
\r
369 const Point& anchor = Point(-1,-1), int iterations = 1);
\r
371 //! returns 2D filter with the specified kernel
\r
372 //! supports CV_8UC1 and CV_8UC4 types
\r
373 CV_EXPORTS Ptr<BaseFilter_GPU> getLinearFilter_GPU(int srcType, int dstType, const Mat& kernel, const Size& ksize,
\r
374 Point anchor = Point(-1, -1));
\r
376 //! returns the non-separable linear filter engine
\r
377 CV_EXPORTS Ptr<FilterEngine_GPU> createLinearFilter_GPU(int srcType, int dstType, const Mat& kernel,
\r
378 const Point& anchor = Point(-1,-1));
\r
380 //! returns the primitive row filter with the specified kernel.
\r
381 //! supports only CV_8UC1, CV_8UC4, CV_16SC1, CV_16SC2, CV_32SC1, CV_32FC1 source type.
\r
382 //! there are two version of algorithm: NPP and OpenCV.
\r
383 //! NPP calls when srcType == CV_8UC1 or srcType == CV_8UC4 and bufType == srcType,
\r
384 //! otherwise calls OpenCV version.
\r
385 //! NPP supports only BORDER_CONSTANT border type.
\r
386 //! OpenCV version supports only CV_32F as buffer depth and
\r
387 //! BORDER_REFLECT101, BORDER_REPLICATE and BORDER_CONSTANT border types.
\r
388 CV_EXPORTS Ptr<BaseRowFilter_GPU> getLinearRowFilter_GPU(int srcType, int bufType, const Mat& rowKernel,
\r
389 int anchor = -1, int borderType = BORDER_CONSTANT);
\r
391 //! returns the primitive column filter with the specified kernel.
\r
392 //! supports only CV_8UC1, CV_8UC4, CV_16SC1, CV_16SC2, CV_32SC1, CV_32FC1 dst type.
\r
393 //! there are two version of algorithm: NPP and OpenCV.
\r
394 //! NPP calls when dstType == CV_8UC1 or dstType == CV_8UC4 and bufType == dstType,
\r
395 //! otherwise calls OpenCV version.
\r
396 //! NPP supports only BORDER_CONSTANT border type.
\r
397 //! OpenCV version supports only CV_32F as buffer depth and
\r
398 //! BORDER_REFLECT101, BORDER_REPLICATE and BORDER_CONSTANT border types.
\r
399 CV_EXPORTS Ptr<BaseColumnFilter_GPU> getLinearColumnFilter_GPU(int bufType, int dstType, const Mat& columnKernel,
\r
400 int anchor = -1, int borderType = BORDER_CONSTANT);
\r
402 //! returns the separable linear filter engine
\r
403 CV_EXPORTS Ptr<FilterEngine_GPU> createSeparableLinearFilter_GPU(int srcType, int dstType, const Mat& rowKernel,
\r
404 const Mat& columnKernel, const Point& anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT,
\r
405 int columnBorderType = -1);
\r
407 //! returns filter engine for the generalized Sobel operator
\r
408 CV_EXPORTS Ptr<FilterEngine_GPU> createDerivFilter_GPU(int srcType, int dstType, int dx, int dy, int ksize,
\r
409 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
411 //! returns the Gaussian filter engine
\r
412 CV_EXPORTS Ptr<FilterEngine_GPU> createGaussianFilter_GPU(int type, Size ksize, double sigma1, double sigma2 = 0,
\r
413 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);
\r
415 //! returns maximum filter
\r
416 CV_EXPORTS Ptr<BaseFilter_GPU> getMaxFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1,-1));
\r
418 //! returns minimum filter
\r
419 CV_EXPORTS Ptr<BaseFilter_GPU> getMinFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1,-1));
\r
421 //! smooths the image using the normalized box filter
\r
422 //! supports CV_8UC1, CV_8UC4 types
\r
423 CV_EXPORTS void boxFilter(const GpuMat& src, GpuMat& dst, int ddepth, Size ksize, Point anchor = Point(-1,-1), Stream& stream = Stream::Null());
\r
425 //! a synonym for normalized box filter
\r
426 static inline void blur(const GpuMat& src, GpuMat& dst, Size ksize, Point anchor = Point(-1,-1), Stream& stream = Stream::Null()) { boxFilter(src, dst, -1, ksize, anchor, stream); }
\r
428 //! erodes the image (applies the local minimum operator)
\r
429 CV_EXPORTS void erode( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1, Stream& stream = Stream::Null());
\r
431 //! dilates the image (applies the local maximum operator)
\r
432 CV_EXPORTS void dilate( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1, Stream& stream = Stream::Null());
\r
434 //! applies an advanced morphological operation to the image
\r
435 CV_EXPORTS void morphologyEx( const GpuMat& src, GpuMat& dst, int op, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1, Stream& stream = Stream::Null());
\r
437 //! applies non-separable 2D linear filter to the image
\r
438 CV_EXPORTS void filter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernel, Point anchor=Point(-1,-1), Stream& stream = Stream::Null());
\r
440 //! applies separable 2D linear filter to the image
\r
441 CV_EXPORTS void sepFilter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernelX, const Mat& kernelY,
\r
442 Point anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1, Stream& stream = Stream::Null());
\r
444 //! applies generalized Sobel operator to the image
\r
445 CV_EXPORTS void Sobel(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, int ksize = 3, double scale = 1,
\r
446 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1, Stream& stream = Stream::Null());
\r
448 //! applies the vertical or horizontal Scharr operator to the image
\r
449 CV_EXPORTS void Scharr(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, double scale = 1,
\r
450 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1, Stream& stream = Stream::Null());
\r
452 //! smooths the image using Gaussian filter.
\r
453 CV_EXPORTS void GaussianBlur(const GpuMat& src, GpuMat& dst, Size ksize, double sigma1, double sigma2 = 0,
\r
454 int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1, Stream& stream = Stream::Null());
\r
456 //! applies Laplacian operator to the image
\r
457 //! supports only ksize = 1 and ksize = 3
\r
458 CV_EXPORTS void Laplacian(const GpuMat& src, GpuMat& dst, int ddepth, int ksize = 1, double scale = 1, Stream& stream = Stream::Null());
\r
461 ////////////////////////////// Arithmetics ///////////////////////////////////
\r
463 //! transposes the matrix
\r
464 //! supports matrix with element size = 1, 4 and 8 bytes (CV_8UC1, CV_8UC4, CV_16UC2, CV_32FC1, etc)
\r
465 CV_EXPORTS void transpose(const GpuMat& src1, GpuMat& dst, Stream& stream = Stream::Null());
\r
467 //! reverses the order of the rows, columns or both in a matrix
\r
468 //! supports CV_8UC1, CV_8UC4 types
\r
469 CV_EXPORTS void flip(const GpuMat& a, GpuMat& b, int flipCode, Stream& stream = Stream::Null());
\r
471 //! transforms 8-bit unsigned integers using lookup table: dst(i)=lut(src(i))
\r
472 //! destination array will have the depth type as lut and the same channels number as source
\r
473 //! supports CV_8UC1, CV_8UC3 types
\r
474 CV_EXPORTS void LUT(const GpuMat& src, const Mat& lut, GpuMat& dst, Stream& stream = Stream::Null());
\r
476 //! makes multi-channel array out of several single-channel arrays
\r
477 CV_EXPORTS void merge(const GpuMat* src, size_t n, GpuMat& dst, Stream& stream = Stream::Null());
\r
479 //! makes multi-channel array out of several single-channel arrays
\r
480 CV_EXPORTS void merge(const vector<GpuMat>& src, GpuMat& dst, Stream& stream = Stream::Null());
\r
482 //! copies each plane of a multi-channel array to a dedicated array
\r
483 CV_EXPORTS void split(const GpuMat& src, GpuMat* dst, Stream& stream = Stream::Null());
\r
485 //! copies each plane of a multi-channel array to a dedicated array
\r
486 CV_EXPORTS void split(const GpuMat& src, vector<GpuMat>& dst, Stream& stream = Stream::Null());
\r
488 //! computes magnitude of complex (x(i).re, x(i).im) vector
\r
489 //! supports only CV_32FC2 type
\r
490 CV_EXPORTS void magnitude(const GpuMat& x, GpuMat& magnitude, Stream& stream = Stream::Null());
\r
492 //! computes squared magnitude of complex (x(i).re, x(i).im) vector
\r
493 //! supports only CV_32FC2 type
\r
494 CV_EXPORTS void magnitudeSqr(const GpuMat& x, GpuMat& magnitude, Stream& stream = Stream::Null());
\r
496 //! computes magnitude of each (x(i), y(i)) vector
\r
497 //! supports only floating-point source
\r
498 CV_EXPORTS void magnitude(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, Stream& stream = Stream::Null());
\r
500 //! computes squared magnitude of each (x(i), y(i)) vector
\r
501 //! supports only floating-point source
\r
502 CV_EXPORTS void magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, Stream& stream = Stream::Null());
\r
504 //! computes angle (angle(i)) of each (x(i), y(i)) vector
\r
505 //! supports only floating-point source
\r
506 CV_EXPORTS void phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees = false, Stream& stream = Stream::Null());
\r
508 //! converts Cartesian coordinates to polar
\r
509 //! supports only floating-point source
\r
510 CV_EXPORTS void cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, GpuMat& angle, bool angleInDegrees = false, Stream& stream = Stream::Null());
\r
512 //! converts polar coordinates to Cartesian
\r
513 //! supports only floating-point source
\r
514 CV_EXPORTS void polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees = false, Stream& stream = Stream::Null());
\r
517 //////////////////////////// Per-element operations ////////////////////////////////////
\r
519 //! adds one matrix to another (c = a + b)
\r
520 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
521 CV_EXPORTS void add(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());
\r
522 //! adds scalar to a matrix (c = a + s)
\r
523 //! supports CV_32FC1 and CV_32FC2 type
\r
524 CV_EXPORTS void add(const GpuMat& a, const Scalar& sc, GpuMat& c, Stream& stream = Stream::Null());
\r
526 //! subtracts one matrix from another (c = a - b)
\r
527 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
528 CV_EXPORTS void subtract(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());
\r
529 //! subtracts scalar from a matrix (c = a - s)
\r
530 //! supports CV_32FC1 and CV_32FC2 type
\r
531 CV_EXPORTS void subtract(const GpuMat& a, const Scalar& sc, GpuMat& c, Stream& stream = Stream::Null());
\r
533 //! computes element-wise product of the two arrays (c = a * b)
\r
534 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
535 CV_EXPORTS void multiply(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());
\r
536 //! multiplies matrix to a scalar (c = a * s)
\r
537 //! supports CV_32FC1 type
\r
538 CV_EXPORTS void multiply(const GpuMat& a, const Scalar& sc, GpuMat& c, Stream& stream = Stream::Null());
\r
540 //! computes element-wise quotient of the two arrays (c = a / b)
\r
541 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
542 CV_EXPORTS void divide(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());
\r
543 //! computes element-wise quotient of matrix and scalar (c = a / s)
\r
544 //! supports CV_32FC1 type
\r
545 CV_EXPORTS void divide(const GpuMat& a, const Scalar& sc, GpuMat& c, Stream& stream = Stream::Null());
\r
547 //! computes exponent of each matrix element (b = e**a)
\r
548 //! supports only CV_32FC1 type
\r
549 CV_EXPORTS void exp(const GpuMat& a, GpuMat& b, Stream& stream = Stream::Null());
\r
551 //! computes power of each matrix element:
\r
552 // (dst(i,j) = pow( src(i,j) , power), if src.type() is integer
\r
553 // (dst(i,j) = pow(fabs(src(i,j)), power), otherwise
\r
554 //! supports all, except depth == CV_64F
\r
555 CV_EXPORTS void pow(const GpuMat& src, double power, GpuMat& dst, Stream& stream = Stream::Null());
\r
557 //! computes natural logarithm of absolute value of each matrix element: b = log(abs(a))
\r
558 //! supports only CV_32FC1 type
\r
559 CV_EXPORTS void log(const GpuMat& a, GpuMat& b, Stream& stream = Stream::Null());
\r
561 //! computes element-wise absolute difference of two arrays (c = abs(a - b))
\r
562 //! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types
\r
563 CV_EXPORTS void absdiff(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());
\r
564 //! computes element-wise absolute difference of array and scalar (c = abs(a - s))
\r
565 //! supports only CV_32FC1 type
\r
566 CV_EXPORTS void absdiff(const GpuMat& a, const Scalar& s, GpuMat& c, Stream& stream = Stream::Null());
\r
568 //! compares elements of two arrays (c = a <cmpop> b)
\r
569 //! supports CV_8UC4, CV_32FC1 types
\r
570 CV_EXPORTS void compare(const GpuMat& a, const GpuMat& b, GpuMat& c, int cmpop, Stream& stream = Stream::Null());
\r
572 //! performs per-elements bit-wise inversion
\r
573 CV_EXPORTS void bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null());
\r
575 //! calculates per-element bit-wise disjunction of two arrays
\r
576 CV_EXPORTS void bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null());
\r
578 //! calculates per-element bit-wise conjunction of two arrays
\r
579 CV_EXPORTS void bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null());
\r
581 //! calculates per-element bit-wise "exclusive or" operation
\r
582 CV_EXPORTS void bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null());
\r
584 //! computes per-element minimum of two arrays (dst = min(src1, src2))
\r
585 CV_EXPORTS void min(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream = Stream::Null());
\r
587 //! computes per-element minimum of array and scalar (dst = min(src1, src2))
\r
588 CV_EXPORTS void min(const GpuMat& src1, double src2, GpuMat& dst, Stream& stream = Stream::Null());
\r
590 //! computes per-element maximum of two arrays (dst = max(src1, src2))
\r
591 CV_EXPORTS void max(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream = Stream::Null());
\r
593 //! computes per-element maximum of array and scalar (dst = max(src1, src2))
\r
594 CV_EXPORTS void max(const GpuMat& src1, double src2, GpuMat& dst, Stream& stream = Stream::Null());
\r
597 ////////////////////////////// Image processing //////////////////////////////
\r
599 //! DST[x,y] = SRC[xmap[x,y],ymap[x,y]]
\r
600 //! supports only CV_32FC1 map type
\r
601 CV_EXPORTS void remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap,
\r
602 int interpolation, int borderMode = BORDER_CONSTANT, const Scalar& borderValue = Scalar(),
\r
603 Stream& stream = Stream::Null());
\r
605 //! Does mean shift filtering on GPU.
\r
606 CV_EXPORTS void meanShiftFiltering(const GpuMat& src, GpuMat& dst, int sp, int sr,
\r
607 TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
\r
609 //! Does mean shift procedure on GPU.
\r
610 CV_EXPORTS void meanShiftProc(const GpuMat& src, GpuMat& dstr, GpuMat& dstsp, int sp, int sr,
\r
611 TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
\r
613 //! Does mean shift segmentation with elimination of small regions.
\r
614 CV_EXPORTS void meanShiftSegmentation(const GpuMat& src, Mat& dst, int sp, int sr, int minsize,
\r
615 TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
\r
617 //! Does coloring of disparity image: [0..ndisp) -> [0..240, 1, 1] in HSV.
\r
618 //! Supported types of input disparity: CV_8U, CV_16S.
\r
619 //! Output disparity has CV_8UC4 type in BGRA format (alpha = 255).
\r
620 CV_EXPORTS void drawColorDisp(const GpuMat& src_disp, GpuMat& dst_disp, int ndisp, Stream& stream = Stream::Null());
\r
622 //! Reprojects disparity image to 3D space.
\r
623 //! Supports CV_8U and CV_16S types of input disparity.
\r
624 //! The output is a 4-channel floating-point (CV_32FC4) matrix.
\r
625 //! Each element of this matrix will contain the 3D coordinates of the point (x,y,z,1), computed from the disparity map.
\r
626 //! Q is the 4x4 perspective transformation matrix that can be obtained with cvStereoRectify.
\r
627 CV_EXPORTS void reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q, Stream& stream = Stream::Null());
\r
629 //! converts image from one color space to another
\r
630 CV_EXPORTS void cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn = 0, Stream& stream = Stream::Null());
\r
632 //! applies fixed threshold to the image
\r
633 CV_EXPORTS double threshold(const GpuMat& src, GpuMat& dst, double thresh, double maxval, int type, Stream& stream = Stream::Null());
\r
635 //! resizes the image
\r
636 //! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
\r
637 CV_EXPORTS void resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx=0, double fy=0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null());
\r
639 //! warps the image using affine transformation
\r
640 //! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
\r
641 CV_EXPORTS void warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR, Stream& stream = Stream::Null());
\r
643 //! warps the image using perspective transformation
\r
644 //! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
\r
645 CV_EXPORTS void warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR, Stream& stream = Stream::Null());
\r
647 //! builds plane warping maps
\r
648 CV_EXPORTS void buildWarpPlaneMaps(Size src_size, Rect dst_roi, const Mat& R, double f, double s, double dist,
\r
649 GpuMat& map_x, GpuMat& map_y, Stream& stream = Stream::Null());
\r
651 //! builds cylindrical warping maps
\r
652 CV_EXPORTS void buildWarpCylindricalMaps(Size src_size, Rect dst_roi, const Mat& R, double f, double s,
\r
653 GpuMat& map_x, GpuMat& map_y, Stream& stream = Stream::Null());
\r
655 //! builds spherical warping maps
\r
656 CV_EXPORTS void buildWarpSphericalMaps(Size src_size, Rect dst_roi, const Mat& R, double f, double s,
\r
657 GpuMat& map_x, GpuMat& map_y, Stream& stream = Stream::Null());
\r
659 //! rotate 8bit single or four channel image
\r
660 //! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
\r
661 //! supports CV_8UC1, CV_8UC4 types
\r
662 CV_EXPORTS void rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift = 0, double yShift = 0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null());
\r
664 //! copies 2D array to a larger destination array and pads borders with user-specifiable constant
\r
665 //! supports CV_8UC1, CV_8UC4, CV_32SC1 and CV_32FC1 types
\r
666 CV_EXPORTS void copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, const Scalar& value = Scalar(), Stream& stream = Stream::Null());
\r
668 //! computes the integral image
\r
669 //! sum will have CV_32S type, but will contain unsigned int values
\r
670 //! supports only CV_8UC1 source type
\r
671 CV_EXPORTS void integral(const GpuMat& src, GpuMat& sum, Stream& stream = Stream::Null());
\r
673 //! buffered version
\r
674 CV_EXPORTS void integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer, Stream& stream = Stream::Null());
\r
676 //! computes the integral image and integral for the squared image
\r
677 //! sum will have CV_32S type, sqsum - CV32F type
\r
678 //! supports only CV_8UC1 source type
\r
679 CV_EXPORTS void integral(const GpuMat& src, GpuMat& sum, GpuMat& sqsum, Stream& stream = Stream::Null());
\r
681 //! computes squared integral image
\r
682 //! result matrix will have 64F type, but will contain 64U values
\r
683 //! supports source images of 8UC1 type only
\r
684 CV_EXPORTS void sqrIntegral(const GpuMat& src, GpuMat& sqsum, Stream& stream = Stream::Null());
\r
686 //! computes vertical sum, supports only CV_32FC1 images
\r
687 CV_EXPORTS void columnSum(const GpuMat& src, GpuMat& sum);
\r
689 //! computes the standard deviation of integral images
\r
690 //! supports only CV_32SC1 source type and CV_32FC1 sqr type
\r
691 //! output will have CV_32FC1 type
\r
692 CV_EXPORTS void rectStdDev(const GpuMat& src, const GpuMat& sqr, GpuMat& dst, const Rect& rect, Stream& stream = Stream::Null());
\r
694 //! computes Harris cornerness criteria at each image pixel
\r
695 CV_EXPORTS void cornerHarris(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, double k, int borderType=BORDER_REFLECT101);
\r
696 CV_EXPORTS void cornerHarris(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, int blockSize, int ksize, double k, int borderType=BORDER_REFLECT101);
\r
698 //! computes minimum eigen value of 2x2 derivative covariation matrix at each pixel - the cornerness criteria
\r
699 CV_EXPORTS void cornerMinEigenVal(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, int borderType=BORDER_REFLECT101);
\r
700 CV_EXPORTS void cornerMinEigenVal(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, int blockSize, int ksize, int borderType=BORDER_REFLECT101);
\r
702 //! performs per-element multiplication of two full (not packed) Fourier spectrums
\r
703 //! supports 32FC2 matrixes only (interleaved format)
\r
704 CV_EXPORTS void mulSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flags, bool conjB=false);
\r
706 //! performs per-element multiplication of two full (not packed) Fourier spectrums
\r
707 //! supports 32FC2 matrixes only (interleaved format)
\r
708 CV_EXPORTS void mulAndScaleSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flags,
\r
709 float scale, bool conjB=false);
\r
711 //! Performs a forward or inverse discrete Fourier transform (1D or 2D) of floating point matrix.
\r
712 //! Param dft_size is the size of DFT transform.
\r
714 //! If the source matrix is not continous, then additional copy will be done,
\r
715 //! so to avoid copying ensure the source matrix is continous one. If you want to use
\r
716 //! preallocated output ensure it is continuous too, otherwise it will be reallocated.
\r
718 //! Being implemented via CUFFT real-to-complex transform result contains only non-redundant values
\r
719 //! in CUFFT's format. Result as full complex matrix for such kind of transform cannot be retrieved.
\r
721 //! For complex-to-real transform it is assumed that the source matrix is packed in CUFFT's format.
\r
722 CV_EXPORTS void dft(const GpuMat& src, GpuMat& dst, Size dft_size, int flags=0);
\r
724 //! computes convolution (or cross-correlation) of two images using discrete Fourier transform
\r
725 //! supports source images of 32FC1 type only
\r
726 //! result matrix will have 32FC1 type
\r
727 CV_EXPORTS void convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result,
\r
730 struct CV_EXPORTS ConvolveBuf;
\r
732 //! buffered version
\r
733 CV_EXPORTS void convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result,
\r
734 bool ccorr, ConvolveBuf& buf);
\r
736 struct CV_EXPORTS ConvolveBuf
\r
739 ConvolveBuf(Size image_size, Size templ_size)
\r
740 { create(image_size, templ_size); }
\r
741 void create(Size image_size, Size templ_size);
\r
744 static Size estimateBlockSize(Size result_size, Size templ_size);
\r
745 friend void convolve(const GpuMat&, const GpuMat&, GpuMat&, bool, ConvolveBuf&);
\r
752 GpuMat image_spect, templ_spect, result_spect;
\r
753 GpuMat image_block, templ_block, result_data;
\r
756 //! computes the proximity map for the raster template and the image where the template is searched for
\r
757 CV_EXPORTS void matchTemplate(const GpuMat& image, const GpuMat& templ, GpuMat& result, int method);
\r
759 //! smoothes the source image and downsamples it
\r
760 CV_EXPORTS void pyrDown(const GpuMat& src, GpuMat& dst, int borderType = BORDER_DEFAULT, Stream& stream = Stream::Null());
\r
762 //! upsamples the source image and then smoothes it
\r
763 CV_EXPORTS void pyrUp(const GpuMat& src, GpuMat& dst, int borderType = BORDER_DEFAULT, Stream& stream = Stream::Null());
\r
765 //! performs linear blending of two images
\r
766 //! to avoid accuracy errors sum of weigths shouldn't be very close to zero
\r
767 CV_EXPORTS void blendLinear(const GpuMat& img1, const GpuMat& img2, const GpuMat& weights1, const GpuMat& weights2,
\r
768 GpuMat& result, Stream& stream = Stream::Null());
\r
771 struct CV_EXPORTS CannyBuf;
\r
773 CV_EXPORTS void Canny(const GpuMat& image, GpuMat& edges, double low_thresh, double high_thresh, int apperture_size = 3, bool L2gradient = false);
\r
774 CV_EXPORTS void Canny(const GpuMat& image, CannyBuf& buf, GpuMat& edges, double low_thresh, double high_thresh, int apperture_size = 3, bool L2gradient = false);
\r
775 CV_EXPORTS void Canny(const GpuMat& dx, const GpuMat& dy, GpuMat& edges, double low_thresh, double high_thresh, bool L2gradient = false);
\r
776 CV_EXPORTS void Canny(const GpuMat& dx, const GpuMat& dy, CannyBuf& buf, GpuMat& edges, double low_thresh, double high_thresh, bool L2gradient = false);
\r
778 struct CV_EXPORTS CannyBuf
\r
781 explicit CannyBuf(const Size& image_size, int apperture_size = 3) {create(image_size, apperture_size);}
\r
782 CannyBuf(const GpuMat& dx_, const GpuMat& dy_);
\r
784 void create(const Size& image_size, int apperture_size = 3);
\r
789 GpuMat dx_buf, dy_buf;
\r
791 GpuMat trackBuf1, trackBuf2;
\r
792 Ptr<FilterEngine_GPU> filterDX, filterDY;
\r
795 ////////////////////////////// Matrix reductions //////////////////////////////
\r
797 //! computes mean value and standard deviation of all or selected array elements
\r
798 //! supports only CV_8UC1 type
\r
799 CV_EXPORTS void meanStdDev(const GpuMat& mtx, Scalar& mean, Scalar& stddev);
\r
801 //! computes norm of array
\r
802 //! supports NORM_INF, NORM_L1, NORM_L2
\r
803 //! supports all matrices except 64F
\r
804 CV_EXPORTS double norm(const GpuMat& src1, int normType=NORM_L2);
\r
806 //! computes norm of array
\r
807 //! supports NORM_INF, NORM_L1, NORM_L2
\r
808 //! supports all matrices except 64F
\r
809 CV_EXPORTS double norm(const GpuMat& src1, int normType, GpuMat& buf);
\r
811 //! computes norm of the difference between two arrays
\r
812 //! supports NORM_INF, NORM_L1, NORM_L2
\r
813 //! supports only CV_8UC1 type
\r
814 CV_EXPORTS double norm(const GpuMat& src1, const GpuMat& src2, int normType=NORM_L2);
\r
816 //! computes sum of array elements
\r
817 //! supports only single channel images
\r
818 CV_EXPORTS Scalar sum(const GpuMat& src);
\r
820 //! computes sum of array elements
\r
821 //! supports only single channel images
\r
822 CV_EXPORTS Scalar sum(const GpuMat& src, GpuMat& buf);
\r
824 //! computes sum of array elements absolute values
\r
825 //! supports only single channel images
\r
826 CV_EXPORTS Scalar absSum(const GpuMat& src);
\r
828 //! computes sum of array elements absolute values
\r
829 //! supports only single channel images
\r
830 CV_EXPORTS Scalar absSum(const GpuMat& src, GpuMat& buf);
\r
832 //! computes squared sum of array elements
\r
833 //! supports only single channel images
\r
834 CV_EXPORTS Scalar sqrSum(const GpuMat& src);
\r
836 //! computes squared sum of array elements
\r
837 //! supports only single channel images
\r
838 CV_EXPORTS Scalar sqrSum(const GpuMat& src, GpuMat& buf);
\r
840 //! finds global minimum and maximum array elements and returns their values
\r
841 CV_EXPORTS void minMax(const GpuMat& src, double* minVal, double* maxVal=0, const GpuMat& mask=GpuMat());
\r
843 //! finds global minimum and maximum array elements and returns their values
\r
844 CV_EXPORTS void minMax(const GpuMat& src, double* minVal, double* maxVal, const GpuMat& mask, GpuMat& buf);
\r
846 //! finds global minimum and maximum array elements and returns their values with locations
\r
847 CV_EXPORTS void minMaxLoc(const GpuMat& src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0,
\r
848 const GpuMat& mask=GpuMat());
\r
850 //! finds global minimum and maximum array elements and returns their values with locations
\r
851 CV_EXPORTS void minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point* minLoc, Point* maxLoc,
\r
852 const GpuMat& mask, GpuMat& valbuf, GpuMat& locbuf);
\r
854 //! counts non-zero array elements
\r
855 CV_EXPORTS int countNonZero(const GpuMat& src);
\r
857 //! counts non-zero array elements
\r
858 CV_EXPORTS int countNonZero(const GpuMat& src, GpuMat& buf);
\r
861 ///////////////////////////// Calibration 3D //////////////////////////////////
\r
863 CV_EXPORTS void transformPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec,
\r
864 GpuMat& dst, Stream& stream = Stream::Null());
\r
866 CV_EXPORTS void projectPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec,
\r
867 const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst,
\r
868 Stream& stream = Stream::Null());
\r
870 CV_EXPORTS void solvePnPRansac(const Mat& object, const Mat& image, const Mat& camera_mat,
\r
871 const Mat& dist_coef, Mat& rvec, Mat& tvec, bool use_extrinsic_guess=false,
\r
872 int num_iters=100, float max_dist=8.0, int min_inlier_count=100,
\r
873 vector<int>* inliers=NULL);
\r
875 //////////////////////////////// Image Labeling ////////////////////////////////
\r
877 //!performs labeling via graph cuts
\r
878 CV_EXPORTS void graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTransp, GpuMat& top, GpuMat& bottom, GpuMat& labels, GpuMat& buf, Stream& stream = Stream::Null());
\r
880 ////////////////////////////////// Histograms //////////////////////////////////
\r
882 //! Compute levels with even distribution. levels will have 1 row and nLevels cols and CV_32SC1 type.
\r
883 CV_EXPORTS void evenLevels(GpuMat& levels, int nLevels, int lowerLevel, int upperLevel);
\r
884 //! Calculates histogram with evenly distributed bins for signle channel source.
\r
885 //! Supports CV_8UC1, CV_16UC1 and CV_16SC1 source types.
\r
886 //! Output hist will have one row and histSize cols and CV_32SC1 type.
\r
887 CV_EXPORTS void histEven(const GpuMat& src, GpuMat& hist, int histSize, int lowerLevel, int upperLevel, Stream& stream = Stream::Null());
\r
888 CV_EXPORTS void histEven(const GpuMat& src, GpuMat& hist, GpuMat& buf, int histSize, int lowerLevel, int upperLevel, Stream& stream = Stream::Null());
\r
889 //! Calculates histogram with evenly distributed bins for four-channel source.
\r
890 //! All channels of source are processed separately.
\r
891 //! Supports CV_8UC4, CV_16UC4 and CV_16SC4 source types.
\r
892 //! Output hist[i] will have one row and histSize[i] cols and CV_32SC1 type.
\r
893 CV_EXPORTS void histEven(const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4], Stream& stream = Stream::Null());
\r
894 CV_EXPORTS void histEven(const GpuMat& src, GpuMat hist[4], GpuMat& buf, int histSize[4], int lowerLevel[4], int upperLevel[4], Stream& stream = Stream::Null());
\r
895 //! Calculates histogram with bins determined by levels array.
\r
896 //! levels must have one row and CV_32SC1 type if source has integer type or CV_32FC1 otherwise.
\r
897 //! Supports CV_8UC1, CV_16UC1, CV_16SC1 and CV_32FC1 source types.
\r
898 //! Output hist will have one row and (levels.cols-1) cols and CV_32SC1 type.
\r
899 CV_EXPORTS void histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels, Stream& stream = Stream::Null());
\r
900 CV_EXPORTS void histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels, GpuMat& buf, Stream& stream = Stream::Null());
\r
901 //! Calculates histogram with bins determined by levels array.
\r
902 //! All levels must have one row and CV_32SC1 type if source has integer type or CV_32FC1 otherwise.
\r
903 //! All channels of source are processed separately.
\r
904 //! Supports CV_8UC4, CV_16UC4, CV_16SC4 and CV_32FC4 source types.
\r
905 //! Output hist[i] will have one row and (levels[i].cols-1) cols and CV_32SC1 type.
\r
906 CV_EXPORTS void histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4], Stream& stream = Stream::Null());
\r
907 CV_EXPORTS void histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4], GpuMat& buf, Stream& stream = Stream::Null());
\r
909 //! Calculates histogram for 8u one channel image
\r
910 //! Output hist will have one row, 256 cols and CV32SC1 type.
\r
911 CV_EXPORTS void calcHist(const GpuMat& src, GpuMat& hist, Stream& stream = Stream::Null());
\r
912 CV_EXPORTS void calcHist(const GpuMat& src, GpuMat& hist, GpuMat& buf, Stream& stream = Stream::Null());
\r
914 //! normalizes the grayscale image brightness and contrast by normalizing its histogram
\r
915 CV_EXPORTS void equalizeHist(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null());
\r
916 CV_EXPORTS void equalizeHist(const GpuMat& src, GpuMat& dst, GpuMat& hist, Stream& stream = Stream::Null());
\r
917 CV_EXPORTS void equalizeHist(const GpuMat& src, GpuMat& dst, GpuMat& hist, GpuMat& buf, Stream& stream = Stream::Null());
\r
919 //////////////////////////////// StereoBM_GPU ////////////////////////////////
\r
921 class CV_EXPORTS StereoBM_GPU
\r
924 enum { BASIC_PRESET = 0, PREFILTER_XSOBEL = 1 };
\r
926 enum { DEFAULT_NDISP = 64, DEFAULT_WINSZ = 19 };
\r
928 //! the default constructor
\r
930 //! the full constructor taking the camera-specific preset, number of disparities and the SAD window size. ndisparities must be multiple of 8.
\r
931 StereoBM_GPU(int preset, int ndisparities = DEFAULT_NDISP, int winSize = DEFAULT_WINSZ);
\r
933 //! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair
\r
934 //! Output disparity has CV_8U type.
\r
935 void operator() ( const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream = Stream::Null());
\r
937 //! Some heuristics that tries to estmate
\r
938 // if current GPU will be faster than CPU in this algorithm.
\r
939 // It queries current active device.
\r
940 static bool checkIfGpuCallReasonable();
\r
946 // If avergeTexThreshold == 0 => post procesing is disabled
\r
947 // If avergeTexThreshold != 0 then disparity is set 0 in each point (x,y) where for left image
\r
948 // SumOfHorizontalGradiensInWindow(x, y, winSize) < (winSize * winSize) * avergeTexThreshold
\r
949 // i.e. input left image is low textured.
\r
950 float avergeTexThreshold;
\r
952 GpuMat minSSD, leBuf, riBuf;
\r
955 ////////////////////////// StereoBeliefPropagation ///////////////////////////
\r
956 // "Efficient Belief Propagation for Early Vision"
\r
959 class CV_EXPORTS StereoBeliefPropagation
\r
962 enum { DEFAULT_NDISP = 64 };
\r
963 enum { DEFAULT_ITERS = 5 };
\r
964 enum { DEFAULT_LEVELS = 5 };
\r
966 static void estimateRecommendedParams(int width, int height, int& ndisp, int& iters, int& levels);
\r
968 //! the default constructor
\r
969 explicit StereoBeliefPropagation(int ndisp = DEFAULT_NDISP,
\r
970 int iters = DEFAULT_ITERS,
\r
971 int levels = DEFAULT_LEVELS,
\r
972 int msg_type = CV_32F);
\r
974 //! the full constructor taking the number of disparities, number of BP iterations on each level,
\r
975 //! number of levels, truncation of data cost, data weight,
\r
976 //! truncation of discontinuity cost and discontinuity single jump
\r
977 //! DataTerm = data_weight * min(fabs(I2-I1), max_data_term)
\r
978 //! DiscTerm = min(disc_single_jump * fabs(f1-f2), max_disc_term)
\r
979 //! please see paper for more details
\r
980 StereoBeliefPropagation(int ndisp, int iters, int levels,
\r
981 float max_data_term, float data_weight,
\r
982 float max_disc_term, float disc_single_jump,
\r
983 int msg_type = CV_32F);
\r
985 //! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair,
\r
986 //! if disparity is empty output type will be CV_16S else output type will be disparity.type().
\r
987 void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream = Stream::Null());
\r
990 //! version for user specified data term
\r
991 void operator()(const GpuMat& data, GpuMat& disparity, Stream& stream = Stream::Null());
\r
998 float max_data_term;
\r
1000 float max_disc_term;
\r
1001 float disc_single_jump;
\r
1005 GpuMat u, d, l, r, u2, d2, l2, r2;
\r
1006 std::vector<GpuMat> datas;
\r
1010 /////////////////////////// StereoConstantSpaceBP ///////////////////////////
\r
1011 // "A Constant-Space Belief Propagation Algorithm for Stereo Matching"
\r
1012 // Qingxiong Yang, Liang Wang, Narendra Ahuja
\r
1013 // http://vision.ai.uiuc.edu/~qyang6/
\r
1015 class CV_EXPORTS StereoConstantSpaceBP
\r
1018 enum { DEFAULT_NDISP = 128 };
\r
1019 enum { DEFAULT_ITERS = 8 };
\r
1020 enum { DEFAULT_LEVELS = 4 };
\r
1021 enum { DEFAULT_NR_PLANE = 4 };
\r
1023 static void estimateRecommendedParams(int width, int height, int& ndisp, int& iters, int& levels, int& nr_plane);
\r
1025 //! the default constructor
\r
1026 explicit StereoConstantSpaceBP(int ndisp = DEFAULT_NDISP,
\r
1027 int iters = DEFAULT_ITERS,
\r
1028 int levels = DEFAULT_LEVELS,
\r
1029 int nr_plane = DEFAULT_NR_PLANE,
\r
1030 int msg_type = CV_32F);
\r
1032 //! the full constructor taking the number of disparities, number of BP iterations on each level,
\r
1033 //! number of levels, number of active disparity on the first level, truncation of data cost, data weight,
\r
1034 //! truncation of discontinuity cost, discontinuity single jump and minimum disparity threshold
\r
1035 StereoConstantSpaceBP(int ndisp, int iters, int levels, int nr_plane,
\r
1036 float max_data_term, float data_weight, float max_disc_term, float disc_single_jump,
\r
1037 int min_disp_th = 0,
\r
1038 int msg_type = CV_32F);
\r
1040 //! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair,
\r
1041 //! if disparity is empty output type will be CV_16S else output type will be disparity.type().
\r
1042 void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream = Stream::Null());
\r
1051 float max_data_term;
\r
1052 float data_weight;
\r
1053 float max_disc_term;
\r
1054 float disc_single_jump;
\r
1060 bool use_local_init_data_cost;
\r
1062 GpuMat u[2], d[2], l[2], r[2];
\r
1063 GpuMat disp_selected_pyr[2];
\r
1066 GpuMat data_cost_selected;
\r
1073 /////////////////////////// DisparityBilateralFilter ///////////////////////////
\r
1074 // Disparity map refinement using joint bilateral filtering given a single color image.
\r
1075 // Qingxiong Yang, Liang Wang, Narendra Ahuja
\r
1076 // http://vision.ai.uiuc.edu/~qyang6/
\r
1078 class CV_EXPORTS DisparityBilateralFilter
\r
1081 enum { DEFAULT_NDISP = 64 };
\r
1082 enum { DEFAULT_RADIUS = 3 };
\r
1083 enum { DEFAULT_ITERS = 1 };
\r
1085 //! the default constructor
\r
1086 explicit DisparityBilateralFilter(int ndisp = DEFAULT_NDISP, int radius = DEFAULT_RADIUS, int iters = DEFAULT_ITERS);
\r
1088 //! the full constructor taking the number of disparities, filter radius,
\r
1089 //! number of iterations, truncation of data continuity, truncation of disparity continuity
\r
1090 //! and filter range sigma
\r
1091 DisparityBilateralFilter(int ndisp, int radius, int iters, float edge_threshold, float max_disc_threshold, float sigma_range);
\r
1093 //! the disparity map refinement operator. Refine disparity map using joint bilateral filtering given a single color image.
\r
1094 //! disparity must have CV_8U or CV_16S type, image must have CV_8UC1 or CV_8UC3 type.
\r
1095 void operator()(const GpuMat& disparity, const GpuMat& image, GpuMat& dst, Stream& stream = Stream::Null());
\r
1102 float edge_threshold;
\r
1103 float max_disc_threshold;
\r
1104 float sigma_range;
\r
1106 GpuMat table_color;
\r
1107 GpuMat table_space;
\r
1111 //////////////// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector //////////////
\r
1113 struct CV_EXPORTS HOGDescriptor
\r
1115 enum { DEFAULT_WIN_SIGMA = -1 };
\r
1116 enum { DEFAULT_NLEVELS = 64 };
\r
1117 enum { DESCR_FORMAT_ROW_BY_ROW, DESCR_FORMAT_COL_BY_COL };
\r
1119 HOGDescriptor(Size win_size=Size(64, 128), Size block_size=Size(16, 16),
\r
1120 Size block_stride=Size(8, 8), Size cell_size=Size(8, 8),
\r
1121 int nbins=9, double win_sigma=DEFAULT_WIN_SIGMA,
\r
1122 double threshold_L2hys=0.2, bool gamma_correction=true,
\r
1123 int nlevels=DEFAULT_NLEVELS);
\r
1125 size_t getDescriptorSize() const;
\r
1126 size_t getBlockHistogramSize() const;
\r
1128 void setSVMDetector(const vector<float>& detector);
\r
1130 static vector<float> getDefaultPeopleDetector();
\r
1131 static vector<float> getPeopleDetector48x96();
\r
1132 static vector<float> getPeopleDetector64x128();
\r
1134 void detect(const GpuMat& img, vector<Point>& found_locations,
\r
1135 double hit_threshold=0, Size win_stride=Size(),
\r
1136 Size padding=Size());
\r
1138 void detectMultiScale(const GpuMat& img, vector<Rect>& found_locations,
\r
1139 double hit_threshold=0, Size win_stride=Size(),
\r
1140 Size padding=Size(), double scale0=1.05,
\r
1141 int group_threshold=2);
\r
1143 void getDescriptors(const GpuMat& img, Size win_stride,
\r
1144 GpuMat& descriptors,
\r
1145 int descr_format=DESCR_FORMAT_COL_BY_COL);
\r
1149 Size block_stride;
\r
1153 double threshold_L2hys;
\r
1154 bool gamma_correction;
\r
1158 void computeBlockHistograms(const GpuMat& img);
\r
1159 void computeGradient(const GpuMat& img, GpuMat& grad, GpuMat& qangle);
\r
1161 double getWinSigma() const;
\r
1162 bool checkDetectorSize() const;
\r
1164 static int numPartsWithin(int size, int part_size, int stride);
\r
1165 static Size numPartsWithin(Size size, Size part_size, Size stride);
\r
1167 // Coefficients of the separating plane
\r
1171 // Results of the last classification step
\r
1172 GpuMat labels, labels_buf;
\r
1175 // Results of the last histogram evaluation step
\r
1176 GpuMat block_hists, block_hists_buf;
\r
1178 // Gradients conputation results
\r
1179 GpuMat grad, qangle, grad_buf, qangle_buf;
\r
1181 // returns subbuffer with required size, reallocates buffer if nessesary.
\r
1182 static GpuMat getBuffer(const Size& sz, int type, GpuMat& buf);
\r
1183 static GpuMat getBuffer(int rows, int cols, int type, GpuMat& buf);
\r
1185 std::vector<GpuMat> image_scales;
\r
1189 ////////////////////////////////// BruteForceMatcher //////////////////////////////////
\r
1191 class CV_EXPORTS BruteForceMatcher_GPU_base
\r
1194 enum DistType {L1Dist = 0, L2Dist, HammingDist};
\r
1196 explicit BruteForceMatcher_GPU_base(DistType distType = L2Dist);
\r
1198 // Add descriptors to train descriptor collection.
\r
1199 void add(const std::vector<GpuMat>& descCollection);
\r
1201 // Get train descriptors collection.
\r
1202 const std::vector<GpuMat>& getTrainDescriptors() const;
\r
1204 // Clear train descriptors collection.
\r
1207 // Return true if there are not train descriptors in collection.
\r
1208 bool empty() const;
\r
1210 // Return true if the matcher supports mask in match methods.
\r
1211 bool isMaskSupported() const;
\r
1213 // Find one best match for each query descriptor.
\r
1214 // trainIdx.at<int>(0, queryIdx) will contain best train index for queryIdx
\r
1215 // distance.at<float>(0, queryIdx) will contain distance
\r
1216 void matchSingle(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1217 GpuMat& trainIdx, GpuMat& distance,
\r
1218 const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null());
\r
1220 // Download trainIdx and distance and convert it to CPU vector with DMatch
\r
1221 static void matchDownload(const GpuMat& trainIdx, const GpuMat& distance, std::vector<DMatch>& matches);
\r
1222 // Convert trainIdx and distance to vector with DMatch
\r
1223 static void matchConvert(const Mat& trainIdx, const Mat& distance, std::vector<DMatch>& matches);
\r
1225 // Find one best match for each query descriptor.
\r
1226 void match(const GpuMat& queryDescs, const GpuMat& trainDescs, std::vector<DMatch>& matches,
\r
1227 const GpuMat& mask = GpuMat());
\r
1229 // Make gpu collection of trains and masks in suitable format for matchCollection function
\r
1230 void makeGpuCollection(GpuMat& trainCollection, GpuMat& maskCollection,
\r
1231 const vector<GpuMat>& masks = std::vector<GpuMat>());
\r
1233 // Find one best match from train collection for each query descriptor.
\r
1234 // trainIdx.at<int>(0, queryIdx) will contain best train index for queryIdx
\r
1235 // imgIdx.at<int>(0, queryIdx) will contain best image index for queryIdx
\r
1236 // distance.at<float>(0, queryIdx) will contain distance
\r
1237 void matchCollection(const GpuMat& queryDescs, const GpuMat& trainCollection,
\r
1238 GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance,
\r
1239 const GpuMat& maskCollection, Stream& stream = Stream::Null());
\r
1241 // Download trainIdx, imgIdx and distance and convert it to vector with DMatch
\r
1242 static void matchDownload(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, std::vector<DMatch>& matches);
\r
1243 // Convert trainIdx, imgIdx and distance to vector with DMatch
\r
1244 static void matchConvert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, std::vector<DMatch>& matches);
\r
1246 // Find one best match from train collection for each query descriptor.
\r
1247 void match(const GpuMat& queryDescs, std::vector<DMatch>& matches, const std::vector<GpuMat>& masks = std::vector<GpuMat>());
\r
1249 // Find k best matches for each query descriptor (in increasing order of distances).
\r
1250 // trainIdx.at<int>(queryIdx, i) will contain index of i'th best trains (i < k).
\r
1251 // distance.at<float>(queryIdx, i) will contain distance.
\r
1252 // allDist is a buffer to store all distance between query descriptors and train descriptors
\r
1253 // it have size (nQuery,nTrain) and CV_32F type
\r
1254 // allDist.at<float>(queryIdx, trainIdx) will contain FLT_MAX, if trainIdx is one from k best,
\r
1255 // otherwise it will contain distance between queryIdx and trainIdx descriptors
\r
1256 void knnMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1257 GpuMat& trainIdx, GpuMat& distance, GpuMat& allDist, int k, const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null());
\r
1259 // Download trainIdx and distance and convert it to vector with DMatch
\r
1260 // compactResult is used when mask is not empty. If compactResult is false matches
\r
1261 // vector will have the same size as queryDescriptors rows. If compactResult is true
\r
1262 // matches vector will not contain matches for fully masked out query descriptors.
\r
1263 static void knnMatchDownload(const GpuMat& trainIdx, const GpuMat& distance,
\r
1264 std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
\r
1265 // Convert trainIdx and distance to vector with DMatch
\r
1266 static void knnMatchConvert(const Mat& trainIdx, const Mat& distance,
\r
1267 std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
\r
1269 // Find k best matches for each query descriptor (in increasing order of distances).
\r
1270 // compactResult is used when mask is not empty. If compactResult is false matches
\r
1271 // vector will have the same size as queryDescriptors rows. If compactResult is true
\r
1272 // matches vector will not contain matches for fully masked out query descriptors.
\r
1273 void knnMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1274 std::vector< std::vector<DMatch> >& matches, int k, const GpuMat& mask = GpuMat(),
\r
1275 bool compactResult = false);
\r
1277 // Find k best matches for each query descriptor (in increasing order of distances).
\r
1278 // compactResult is used when mask is not empty. If compactResult is false matches
\r
1279 // vector will have the same size as queryDescriptors rows. If compactResult is true
\r
1280 // matches vector will not contain matches for fully masked out query descriptors.
\r
1281 void knnMatch(const GpuMat& queryDescs, std::vector< std::vector<DMatch> >& matches, int knn,
\r
1282 const std::vector<GpuMat>& masks = std::vector<GpuMat>(), bool compactResult = false );
\r
1284 // Find best matches for each query descriptor which have distance less than maxDistance.
\r
1285 // nMatches.at<unsigned int>(0, queruIdx) will contain matches count for queryIdx.
\r
1286 // carefully nMatches can be greater than trainIdx.cols - it means that matcher didn't find all matches,
\r
1287 // because it didn't have enough memory.
\r
1288 // trainIdx.at<int>(queruIdx, i) will contain ith train index (i < min(nMatches.at<unsigned int>(0, queruIdx), trainIdx.cols))
\r
1289 // distance.at<int>(queruIdx, i) will contain ith distance (i < min(nMatches.at<unsigned int>(0, queruIdx), trainIdx.cols))
\r
1290 // If trainIdx is empty, then trainIdx and distance will be created with size nQuery x nTrain,
\r
1291 // otherwize user can pass own allocated trainIdx and distance with size nQuery x nMaxMatches
\r
1292 // Matches doesn't sorted.
\r
1293 void radiusMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1294 GpuMat& trainIdx, GpuMat& nMatches, GpuMat& distance, float maxDistance,
\r
1295 const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null());
\r
1297 // Download trainIdx, nMatches and distance and convert it to vector with DMatch.
\r
1298 // matches will be sorted in increasing order of distances.
\r
1299 // compactResult is used when mask is not empty. If compactResult is false matches
\r
1300 // vector will have the same size as queryDescriptors rows. If compactResult is true
\r
1301 // matches vector will not contain matches for fully masked out query descriptors.
\r
1302 static void radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& nMatches, const GpuMat& distance,
\r
1303 std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
\r
1304 // Convert trainIdx, nMatches and distance to vector with DMatch.
\r
1305 static void radiusMatchConvert(const Mat& trainIdx, const Mat& nMatches, const Mat& distance,
\r
1306 std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
\r
1308 // Find best matches for each query descriptor which have distance less than maxDistance
\r
1309 // in increasing order of distances).
\r
1310 void radiusMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,
\r
1311 std::vector< std::vector<DMatch> >& matches, float maxDistance,
\r
1312 const GpuMat& mask = GpuMat(), bool compactResult = false);
\r
1314 // Find best matches from train collection for each query descriptor which have distance less than
\r
1315 // maxDistance (in increasing order of distances).
\r
1316 void radiusMatch(const GpuMat& queryDescs, std::vector< std::vector<DMatch> >& matches, float maxDistance,
\r
1317 const std::vector<GpuMat>& masks = std::vector<GpuMat>(), bool compactResult = false);
\r
1319 DistType distType;
\r
1322 std::vector<GpuMat> trainDescCollection;
\r
1325 template <class Distance>
\r
1326 class CV_EXPORTS BruteForceMatcher_GPU;
\r
1328 template <typename T>
\r
1329 class CV_EXPORTS BruteForceMatcher_GPU< L1<T> > : public BruteForceMatcher_GPU_base
\r
1332 explicit BruteForceMatcher_GPU() : BruteForceMatcher_GPU_base(L1Dist) {}
\r
1333 explicit BruteForceMatcher_GPU(L1<T> /*d*/) : BruteForceMatcher_GPU_base(L1Dist) {}
\r
1335 template <typename T>
\r
1336 class CV_EXPORTS BruteForceMatcher_GPU< L2<T> > : public BruteForceMatcher_GPU_base
\r
1339 explicit BruteForceMatcher_GPU() : BruteForceMatcher_GPU_base(L2Dist) {}
\r
1340 explicit BruteForceMatcher_GPU(L2<T> /*d*/) : BruteForceMatcher_GPU_base(L2Dist) {}
\r
1342 template <> class CV_EXPORTS BruteForceMatcher_GPU< HammingLUT > : public BruteForceMatcher_GPU_base
\r
1345 explicit BruteForceMatcher_GPU() : BruteForceMatcher_GPU_base(HammingDist) {}
\r
1346 explicit BruteForceMatcher_GPU(HammingLUT /*d*/) : BruteForceMatcher_GPU_base(HammingDist) {}
\r
1348 template <> class CV_EXPORTS BruteForceMatcher_GPU< Hamming > : public BruteForceMatcher_GPU_base
\r
1351 explicit BruteForceMatcher_GPU() : BruteForceMatcher_GPU_base(HammingDist) {}
\r
1352 explicit BruteForceMatcher_GPU(Hamming /*d*/) : BruteForceMatcher_GPU_base(HammingDist) {}
\r
1355 ////////////////////////////////// CascadeClassifier_GPU //////////////////////////////////////////
\r
1356 // The cascade classifier class for object detection.
\r
1357 class CV_EXPORTS CascadeClassifier_GPU
\r
1360 CascadeClassifier_GPU();
\r
1361 CascadeClassifier_GPU(const string& filename);
\r
1362 ~CascadeClassifier_GPU();
\r
1364 bool empty() const;
\r
1365 bool load(const string& filename);
\r
1368 /* returns number of detected objects */
\r
1369 int detectMultiScale( const GpuMat& image, GpuMat& objectsBuf, double scaleFactor=1.2, int minNeighbors=4, Size minSize=Size());
\r
1371 bool findLargestObject;
\r
1372 bool visualizeInPlace;
\r
1374 Size getClassifierSize() const;
\r
1377 struct CascadeClassifierImpl;
\r
1378 CascadeClassifierImpl* impl;
\r
1381 ////////////////////////////////// SURF //////////////////////////////////////////
\r
1383 class CV_EXPORTS SURF_GPU : public CvSURFParams
\r
1386 enum KeypointLayout
\r
1397 //! the default constructor
\r
1399 //! the full constructor taking all the necessary parameters
\r
1400 explicit SURF_GPU(double _hessianThreshold, int _nOctaves=4,
\r
1401 int _nOctaveLayers=2, bool _extended=false, float _keypointsRatio=0.01f, bool _upright = false);
\r
1403 //! returns the descriptor size in float's (64 or 128)
\r
1404 int descriptorSize() const;
\r
1406 //! upload host keypoints to device memory
\r
1407 void uploadKeypoints(const vector<KeyPoint>& keypoints, GpuMat& keypointsGPU);
\r
1408 //! download keypoints from device to host memory
\r
1409 void downloadKeypoints(const GpuMat& keypointsGPU, vector<KeyPoint>& keypoints);
\r
1411 //! download descriptors from device to host memory
\r
1412 void downloadDescriptors(const GpuMat& descriptorsGPU, vector<float>& descriptors);
\r
1414 //! finds the keypoints using fast hessian detector used in SURF
\r
1415 //! supports CV_8UC1 images
\r
1416 //! keypoints will have nFeature cols and 6 rows
\r
1417 //! keypoints.ptr<float>(SF_X)[i] will contain x coordinate of i'th feature
\r
1418 //! keypoints.ptr<float>(SF_Y)[i] will contain y coordinate of i'th feature
\r
1419 //! keypoints.ptr<float>(SF_LAPLACIAN)[i] will contain laplacian sign of i'th feature
\r
1420 //! keypoints.ptr<float>(SF_SIZE)[i] will contain size of i'th feature
\r
1421 //! keypoints.ptr<float>(SF_DIR)[i] will contain orientation of i'th feature
\r
1422 //! keypoints.ptr<float>(SF_HESSIAN)[i] will contain response of i'th feature
\r
1423 void operator()(const GpuMat& img, const GpuMat& mask, GpuMat& keypoints);
\r
1424 //! finds the keypoints and computes their descriptors.
\r
1425 //! Optionally it can compute descriptors for the user-provided keypoints and recompute keypoints direction
\r
1426 void operator()(const GpuMat& img, const GpuMat& mask, GpuMat& keypoints, GpuMat& descriptors,
\r
1427 bool useProvidedKeypoints = false);
\r
1429 void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints);
\r
1430 void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, GpuMat& descriptors,
\r
1431 bool useProvidedKeypoints = false);
\r
1433 void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, std::vector<float>& descriptors,
\r
1434 bool useProvidedKeypoints = false);
\r
1436 void releaseMemory();
\r
1438 //! max keypoints = min(keypointsRatio * img.size().area(), 65535)
\r
1439 float keypointsRatio;
\r
1441 GpuMat sum, mask1, maskSum, intBuffer;
\r
1443 GpuMat det, trace;
\r
1445 GpuMat maxPosBuffer;
\r
1450 //! Speckle filtering - filters small connected components on diparity image.
\r
1451 //! It sets pixel (x,y) to newVal if it coresponds to small CC with size < maxSpeckleSize.
\r
1452 //! Threshold for border between CC is diffThreshold;
\r
1453 CV_EXPORTS void filterSpeckles( Mat& img, uchar newVal, int maxSpeckleSize, uchar diffThreshold, Mat& buf);
\r
1456 #include "opencv2/gpu/matrix_operations.hpp"
\r
1458 #endif /* __OPENCV_GPU_HPP__ */
\r