cudaimgproc.hpp 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738
  1. /*M///////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
  4. //
  5. // By downloading, copying, installing or using the software you agree to this license.
  6. // If you do not agree to this license, do not download, install,
  7. // copy or use the software.
  8. //
  9. //
  10. // License Agreement
  11. // For Open Source Computer Vision Library
  12. //
  13. // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
  14. // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
  15. // Third party copyrights are property of their respective owners.
  16. //
  17. // Redistribution and use in source and binary forms, with or without modification,
  18. // are permitted provided that the following conditions are met:
  19. //
  20. // * Redistribution's of source code must retain the above copyright notice,
  21. // this list of conditions and the following disclaimer.
  22. //
  23. // * Redistribution's in binary form must reproduce the above copyright notice,
  24. // this list of conditions and the following disclaimer in the documentation
  25. // and/or other materials provided with the distribution.
  26. //
  27. // * The name of the copyright holders may not be used to endorse or promote products
  28. // derived from this software without specific prior written permission.
  29. //
  30. // This software is provided by the copyright holders and contributors "as is" and
  31. // any express or implied warranties, including, but not limited to, the implied
  32. // warranties of merchantability and fitness for a particular purpose are disclaimed.
  33. // In no event shall the Intel Corporation or contributors be liable for any direct,
  34. // indirect, incidental, special, exemplary, or consequential damages
  35. // (including, but not limited to, procurement of substitute goods or services;
  36. // loss of use, data, or profits; or business interruption) however caused
  37. // and on any theory of liability, whether in contract, strict liability,
  38. // or tort (including negligence or otherwise) arising in any way out of
  39. // the use of this software, even if advised of the possibility of such damage.
  40. //
  41. //M*/
  42. #ifndef OPENCV_CUDAIMGPROC_HPP
  43. #define OPENCV_CUDAIMGPROC_HPP
  44. #ifndef __cplusplus
  45. # error cudaimgproc.hpp header must be compiled as C++
  46. #endif
  47. #include "opencv2/core/cuda.hpp"
  48. #include "opencv2/imgproc.hpp"
  49. /**
  50. @addtogroup cuda
  51. @{
  52. @defgroup cudaimgproc Image Processing
  53. @{
  54. @defgroup cudaimgproc_color Color space processing
  55. @defgroup cudaimgproc_hist Histogram Calculation
  56. @defgroup cudaimgproc_hough Hough Transform
  57. @defgroup cudaimgproc_feature Feature Detection
  58. @}
  59. @}
  60. */
  61. namespace cv { namespace cuda {
  62. //! @addtogroup cudaimgproc
  63. //! @{
  64. /////////////////////////// Color Processing ///////////////////////////
  65. //! @addtogroup cudaimgproc_color
  66. //! @{
  67. /** @brief Converts an image from one color space to another.
  68. @param src Source image with CV_8U , CV_16U , or CV_32F depth and 1, 3, or 4 channels.
  69. @param dst Destination image.
  70. @param code Color space conversion code. For details, see cvtColor .
  71. @param dcn Number of channels in the destination image. If the parameter is 0, the number of the
  72. channels is derived automatically from src and the code .
  73. @param stream Stream for the asynchronous version.
  74. 3-channel color spaces (like HSV, XYZ, and so on) can be stored in a 4-channel image for better
  75. performance.
  76. @sa cvtColor
  77. */
  78. CV_EXPORTS void cvtColor(InputArray src, OutputArray dst, int code, int dcn = 0, Stream& stream = Stream::Null());
  79. enum DemosaicTypes
  80. {
  81. //! Bayer Demosaicing (Malvar, He, and Cutler)
  82. COLOR_BayerBG2BGR_MHT = 256,
  83. COLOR_BayerGB2BGR_MHT = 257,
  84. COLOR_BayerRG2BGR_MHT = 258,
  85. COLOR_BayerGR2BGR_MHT = 259,
  86. COLOR_BayerBG2RGB_MHT = COLOR_BayerRG2BGR_MHT,
  87. COLOR_BayerGB2RGB_MHT = COLOR_BayerGR2BGR_MHT,
  88. COLOR_BayerRG2RGB_MHT = COLOR_BayerBG2BGR_MHT,
  89. COLOR_BayerGR2RGB_MHT = COLOR_BayerGB2BGR_MHT,
  90. COLOR_BayerBG2GRAY_MHT = 260,
  91. COLOR_BayerGB2GRAY_MHT = 261,
  92. COLOR_BayerRG2GRAY_MHT = 262,
  93. COLOR_BayerGR2GRAY_MHT = 263
  94. };
  95. /** @brief Converts an image from Bayer pattern to RGB or grayscale.
  96. @param src Source image (8-bit or 16-bit single channel).
  97. @param dst Destination image.
  98. @param code Color space conversion code (see the description below).
  99. @param dcn Number of channels in the destination image. If the parameter is 0, the number of the
  100. channels is derived automatically from src and the code .
  101. @param stream Stream for the asynchronous version.
  102. The function can do the following transformations:
  103. - Demosaicing using bilinear interpolation
  104. > - COLOR_BayerBG2GRAY , COLOR_BayerGB2GRAY , COLOR_BayerRG2GRAY , COLOR_BayerGR2GRAY
  105. > - COLOR_BayerBG2BGR , COLOR_BayerGB2BGR , COLOR_BayerRG2BGR , COLOR_BayerGR2BGR
  106. - Demosaicing using Malvar-He-Cutler algorithm (@cite MHT2011)
  107. > - COLOR_BayerBG2GRAY_MHT , COLOR_BayerGB2GRAY_MHT , COLOR_BayerRG2GRAY_MHT ,
  108. > COLOR_BayerGR2GRAY_MHT
  109. > - COLOR_BayerBG2BGR_MHT , COLOR_BayerGB2BGR_MHT , COLOR_BayerRG2BGR_MHT ,
  110. > COLOR_BayerGR2BGR_MHT
  111. @sa cvtColor
  112. */
  113. CV_EXPORTS void demosaicing(InputArray src, OutputArray dst, int code, int dcn = -1, Stream& stream = Stream::Null());
  114. /** @brief Exchanges the color channels of an image in-place.
  115. @param image Source image. Supports only CV_8UC4 type.
  116. @param dstOrder Integer array describing how channel values are permutated. The n-th entry of the
  117. array contains the number of the channel that is stored in the n-th channel of the output image.
  118. E.g. Given an RGBA image, aDstOrder = [3,2,1,0] converts this to ABGR channel order.
  119. @param stream Stream for the asynchronous version.
  120. The methods support arbitrary permutations of the original channels, including replication.
  121. */
  122. CV_EXPORTS void swapChannels(InputOutputArray image, const int dstOrder[4], Stream& stream = Stream::Null());
  123. /** @brief Routines for correcting image color gamma.
  124. @param src Source image (3- or 4-channel 8 bit).
  125. @param dst Destination image.
  126. @param forward true for forward gamma correction or false for inverse gamma correction.
  127. @param stream Stream for the asynchronous version.
  128. */
  129. CV_EXPORTS void gammaCorrection(InputArray src, OutputArray dst, bool forward = true, Stream& stream = Stream::Null());
  130. enum AlphaCompTypes { ALPHA_OVER, ALPHA_IN, ALPHA_OUT, ALPHA_ATOP, ALPHA_XOR, ALPHA_PLUS, ALPHA_OVER_PREMUL, ALPHA_IN_PREMUL, ALPHA_OUT_PREMUL,
  131. ALPHA_ATOP_PREMUL, ALPHA_XOR_PREMUL, ALPHA_PLUS_PREMUL, ALPHA_PREMUL};
  132. /** @brief Composites two images using alpha opacity values contained in each image.
  133. @param img1 First image. Supports CV_8UC4 , CV_16UC4 , CV_32SC4 and CV_32FC4 types.
  134. @param img2 Second image. Must have the same size and the same type as img1 .
  135. @param dst Destination image.
  136. @param alpha_op Flag specifying the alpha-blending operation:
  137. - **ALPHA_OVER**
  138. - **ALPHA_IN**
  139. - **ALPHA_OUT**
  140. - **ALPHA_ATOP**
  141. - **ALPHA_XOR**
  142. - **ALPHA_PLUS**
  143. - **ALPHA_OVER_PREMUL**
  144. - **ALPHA_IN_PREMUL**
  145. - **ALPHA_OUT_PREMUL**
  146. - **ALPHA_ATOP_PREMUL**
  147. - **ALPHA_XOR_PREMUL**
  148. - **ALPHA_PLUS_PREMUL**
  149. - **ALPHA_PREMUL**
  150. @param stream Stream for the asynchronous version.
  151. @note
  152. - An example demonstrating the use of alphaComp can be found at
  153. opencv_source_code/samples/gpu/alpha_comp.cpp
  154. */
  155. CV_EXPORTS void alphaComp(InputArray img1, InputArray img2, OutputArray dst, int alpha_op, Stream& stream = Stream::Null());
  156. //! @} cudaimgproc_color
  157. ////////////////////////////// Histogram ///////////////////////////////
  158. //! @addtogroup cudaimgproc_hist
  159. //! @{
  160. /** @brief Calculates histogram for one channel 8-bit image.
  161. @param src Source image with CV_8UC1 type.
  162. @param hist Destination histogram with one row, 256 columns, and the CV_32SC1 type.
  163. @param stream Stream for the asynchronous version.
  164. */
  165. CV_EXPORTS void calcHist(InputArray src, OutputArray hist, Stream& stream = Stream::Null());
  166. /** @brief Calculates histogram for one channel 8-bit image confined in given mask.
  167. @param src Source image with CV_8UC1 type.
  168. @param hist Destination histogram with one row, 256 columns, and the CV_32SC1 type.
  169. @param mask A mask image same size as src and of type CV_8UC1.
  170. @param stream Stream for the asynchronous version.
  171. */
  172. CV_EXPORTS void calcHist(InputArray src, InputArray mask, OutputArray hist, Stream& stream = Stream::Null());
  173. /** @brief Equalizes the histogram of a grayscale image.
  174. @param src Source image with CV_8UC1 type.
  175. @param dst Destination image.
  176. @param stream Stream for the asynchronous version.
  177. @sa equalizeHist
  178. */
  179. CV_EXPORTS void equalizeHist(InputArray src, OutputArray dst, Stream& stream = Stream::Null());
  180. /** @brief Base class for Contrast Limited Adaptive Histogram Equalization. :
  181. */
  182. class CV_EXPORTS CLAHE : public cv::CLAHE
  183. {
  184. public:
  185. using cv::CLAHE::apply;
  186. /** @brief Equalizes the histogram of a grayscale image using Contrast Limited Adaptive Histogram Equalization.
  187. @param src Source image with CV_8UC1 type.
  188. @param dst Destination image.
  189. @param stream Stream for the asynchronous version.
  190. */
  191. virtual void apply(InputArray src, OutputArray dst, Stream& stream) = 0;
  192. };
  193. /** @brief Creates implementation for cuda::CLAHE .
  194. @param clipLimit Threshold for contrast limiting.
  195. @param tileGridSize Size of grid for histogram equalization. Input image will be divided into
  196. equally sized rectangular tiles. tileGridSize defines the number of tiles in row and column.
  197. */
  198. CV_EXPORTS Ptr<cuda::CLAHE> createCLAHE(double clipLimit = 40.0, Size tileGridSize = Size(8, 8));
  199. /** @brief Computes levels with even distribution.
  200. @param levels Destination array. levels has 1 row, nLevels columns, and the CV_32SC1 type.
  201. @param nLevels Number of computed levels. nLevels must be at least 2.
  202. @param lowerLevel Lower boundary value of the lowest level.
  203. @param upperLevel Upper boundary value of the greatest level.
  204. @param stream Stream for the asynchronous version.
  205. */
  206. CV_EXPORTS void evenLevels(OutputArray levels, int nLevels, int lowerLevel, int upperLevel, Stream& stream = Stream::Null());
  207. /** @brief Calculates a histogram with evenly distributed bins.
  208. @param src Source image. CV_8U, CV_16U, or CV_16S depth and 1 or 4 channels are supported. For
  209. a four-channel image, all channels are processed separately.
  210. @param hist Destination histogram with one row, histSize columns, and the CV_32S type.
  211. @param histSize Size of the histogram.
  212. @param lowerLevel Lower boundary of lowest-level bin.
  213. @param upperLevel Upper boundary of highest-level bin.
  214. @param stream Stream for the asynchronous version.
  215. */
  216. CV_EXPORTS void histEven(InputArray src, OutputArray hist, int histSize, int lowerLevel, int upperLevel, Stream& stream = Stream::Null());
  217. /** @overload */
  218. CV_EXPORTS void histEven(InputArray src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4], Stream& stream = Stream::Null());
  219. /** @brief Calculates a histogram with bins determined by the levels array.
  220. @param src Source image. CV_8U , CV_16U , or CV_16S depth and 1 or 4 channels are supported.
  221. For a four-channel image, all channels are processed separately.
  222. @param hist Destination histogram with one row, (levels.cols-1) columns, and the CV_32SC1 type.
  223. @param levels Number of levels in the histogram.
  224. @param stream Stream for the asynchronous version.
  225. */
  226. CV_EXPORTS void histRange(InputArray src, OutputArray hist, InputArray levels, Stream& stream = Stream::Null());
  227. /** @overload */
  228. CV_EXPORTS void histRange(InputArray src, GpuMat hist[4], const GpuMat levels[4], Stream& stream = Stream::Null());
  229. //! @} cudaimgproc_hist
  230. //////////////////////////////// Canny ////////////////////////////////
  231. /** @brief Base class for Canny Edge Detector. :
  232. */
  233. class CV_EXPORTS CannyEdgeDetector : public Algorithm
  234. {
  235. public:
  236. /** @brief Finds edges in an image using the @cite Canny86 algorithm.
  237. @param image Single-channel 8-bit input image.
  238. @param edges Output edge map. It has the same size and type as image.
  239. @param stream Stream for the asynchronous version.
  240. */
  241. virtual void detect(InputArray image, OutputArray edges, Stream& stream = Stream::Null()) = 0;
  242. /** @overload
  243. @param dx First derivative of image in the vertical direction. Support only CV_32S type.
  244. @param dy First derivative of image in the horizontal direction. Support only CV_32S type.
  245. @param edges Output edge map. It has the same size and type as image.
  246. @param stream Stream for the asynchronous version.
  247. */
  248. virtual void detect(InputArray dx, InputArray dy, OutputArray edges, Stream& stream = Stream::Null()) = 0;
  249. virtual void setLowThreshold(double low_thresh) = 0;
  250. virtual double getLowThreshold() const = 0;
  251. virtual void setHighThreshold(double high_thresh) = 0;
  252. virtual double getHighThreshold() const = 0;
  253. virtual void setAppertureSize(int apperture_size) = 0;
  254. virtual int getAppertureSize() const = 0;
  255. virtual void setL2Gradient(bool L2gradient) = 0;
  256. virtual bool getL2Gradient() const = 0;
  257. };
  258. /** @brief Creates implementation for cuda::CannyEdgeDetector .
  259. @param low_thresh First threshold for the hysteresis procedure.
  260. @param high_thresh Second threshold for the hysteresis procedure.
  261. @param apperture_size Aperture size for the Sobel operator.
  262. @param L2gradient Flag indicating whether a more accurate \f$L_2\f$ norm
  263. \f$=\sqrt{(dI/dx)^2 + (dI/dy)^2}\f$ should be used to compute the image gradient magnitude (
  264. L2gradient=true ), or a faster default \f$L_1\f$ norm \f$=|dI/dx|+|dI/dy|\f$ is enough ( L2gradient=false
  265. ).
  266. */
  267. CV_EXPORTS Ptr<CannyEdgeDetector> createCannyEdgeDetector(double low_thresh, double high_thresh, int apperture_size = 3, bool L2gradient = false);
  268. /////////////////////////// Hough Transform ////////////////////////////
  269. //////////////////////////////////////
  270. // HoughLines
  271. //! @addtogroup cudaimgproc_hough
  272. //! @{
  273. /** @brief Base class for lines detector algorithm. :
  274. */
  275. class CV_EXPORTS HoughLinesDetector : public Algorithm
  276. {
  277. public:
  278. /** @brief Finds lines in a binary image using the classical Hough transform.
  279. @param src 8-bit, single-channel binary source image.
  280. @param lines Output vector of lines. Each line is represented by a two-element vector
  281. \f$(\rho, \theta)\f$ . \f$\rho\f$ is the distance from the coordinate origin \f$(0,0)\f$ (top-left corner of
  282. the image). \f$\theta\f$ is the line rotation angle in radians (
  283. \f$0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line}\f$ ).
  284. @param stream Stream for the asynchronous version.
  285. @sa HoughLines
  286. */
  287. virtual void detect(InputArray src, OutputArray lines, Stream& stream = Stream::Null()) = 0;
  288. /** @brief Downloads results from cuda::HoughLinesDetector::detect to host memory.
  289. @param d_lines Result of cuda::HoughLinesDetector::detect .
  290. @param h_lines Output host array.
  291. @param h_votes Optional output array for line's votes.
  292. @param stream Stream for the asynchronous version.
  293. */
  294. virtual void downloadResults(InputArray d_lines, OutputArray h_lines, OutputArray h_votes = noArray(), Stream& stream = Stream::Null()) = 0;
  295. virtual void setRho(float rho) = 0;
  296. virtual float getRho() const = 0;
  297. virtual void setTheta(float theta) = 0;
  298. virtual float getTheta() const = 0;
  299. virtual void setThreshold(int threshold) = 0;
  300. virtual int getThreshold() const = 0;
  301. virtual void setDoSort(bool doSort) = 0;
  302. virtual bool getDoSort() const = 0;
  303. virtual void setMaxLines(int maxLines) = 0;
  304. virtual int getMaxLines() const = 0;
  305. };
  306. /** @brief Creates implementation for cuda::HoughLinesDetector .
  307. @param rho Distance resolution of the accumulator in pixels.
  308. @param theta Angle resolution of the accumulator in radians.
  309. @param threshold Accumulator threshold parameter. Only those lines are returned that get enough
  310. votes ( \f$>\texttt{threshold}\f$ ).
  311. @param doSort Performs lines sort by votes.
  312. @param maxLines Maximum number of output lines.
  313. */
  314. CV_EXPORTS Ptr<HoughLinesDetector> createHoughLinesDetector(float rho, float theta, int threshold, bool doSort = false, int maxLines = 4096);
  315. //////////////////////////////////////
  316. // HoughLinesP
  317. /** @brief Base class for line segments detector algorithm. :
  318. */
  319. class CV_EXPORTS HoughSegmentDetector : public Algorithm
  320. {
  321. public:
  322. /** @brief Finds line segments in a binary image using the probabilistic Hough transform.
  323. @param src 8-bit, single-channel binary source image.
  324. @param lines Output vector of lines. Each line is represented by a 4-element vector
  325. \f$(x_1, y_1, x_2, y_2)\f$ , where \f$(x_1,y_1)\f$ and \f$(x_2, y_2)\f$ are the ending points of each detected
  326. line segment.
  327. @param stream Stream for the asynchronous version.
  328. @sa HoughLinesP
  329. */
  330. virtual void detect(InputArray src, OutputArray lines, Stream& stream = Stream::Null()) = 0;
  331. virtual void setRho(float rho) = 0;
  332. virtual float getRho() const = 0;
  333. virtual void setTheta(float theta) = 0;
  334. virtual float getTheta() const = 0;
  335. virtual void setMinLineLength(int minLineLength) = 0;
  336. virtual int getMinLineLength() const = 0;
  337. virtual void setMaxLineGap(int maxLineGap) = 0;
  338. virtual int getMaxLineGap() const = 0;
  339. virtual void setMaxLines(int maxLines) = 0;
  340. virtual int getMaxLines() const = 0;
  341. };
  342. /** @brief Creates implementation for cuda::HoughSegmentDetector .
  343. @param rho Distance resolution of the accumulator in pixels.
  344. @param theta Angle resolution of the accumulator in radians.
  345. @param minLineLength Minimum line length. Line segments shorter than that are rejected.
  346. @param maxLineGap Maximum allowed gap between points on the same line to link them.
  347. @param maxLines Maximum number of output lines.
  348. */
  349. CV_EXPORTS Ptr<HoughSegmentDetector> createHoughSegmentDetector(float rho, float theta, int minLineLength, int maxLineGap, int maxLines = 4096);
  350. //////////////////////////////////////
  351. // HoughCircles
  352. /** @brief Base class for circles detector algorithm. :
  353. */
  354. class CV_EXPORTS HoughCirclesDetector : public Algorithm
  355. {
  356. public:
  357. /** @brief Finds circles in a grayscale image using the Hough transform.
  358. @param src 8-bit, single-channel grayscale input image.
  359. @param circles Output vector of found circles. Each vector is encoded as a 3-element
  360. floating-point vector \f$(x, y, radius)\f$ .
  361. @param stream Stream for the asynchronous version.
  362. @sa HoughCircles
  363. */
  364. virtual void detect(InputArray src, OutputArray circles, Stream& stream = Stream::Null()) = 0;
  365. virtual void setDp(float dp) = 0;
  366. virtual float getDp() const = 0;
  367. virtual void setMinDist(float minDist) = 0;
  368. virtual float getMinDist() const = 0;
  369. virtual void setCannyThreshold(int cannyThreshold) = 0;
  370. virtual int getCannyThreshold() const = 0;
  371. virtual void setVotesThreshold(int votesThreshold) = 0;
  372. virtual int getVotesThreshold() const = 0;
  373. virtual void setMinRadius(int minRadius) = 0;
  374. virtual int getMinRadius() const = 0;
  375. virtual void setMaxRadius(int maxRadius) = 0;
  376. virtual int getMaxRadius() const = 0;
  377. virtual void setMaxCircles(int maxCircles) = 0;
  378. virtual int getMaxCircles() const = 0;
  379. };
  380. /** @brief Creates implementation for cuda::HoughCirclesDetector .
  381. @param dp Inverse ratio of the accumulator resolution to the image resolution. For example, if
  382. dp=1 , the accumulator has the same resolution as the input image. If dp=2 , the accumulator has
  383. half as big width and height.
  384. @param minDist Minimum distance between the centers of the detected circles. If the parameter is
  385. too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is
  386. too large, some circles may be missed.
  387. @param cannyThreshold The higher threshold of the two passed to Canny edge detector (the lower one
  388. is twice smaller).
  389. @param votesThreshold The accumulator threshold for the circle centers at the detection stage. The
  390. smaller it is, the more false circles may be detected.
  391. @param minRadius Minimum circle radius.
  392. @param maxRadius Maximum circle radius.
  393. @param maxCircles Maximum number of output circles.
  394. */
  395. CV_EXPORTS Ptr<HoughCirclesDetector> createHoughCirclesDetector(float dp, float minDist, int cannyThreshold, int votesThreshold, int minRadius, int maxRadius, int maxCircles = 4096);
  396. //////////////////////////////////////
  397. // GeneralizedHough
  398. /** @brief Creates implementation for generalized hough transform from @cite Ballard1981 .
  399. */
  400. CV_EXPORTS Ptr<GeneralizedHoughBallard> createGeneralizedHoughBallard();
  401. /** @brief Creates implementation for generalized hough transform from @cite Guil1999 .
  402. */
  403. CV_EXPORTS Ptr<GeneralizedHoughGuil> createGeneralizedHoughGuil();
  404. //! @} cudaimgproc_hough
  405. ////////////////////////// Corners Detection ///////////////////////////
  406. //! @addtogroup cudaimgproc_feature
  407. //! @{
  408. /** @brief Base class for Cornerness Criteria computation. :
  409. */
  410. class CV_EXPORTS CornernessCriteria : public Algorithm
  411. {
  412. public:
  413. /** @brief Computes the cornerness criteria at each image pixel.
  414. @param src Source image.
  415. @param dst Destination image containing cornerness values. It will have the same size as src and
  416. CV_32FC1 type.
  417. @param stream Stream for the asynchronous version.
  418. */
  419. virtual void compute(InputArray src, OutputArray dst, Stream& stream = Stream::Null()) = 0;
  420. };
  421. /** @brief Creates implementation for Harris cornerness criteria.
  422. @param srcType Input source type. Only CV_8UC1 and CV_32FC1 are supported for now.
  423. @param blockSize Neighborhood size.
  424. @param ksize Aperture parameter for the Sobel operator.
  425. @param k Harris detector free parameter.
  426. @param borderType Pixel extrapolation method. Only BORDER_REFLECT101 and BORDER_REPLICATE are
  427. supported for now.
  428. @sa cornerHarris
  429. */
  430. CV_EXPORTS Ptr<CornernessCriteria> createHarrisCorner(int srcType, int blockSize, int ksize, double k, int borderType = BORDER_REFLECT101);
  431. /** @brief Creates implementation for the minimum eigen value of a 2x2 derivative covariation matrix (the
  432. cornerness criteria).
  433. @param srcType Input source type. Only CV_8UC1 and CV_32FC1 are supported for now.
  434. @param blockSize Neighborhood size.
  435. @param ksize Aperture parameter for the Sobel operator.
  436. @param borderType Pixel extrapolation method. Only BORDER_REFLECT101 and BORDER_REPLICATE are
  437. supported for now.
  438. @sa cornerMinEigenVal
  439. */
  440. CV_EXPORTS Ptr<CornernessCriteria> createMinEigenValCorner(int srcType, int blockSize, int ksize, int borderType = BORDER_REFLECT101);
  441. ////////////////////////// Corners Detection ///////////////////////////
  442. /** @brief Base class for Corners Detector. :
  443. */
  444. class CV_EXPORTS CornersDetector : public Algorithm
  445. {
  446. public:
  447. /** @brief Determines strong corners on an image.
  448. @param image Input 8-bit or floating-point 32-bit, single-channel image.
  449. @param corners Output vector of detected corners (1-row matrix with CV_32FC2 type with corners
  450. positions).
  451. @param mask Optional region of interest. If the image is not empty (it needs to have the type
  452. CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
  453. @param stream Stream for the asynchronous version.
  454. */
  455. virtual void detect(InputArray image, OutputArray corners, InputArray mask = noArray(), Stream& stream = Stream::Null()) = 0;
  456. };
  457. /** @brief Creates implementation for cuda::CornersDetector .
  458. @param srcType Input source type. Only CV_8UC1 and CV_32FC1 are supported for now.
  459. @param maxCorners Maximum number of corners to return. If there are more corners than are found,
  460. the strongest of them is returned.
  461. @param qualityLevel Parameter characterizing the minimal accepted quality of image corners. The
  462. parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue
  463. (see cornerMinEigenVal ) or the Harris function response (see cornerHarris ). The corners with the
  464. quality measure less than the product are rejected. For example, if the best corner has the
  465. quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure
  466. less than 15 are rejected.
  467. @param minDistance Minimum possible Euclidean distance between the returned corners.
  468. @param blockSize Size of an average block for computing a derivative covariation matrix over each
  469. pixel neighborhood. See cornerEigenValsAndVecs .
  470. @param useHarrisDetector Parameter indicating whether to use a Harris detector (see cornerHarris)
  471. or cornerMinEigenVal.
  472. @param harrisK Free parameter of the Harris detector.
  473. */
  474. CV_EXPORTS Ptr<CornersDetector> createGoodFeaturesToTrackDetector(int srcType, int maxCorners = 1000, double qualityLevel = 0.01, double minDistance = 0.0,
  475. int blockSize = 3, bool useHarrisDetector = false, double harrisK = 0.04);
  476. //! @} cudaimgproc_feature
  477. ///////////////////////////// Mean Shift //////////////////////////////
  478. /** @brief Performs mean-shift filtering for each point of the source image.
  479. @param src Source image. Only CV_8UC4 images are supported for now.
  480. @param dst Destination image containing the color of mapped points. It has the same size and type
  481. as src .
  482. @param sp Spatial window radius.
  483. @param sr Color window radius.
  484. @param criteria Termination criteria. See TermCriteria.
  485. @param stream Stream for the asynchronous version.
  486. It maps each point of the source image into another point. As a result, you have a new color and new
  487. position of each point.
  488. */
  489. CV_EXPORTS void meanShiftFiltering(InputArray src, OutputArray dst, int sp, int sr,
  490. TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1),
  491. Stream& stream = Stream::Null());
  492. /** @brief Performs a mean-shift procedure and stores information about processed points (their colors and
  493. positions) in two images.
  494. @param src Source image. Only CV_8UC4 images are supported for now.
  495. @param dstr Destination image containing the color of mapped points. The size and type is the same
  496. as src .
  497. @param dstsp Destination image containing the position of mapped points. The size is the same as
  498. src size. The type is CV_16SC2 .
  499. @param sp Spatial window radius.
  500. @param sr Color window radius.
  501. @param criteria Termination criteria. See TermCriteria.
  502. @param stream Stream for the asynchronous version.
  503. @sa cuda::meanShiftFiltering
  504. */
  505. CV_EXPORTS void meanShiftProc(InputArray src, OutputArray dstr, OutputArray dstsp, int sp, int sr,
  506. TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1),
  507. Stream& stream = Stream::Null());
  508. /** @brief Performs a mean-shift segmentation of the source image and eliminates small segments.
  509. @param src Source image. Only CV_8UC4 images are supported for now.
  510. @param dst Segmented image with the same size and type as src (host memory).
  511. @param sp Spatial window radius.
  512. @param sr Color window radius.
  513. @param minsize Minimum segment size. Smaller segments are merged.
  514. @param criteria Termination criteria. See TermCriteria.
  515. @param stream Stream for the asynchronous version.
  516. */
  517. CV_EXPORTS void meanShiftSegmentation(InputArray src, OutputArray dst, int sp, int sr, int minsize,
  518. TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1),
  519. Stream& stream = Stream::Null());
  520. /////////////////////////// Match Template ////////////////////////////
  521. /** @brief Base class for Template Matching. :
  522. */
  523. class CV_EXPORTS TemplateMatching : public Algorithm
  524. {
  525. public:
  526. /** @brief Computes a proximity map for a raster template and an image where the template is searched for.
  527. @param image Source image.
  528. @param templ Template image with the size and type the same as image .
  529. @param result Map containing comparison results ( CV_32FC1 ). If image is *W x H* and templ is *w
  530. x h*, then result must be *W-w+1 x H-h+1*.
  531. @param stream Stream for the asynchronous version.
  532. */
  533. virtual void match(InputArray image, InputArray templ, OutputArray result, Stream& stream = Stream::Null()) = 0;
  534. };
  535. /** @brief Creates implementation for cuda::TemplateMatching .
  536. @param srcType Input source type. CV_32F and CV_8U depth images (1..4 channels) are supported
  537. for now.
  538. @param method Specifies the way to compare the template with the image.
  539. @param user_block_size You can use field user_block_size to set specific block size. If you
  540. leave its default value Size(0,0) then automatic estimation of block size will be used (which is
  541. optimized for speed). By varying user_block_size you can reduce memory requirements at the cost
  542. of speed.
  543. The following methods are supported for the CV_8U depth images for now:
  544. - CV_TM_SQDIFF
  545. - CV_TM_SQDIFF_NORMED
  546. - CV_TM_CCORR
  547. - CV_TM_CCORR_NORMED
  548. - CV_TM_CCOEFF
  549. - CV_TM_CCOEFF_NORMED
  550. The following methods are supported for the CV_32F images for now:
  551. - CV_TM_SQDIFF
  552. - CV_TM_CCORR
  553. @sa matchTemplate
  554. */
  555. CV_EXPORTS Ptr<TemplateMatching> createTemplateMatching(int srcType, int method, Size user_block_size = Size());
  556. ////////////////////////// Bilateral Filter ///////////////////////////
  557. /** @brief Performs bilateral filtering of passed image
  558. @param src Source image. Supports only (channels != 2 && depth() != CV_8S && depth() != CV_32S
  559. && depth() != CV_64F).
  560. @param dst Destination imagwe.
  561. @param kernel_size Kernel window size.
  562. @param sigma_color Filter sigma in the color space.
  563. @param sigma_spatial Filter sigma in the coordinate space.
  564. @param borderMode Border type. See borderInterpolate for details. BORDER_REFLECT101 ,
  565. BORDER_REPLICATE , BORDER_CONSTANT , BORDER_REFLECT and BORDER_WRAP are supported for now.
  566. @param stream Stream for the asynchronous version.
  567. @sa bilateralFilter
  568. */
  569. CV_EXPORTS void bilateralFilter(InputArray src, OutputArray dst, int kernel_size, float sigma_color, float sigma_spatial,
  570. int borderMode = BORDER_DEFAULT, Stream& stream = Stream::Null());
  571. ///////////////////////////// Blending ////////////////////////////////
  572. /** @brief Performs linear blending of two images.
  573. @param img1 First image. Supports only CV_8U and CV_32F depth.
  574. @param img2 Second image. Must have the same size and the same type as img1 .
  575. @param weights1 Weights for first image. Must have tha same size as img1 . Supports only CV_32F
  576. type.
  577. @param weights2 Weights for second image. Must have tha same size as img2 . Supports only CV_32F
  578. type.
  579. @param result Destination image.
  580. @param stream Stream for the asynchronous version.
  581. */
  582. CV_EXPORTS void blendLinear(InputArray img1, InputArray img2, InputArray weights1, InputArray weights2,
  583. OutputArray result, Stream& stream = Stream::Null());
  584. //! @}
  585. }} // namespace cv { namespace cuda {
  586. #endif /* OPENCV_CUDAIMGPROC_HPP */