imgproc_c.h 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  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_IMGPROC_IMGPROC_C_H
  43. #define OPENCV_IMGPROC_IMGPROC_C_H
  44. #include "opencv2/imgproc/types_c.h"
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48. /** @addtogroup imgproc_c
  49. @{
  50. */
  51. /*********************** Background statistics accumulation *****************************/
  52. /** @brief Adds image to accumulator
  53. @see cv::accumulate
  54. */
  55. CVAPI(void) cvAcc( const CvArr* image, CvArr* sum,
  56. const CvArr* mask CV_DEFAULT(NULL) );
  57. /** @brief Adds squared image to accumulator
  58. @see cv::accumulateSquare
  59. */
  60. CVAPI(void) cvSquareAcc( const CvArr* image, CvArr* sqsum,
  61. const CvArr* mask CV_DEFAULT(NULL) );
  62. /** @brief Adds a product of two images to accumulator
  63. @see cv::accumulateProduct
  64. */
  65. CVAPI(void) cvMultiplyAcc( const CvArr* image1, const CvArr* image2, CvArr* acc,
  66. const CvArr* mask CV_DEFAULT(NULL) );
  67. /** @brief Adds image to accumulator with weights: acc = acc*(1-alpha) + image*alpha
  68. @see cv::accumulateWeighted
  69. */
  70. CVAPI(void) cvRunningAvg( const CvArr* image, CvArr* acc, double alpha,
  71. const CvArr* mask CV_DEFAULT(NULL) );
  72. /****************************************************************************************\
  73. * Image Processing *
  74. \****************************************************************************************/
  75. /** Copies source 2D array inside of the larger destination array and
  76. makes a border of the specified type (IPL_BORDER_*) around the copied area. */
  77. CVAPI(void) cvCopyMakeBorder( const CvArr* src, CvArr* dst, CvPoint offset,
  78. int bordertype, CvScalar value CV_DEFAULT(cvScalarAll(0)));
  79. /** @brief Smooths the image in one of several ways.
  80. @param src The source image
  81. @param dst The destination image
  82. @param smoothtype Type of the smoothing, see SmoothMethod_c
  83. @param size1 The first parameter of the smoothing operation, the aperture width. Must be a
  84. positive odd number (1, 3, 5, ...)
  85. @param size2 The second parameter of the smoothing operation, the aperture height. Ignored by
  86. CV_MEDIAN and CV_BILATERAL methods. In the case of simple scaled/non-scaled and Gaussian blur if
  87. size2 is zero, it is set to size1. Otherwise it must be a positive odd number.
  88. @param sigma1 In the case of a Gaussian parameter this parameter may specify Gaussian \f$\sigma\f$
  89. (standard deviation). If it is zero, it is calculated from the kernel size:
  90. \f[\sigma = 0.3 (n/2 - 1) + 0.8 \quad \text{where} \quad n= \begin{array}{l l} \mbox{\texttt{size1} for horizontal kernel} \\ \mbox{\texttt{size2} for vertical kernel} \end{array}\f]
  91. Using standard sigma for small kernels ( \f$3\times 3\f$ to \f$7\times 7\f$ ) gives better speed. If
  92. sigma1 is not zero, while size1 and size2 are zeros, the kernel size is calculated from the
  93. sigma (to provide accurate enough operation).
  94. @param sigma2 additional parameter for bilateral filtering
  95. @see cv::GaussianBlur, cv::blur, cv::medianBlur, cv::bilateralFilter.
  96. */
  97. CVAPI(void) cvSmooth( const CvArr* src, CvArr* dst,
  98. int smoothtype CV_DEFAULT(CV_GAUSSIAN),
  99. int size1 CV_DEFAULT(3),
  100. int size2 CV_DEFAULT(0),
  101. double sigma1 CV_DEFAULT(0),
  102. double sigma2 CV_DEFAULT(0));
  103. /** @brief Convolves an image with the kernel.
  104. @param src input image.
  105. @param dst output image of the same size and the same number of channels as src.
  106. @param kernel convolution kernel (or rather a correlation kernel), a single-channel floating point
  107. matrix; if you want to apply different kernels to different channels, split the image into
  108. separate color planes using split and process them individually.
  109. @param anchor anchor of the kernel that indicates the relative position of a filtered point within
  110. the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor
  111. is at the kernel center.
  112. @see cv::filter2D
  113. */
  114. CVAPI(void) cvFilter2D( const CvArr* src, CvArr* dst, const CvMat* kernel,
  115. CvPoint anchor CV_DEFAULT(cvPoint(-1,-1)));
  116. /** @brief Finds integral image: SUM(X,Y) = sum(x<X,y<Y)I(x,y)
  117. @see cv::integral
  118. */
  119. CVAPI(void) cvIntegral( const CvArr* image, CvArr* sum,
  120. CvArr* sqsum CV_DEFAULT(NULL),
  121. CvArr* tilted_sum CV_DEFAULT(NULL));
  122. /** @brief Smoothes the input image with gaussian kernel and then down-samples it.
  123. dst_width = floor(src_width/2)[+1],
  124. dst_height = floor(src_height/2)[+1]
  125. @see cv::pyrDown
  126. */
  127. CVAPI(void) cvPyrDown( const CvArr* src, CvArr* dst,
  128. int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
  129. /** @brief Up-samples image and smoothes the result with gaussian kernel.
  130. dst_width = src_width*2,
  131. dst_height = src_height*2
  132. @see cv::pyrUp
  133. */
  134. CVAPI(void) cvPyrUp( const CvArr* src, CvArr* dst,
  135. int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
  136. /** @brief Builds pyramid for an image
  137. @see buildPyramid
  138. */
  139. CVAPI(CvMat**) cvCreatePyramid( const CvArr* img, int extra_layers, double rate,
  140. const CvSize* layer_sizes CV_DEFAULT(0),
  141. CvArr* bufarr CV_DEFAULT(0),
  142. int calc CV_DEFAULT(1),
  143. int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
  144. /** @brief Releases pyramid */
  145. CVAPI(void) cvReleasePyramid( CvMat*** pyramid, int extra_layers );
  146. /** @brief Filters image using meanshift algorithm
  147. @see cv::pyrMeanShiftFiltering
  148. */
  149. CVAPI(void) cvPyrMeanShiftFiltering( const CvArr* src, CvArr* dst,
  150. double sp, double sr, int max_level CV_DEFAULT(1),
  151. CvTermCriteria termcrit CV_DEFAULT(cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,5,1)));
  152. /** @brief Segments image using seed "markers"
  153. @see cv::watershed
  154. */
  155. CVAPI(void) cvWatershed( const CvArr* image, CvArr* markers );
  156. /** @brief Calculates an image derivative using generalized Sobel
  157. (aperture_size = 1,3,5,7) or Scharr (aperture_size = -1) operator.
  158. Scharr can be used only for the first dx or dy derivative
  159. @see cv::Sobel
  160. */
  161. CVAPI(void) cvSobel( const CvArr* src, CvArr* dst,
  162. int xorder, int yorder,
  163. int aperture_size CV_DEFAULT(3));
  164. /** @brief Calculates the image Laplacian: (d2/dx + d2/dy)I
  165. @see cv::Laplacian
  166. */
  167. CVAPI(void) cvLaplace( const CvArr* src, CvArr* dst,
  168. int aperture_size CV_DEFAULT(3) );
  169. /** @brief Converts input array pixels from one color space to another
  170. @see cv::cvtColor
  171. */
  172. CVAPI(void) cvCvtColor( const CvArr* src, CvArr* dst, int code );
  173. /** @brief Resizes image (input array is resized to fit the destination array)
  174. @see cv::resize
  175. */
  176. CVAPI(void) cvResize( const CvArr* src, CvArr* dst,
  177. int interpolation CV_DEFAULT( CV_INTER_LINEAR ));
  178. /** @brief Warps image with affine transform
  179. @note ::cvGetQuadrangleSubPix is similar to ::cvWarpAffine, but the outliers are extrapolated using
  180. replication border mode.
  181. @see cv::warpAffine
  182. */
  183. CVAPI(void) cvWarpAffine( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
  184. int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
  185. CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
  186. /** @brief Computes affine transform matrix for mapping src[i] to dst[i] (i=0,1,2)
  187. @see cv::getAffineTransform
  188. */
  189. CVAPI(CvMat*) cvGetAffineTransform( const CvPoint2D32f * src,
  190. const CvPoint2D32f * dst,
  191. CvMat * map_matrix );
  192. /** @brief Computes rotation_matrix matrix
  193. @see cv::getRotationMatrix2D
  194. */
  195. CVAPI(CvMat*) cv2DRotationMatrix( CvPoint2D32f center, double angle,
  196. double scale, CvMat* map_matrix );
  197. /** @brief Warps image with perspective (projective) transform
  198. @see cv::warpPerspective
  199. */
  200. CVAPI(void) cvWarpPerspective( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
  201. int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
  202. CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
  203. /** @brief Computes perspective transform matrix for mapping src[i] to dst[i] (i=0,1,2,3)
  204. @see cv::getPerspectiveTransform
  205. */
  206. CVAPI(CvMat*) cvGetPerspectiveTransform( const CvPoint2D32f* src,
  207. const CvPoint2D32f* dst,
  208. CvMat* map_matrix );
  209. /** @brief Performs generic geometric transformation using the specified coordinate maps
  210. @see cv::remap
  211. */
  212. CVAPI(void) cvRemap( const CvArr* src, CvArr* dst,
  213. const CvArr* mapx, const CvArr* mapy,
  214. int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
  215. CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
  216. /** @brief Converts mapx & mapy from floating-point to integer formats for cvRemap
  217. @see cv::convertMaps
  218. */
  219. CVAPI(void) cvConvertMaps( const CvArr* mapx, const CvArr* mapy,
  220. CvArr* mapxy, CvArr* mapalpha );
  221. /** @brief Performs forward or inverse log-polar image transform
  222. @see cv::warpPolar
  223. */
  224. CVAPI(void) cvLogPolar( const CvArr* src, CvArr* dst,
  225. CvPoint2D32f center, double M,
  226. int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
  227. /** Performs forward or inverse linear-polar image transform
  228. @see cv::warpPolar
  229. */
  230. CVAPI(void) cvLinearPolar( const CvArr* src, CvArr* dst,
  231. CvPoint2D32f center, double maxRadius,
  232. int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
  233. /** @brief Returns a structuring element of the specified size and shape for morphological operations.
  234. @note the created structuring element IplConvKernel\* element must be released in the end using
  235. `cvReleaseStructuringElement(&element)`.
  236. @param cols Width of the structuring element
  237. @param rows Height of the structuring element
  238. @param anchor_x x-coordinate of the anchor
  239. @param anchor_y y-coordinate of the anchor
  240. @param shape element shape that could be one of the cv::MorphShapes_c
  241. @param values integer array of cols*rows elements that specifies the custom shape of the
  242. structuring element, when shape=CV_SHAPE_CUSTOM.
  243. @see cv::getStructuringElement
  244. */
  245. CVAPI(IplConvKernel*) cvCreateStructuringElementEx(
  246. int cols, int rows, int anchor_x, int anchor_y,
  247. int shape, int* values CV_DEFAULT(NULL) );
  248. /** @brief releases structuring element
  249. @see cvCreateStructuringElementEx
  250. */
  251. CVAPI(void) cvReleaseStructuringElement( IplConvKernel** element );
  252. /** @brief erodes input image (applies minimum filter) one or more times.
  253. If element pointer is NULL, 3x3 rectangular element is used
  254. @see cv::erode
  255. */
  256. CVAPI(void) cvErode( const CvArr* src, CvArr* dst,
  257. IplConvKernel* element CV_DEFAULT(NULL),
  258. int iterations CV_DEFAULT(1) );
  259. /** @brief dilates input image (applies maximum filter) one or more times.
  260. If element pointer is NULL, 3x3 rectangular element is used
  261. @see cv::dilate
  262. */
  263. CVAPI(void) cvDilate( const CvArr* src, CvArr* dst,
  264. IplConvKernel* element CV_DEFAULT(NULL),
  265. int iterations CV_DEFAULT(1) );
  266. /** @brief Performs complex morphological transformation
  267. @see cv::morphologyEx
  268. */
  269. CVAPI(void) cvMorphologyEx( const CvArr* src, CvArr* dst,
  270. CvArr* temp, IplConvKernel* element,
  271. int operation, int iterations CV_DEFAULT(1) );
  272. /** @brief Calculates all spatial and central moments up to the 3rd order
  273. @see cv::moments
  274. */
  275. CVAPI(void) cvMoments( const CvArr* arr, CvMoments* moments, int binary CV_DEFAULT(0));
  276. /** @brief Retrieve spatial moments */
  277. CVAPI(double) cvGetSpatialMoment( CvMoments* moments, int x_order, int y_order );
  278. /** @brief Retrieve central moments */
  279. CVAPI(double) cvGetCentralMoment( CvMoments* moments, int x_order, int y_order );
  280. /** @brief Retrieve normalized central moments */
  281. CVAPI(double) cvGetNormalizedCentralMoment( CvMoments* moments,
  282. int x_order, int y_order );
  283. /** @brief Calculates 7 Hu's invariants from precalculated spatial and central moments
  284. @see cv::HuMoments
  285. */
  286. CVAPI(void) cvGetHuMoments( CvMoments* moments, CvHuMoments* hu_moments );
  287. /*********************************** data sampling **************************************/
  288. /** @brief Fetches pixels that belong to the specified line segment and stores them to the buffer.
  289. Returns the number of retrieved points.
  290. @see cv::LineSegmentDetector
  291. */
  292. CVAPI(int) cvSampleLine( const CvArr* image, CvPoint pt1, CvPoint pt2, void* buffer,
  293. int connectivity CV_DEFAULT(8));
  294. /** @brief Retrieves the rectangular image region with specified center from the input array.
  295. dst(x,y) <- src(x + center.x - dst_width/2, y + center.y - dst_height/2).
  296. Values of pixels with fractional coordinates are retrieved using bilinear interpolation
  297. @see cv::getRectSubPix
  298. */
  299. CVAPI(void) cvGetRectSubPix( const CvArr* src, CvArr* dst, CvPoint2D32f center );
  300. /** @brief Retrieves quadrangle from the input array.
  301. matrixarr = ( a11 a12 | b1 ) dst(x,y) <- src(A[x y]' + b)
  302. ( a21 a22 | b2 ) (bilinear interpolation is used to retrieve pixels
  303. with fractional coordinates)
  304. @see cvWarpAffine
  305. */
  306. CVAPI(void) cvGetQuadrangleSubPix( const CvArr* src, CvArr* dst,
  307. const CvMat* map_matrix );
  308. /** @brief Measures similarity between template and overlapped windows in the source image
  309. and fills the resultant image with the measurements
  310. @see cv::matchTemplate
  311. */
  312. CVAPI(void) cvMatchTemplate( const CvArr* image, const CvArr* templ,
  313. CvArr* result, int method );
  314. /** @brief Computes earth mover distance between
  315. two weighted point sets (called signatures)
  316. @see cv::EMD
  317. */
  318. CVAPI(float) cvCalcEMD2( const CvArr* signature1,
  319. const CvArr* signature2,
  320. int distance_type,
  321. CvDistanceFunction distance_func CV_DEFAULT(NULL),
  322. const CvArr* cost_matrix CV_DEFAULT(NULL),
  323. CvArr* flow CV_DEFAULT(NULL),
  324. float* lower_bound CV_DEFAULT(NULL),
  325. void* userdata CV_DEFAULT(NULL));
  326. /****************************************************************************************\
  327. * Contours retrieving *
  328. \****************************************************************************************/
  329. /** @brief Retrieves outer and optionally inner boundaries of white (non-zero) connected
  330. components in the black (zero) background
  331. @see cv::findContours, cvStartFindContours, cvFindNextContour, cvSubstituteContour, cvEndFindContours
  332. */
  333. CVAPI(int) cvFindContours( CvArr* image, CvMemStorage* storage, CvSeq** first_contour,
  334. int header_size CV_DEFAULT(sizeof(CvContour)),
  335. int mode CV_DEFAULT(CV_RETR_LIST),
  336. int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
  337. CvPoint offset CV_DEFAULT(cvPoint(0,0)));
  338. /** @brief Initializes contour retrieving process.
  339. Calls cvStartFindContours.
  340. Calls cvFindNextContour until null pointer is returned
  341. or some other condition becomes true.
  342. Calls cvEndFindContours at the end.
  343. @see cvFindContours
  344. */
  345. CVAPI(CvContourScanner) cvStartFindContours( CvArr* image, CvMemStorage* storage,
  346. int header_size CV_DEFAULT(sizeof(CvContour)),
  347. int mode CV_DEFAULT(CV_RETR_LIST),
  348. int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
  349. CvPoint offset CV_DEFAULT(cvPoint(0,0)));
  350. /** @brief Retrieves next contour
  351. @see cvFindContours
  352. */
  353. CVAPI(CvSeq*) cvFindNextContour( CvContourScanner scanner );
  354. /** @brief Substitutes the last retrieved contour with the new one
  355. (if the substitutor is null, the last retrieved contour is removed from the tree)
  356. @see cvFindContours
  357. */
  358. CVAPI(void) cvSubstituteContour( CvContourScanner scanner, CvSeq* new_contour );
  359. /** @brief Releases contour scanner and returns pointer to the first outer contour
  360. @see cvFindContours
  361. */
  362. CVAPI(CvSeq*) cvEndFindContours( CvContourScanner* scanner );
  363. /** @brief Approximates Freeman chain(s) with a polygonal curve.
  364. This is a standalone contour approximation routine, not represented in the new interface. When
  365. cvFindContours retrieves contours as Freeman chains, it calls the function to get approximated
  366. contours, represented as polygons.
  367. @param src_seq Pointer to the approximated Freeman chain that can refer to other chains.
  368. @param storage Storage location for the resulting polylines.
  369. @param method Approximation method (see the description of the function :ocvFindContours ).
  370. @param parameter Method parameter (not used now).
  371. @param minimal_perimeter Approximates only those contours whose perimeters are not less than
  372. minimal_perimeter . Other chains are removed from the resulting structure.
  373. @param recursive Recursion flag. If it is non-zero, the function approximates all chains that can
  374. be obtained from chain by using the h_next or v_next links. Otherwise, the single input chain is
  375. approximated.
  376. @see cvStartReadChainPoints, cvReadChainPoint
  377. */
  378. CVAPI(CvSeq*) cvApproxChains( CvSeq* src_seq, CvMemStorage* storage,
  379. int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
  380. double parameter CV_DEFAULT(0),
  381. int minimal_perimeter CV_DEFAULT(0),
  382. int recursive CV_DEFAULT(0));
  383. /** @brief Initializes Freeman chain reader.
  384. The reader is used to iteratively get coordinates of all the chain points.
  385. If the Freeman codes should be read as is, a simple sequence reader should be used
  386. @see cvApproxChains
  387. */
  388. CVAPI(void) cvStartReadChainPoints( CvChain* chain, CvChainPtReader* reader );
  389. /** @brief Retrieves the next chain point
  390. @see cvApproxChains
  391. */
  392. CVAPI(CvPoint) cvReadChainPoint( CvChainPtReader* reader );
  393. /****************************************************************************************\
  394. * Contour Processing and Shape Analysis *
  395. \****************************************************************************************/
  396. /** @brief Approximates a single polygonal curve (contour) or
  397. a tree of polygonal curves (contours)
  398. @see cv::approxPolyDP
  399. */
  400. CVAPI(CvSeq*) cvApproxPoly( const void* src_seq,
  401. int header_size, CvMemStorage* storage,
  402. int method, double eps,
  403. int recursive CV_DEFAULT(0));
  404. /** @brief Calculates perimeter of a contour or length of a part of contour
  405. @see cv::arcLength
  406. */
  407. CVAPI(double) cvArcLength( const void* curve,
  408. CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ),
  409. int is_closed CV_DEFAULT(-1));
  410. /** same as cvArcLength for closed contour
  411. */
  412. CV_INLINE double cvContourPerimeter( const void* contour )
  413. {
  414. return cvArcLength( contour, CV_WHOLE_SEQ, 1 );
  415. }
  416. /** @brief Calculates contour bounding rectangle (update=1) or
  417. just retrieves pre-calculated rectangle (update=0)
  418. @see cv::boundingRect
  419. */
  420. CVAPI(CvRect) cvBoundingRect( CvArr* points, int update CV_DEFAULT(0) );
  421. /** @brief Calculates area of a contour or contour segment
  422. @see cv::contourArea
  423. */
  424. CVAPI(double) cvContourArea( const CvArr* contour,
  425. CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ),
  426. int oriented CV_DEFAULT(0));
  427. /** @brief Finds minimum area rotated rectangle bounding a set of points
  428. @see cv::minAreaRect
  429. */
  430. CVAPI(CvBox2D) cvMinAreaRect2( const CvArr* points,
  431. CvMemStorage* storage CV_DEFAULT(NULL));
  432. /** @brief Finds minimum enclosing circle for a set of points
  433. @see cv::minEnclosingCircle
  434. */
  435. CVAPI(int) cvMinEnclosingCircle( const CvArr* points,
  436. CvPoint2D32f* center, float* radius );
  437. /** @brief Compares two contours by matching their moments
  438. @see cv::matchShapes
  439. */
  440. CVAPI(double) cvMatchShapes( const void* object1, const void* object2,
  441. int method, double parameter CV_DEFAULT(0));
  442. /** @brief Calculates exact convex hull of 2d point set
  443. @see cv::convexHull
  444. */
  445. CVAPI(CvSeq*) cvConvexHull2( const CvArr* input,
  446. void* hull_storage CV_DEFAULT(NULL),
  447. int orientation CV_DEFAULT(CV_CLOCKWISE),
  448. int return_points CV_DEFAULT(0));
  449. /** @brief Checks whether the contour is convex or not (returns 1 if convex, 0 if not)
  450. @see cv::isContourConvex
  451. */
  452. CVAPI(int) cvCheckContourConvexity( const CvArr* contour );
  453. /** @brief Finds convexity defects for the contour
  454. @see cv::convexityDefects
  455. */
  456. CVAPI(CvSeq*) cvConvexityDefects( const CvArr* contour, const CvArr* convexhull,
  457. CvMemStorage* storage CV_DEFAULT(NULL));
  458. /** @brief Fits ellipse into a set of 2d points
  459. @see cv::fitEllipse
  460. */
  461. CVAPI(CvBox2D) cvFitEllipse2( const CvArr* points );
  462. /** @brief Finds minimum rectangle containing two given rectangles */
  463. CVAPI(CvRect) cvMaxRect( const CvRect* rect1, const CvRect* rect2 );
  464. /** @brief Finds coordinates of the box vertices */
  465. CVAPI(void) cvBoxPoints( CvBox2D box, CvPoint2D32f pt[4] );
  466. /** @brief Initializes sequence header for a matrix (column or row vector) of points
  467. a wrapper for cvMakeSeqHeaderForArray (it does not initialize bounding rectangle!!!) */
  468. CVAPI(CvSeq*) cvPointSeqFromMat( int seq_kind, const CvArr* mat,
  469. CvContour* contour_header,
  470. CvSeqBlock* block );
  471. /** @brief Checks whether the point is inside polygon, outside, on an edge (at a vertex).
  472. Returns positive, negative or zero value, correspondingly.
  473. Optionally, measures a signed distance between
  474. the point and the nearest polygon edge (measure_dist=1)
  475. @see cv::pointPolygonTest
  476. */
  477. CVAPI(double) cvPointPolygonTest( const CvArr* contour,
  478. CvPoint2D32f pt, int measure_dist );
  479. /****************************************************************************************\
  480. * Histogram functions *
  481. \****************************************************************************************/
  482. /** @brief Creates a histogram.
  483. The function creates a histogram of the specified size and returns a pointer to the created
  484. histogram. If the array ranges is 0, the histogram bin ranges must be specified later via the
  485. function cvSetHistBinRanges. Though cvCalcHist and cvCalcBackProject may process 8-bit images
  486. without setting bin ranges, they assume they are equally spaced in 0 to 255 bins.
  487. @param dims Number of histogram dimensions.
  488. @param sizes Array of the histogram dimension sizes.
  489. @param type Histogram representation format. CV_HIST_ARRAY means that the histogram data is
  490. represented as a multi-dimensional dense array CvMatND. CV_HIST_SPARSE means that histogram data
  491. is represented as a multi-dimensional sparse array CvSparseMat.
  492. @param ranges Array of ranges for the histogram bins. Its meaning depends on the uniform parameter
  493. value. The ranges are used when the histogram is calculated or backprojected to determine which
  494. histogram bin corresponds to which value/tuple of values from the input image(s).
  495. @param uniform Uniformity flag. If not zero, the histogram has evenly spaced bins and for every
  496. \f$0<=i<cDims\f$ ranges[i] is an array of two numbers: lower and upper boundaries for the i-th
  497. histogram dimension. The whole range [lower,upper] is then split into dims[i] equal parts to
  498. determine the i-th input tuple value ranges for every histogram bin. And if uniform=0 , then the
  499. i-th element of the ranges array contains dims[i]+1 elements: \f$\texttt{lower}_0,
  500. \texttt{upper}_0, \texttt{lower}_1, \texttt{upper}_1 = \texttt{lower}_2,
  501. ...
  502. \texttt{upper}_{dims[i]-1}\f$ where \f$\texttt{lower}_j\f$ and \f$\texttt{upper}_j\f$ are lower
  503. and upper boundaries of the i-th input tuple value for the j-th bin, respectively. In either
  504. case, the input values that are beyond the specified range for a histogram bin are not counted
  505. by cvCalcHist and filled with 0 by cvCalcBackProject.
  506. */
  507. CVAPI(CvHistogram*) cvCreateHist( int dims, int* sizes, int type,
  508. float** ranges CV_DEFAULT(NULL),
  509. int uniform CV_DEFAULT(1));
  510. /** @brief Sets the bounds of the histogram bins.
  511. This is a standalone function for setting bin ranges in the histogram. For a more detailed
  512. description of the parameters ranges and uniform, see the :ocvCalcHist function that can initialize
  513. the ranges as well. Ranges for the histogram bins must be set before the histogram is calculated or
  514. the backproject of the histogram is calculated.
  515. @param hist Histogram.
  516. @param ranges Array of bin ranges arrays. See :ocvCreateHist for details.
  517. @param uniform Uniformity flag. See :ocvCreateHist for details.
  518. */
  519. CVAPI(void) cvSetHistBinRanges( CvHistogram* hist, float** ranges,
  520. int uniform CV_DEFAULT(1));
  521. /** @brief Makes a histogram out of an array.
  522. The function initializes the histogram, whose header and bins are allocated by the user.
  523. cvReleaseHist does not need to be called afterwards. Only dense histograms can be initialized this
  524. way. The function returns hist.
  525. @param dims Number of the histogram dimensions.
  526. @param sizes Array of the histogram dimension sizes.
  527. @param hist Histogram header initialized by the function.
  528. @param data Array used to store histogram bins.
  529. @param ranges Histogram bin ranges. See cvCreateHist for details.
  530. @param uniform Uniformity flag. See cvCreateHist for details.
  531. */
  532. CVAPI(CvHistogram*) cvMakeHistHeaderForArray(
  533. int dims, int* sizes, CvHistogram* hist,
  534. float* data, float** ranges CV_DEFAULT(NULL),
  535. int uniform CV_DEFAULT(1));
  536. /** @brief Releases the histogram.
  537. The function releases the histogram (header and the data). The pointer to the histogram is cleared
  538. by the function. If \*hist pointer is already NULL, the function does nothing.
  539. @param hist Double pointer to the released histogram.
  540. */
  541. CVAPI(void) cvReleaseHist( CvHistogram** hist );
  542. /** @brief Clears the histogram.
  543. The function sets all of the histogram bins to 0 in case of a dense histogram and removes all
  544. histogram bins in case of a sparse array.
  545. @param hist Histogram.
  546. */
  547. CVAPI(void) cvClearHist( CvHistogram* hist );
  548. /** @brief Finds the minimum and maximum histogram bins.
  549. The function finds the minimum and maximum histogram bins and their positions. All of output
  550. arguments are optional. Among several extremas with the same value the ones with the minimum index
  551. (in the lexicographical order) are returned. In case of several maximums or minimums, the earliest
  552. in the lexicographical order (extrema locations) is returned.
  553. @param hist Histogram.
  554. @param min_value Pointer to the minimum value of the histogram.
  555. @param max_value Pointer to the maximum value of the histogram.
  556. @param min_idx Pointer to the array of coordinates for the minimum.
  557. @param max_idx Pointer to the array of coordinates for the maximum.
  558. */
  559. CVAPI(void) cvGetMinMaxHistValue( const CvHistogram* hist,
  560. float* min_value, float* max_value,
  561. int* min_idx CV_DEFAULT(NULL),
  562. int* max_idx CV_DEFAULT(NULL));
  563. /** @brief Normalizes the histogram.
  564. The function normalizes the histogram bins by scaling them so that the sum of the bins becomes equal
  565. to factor.
  566. @param hist Pointer to the histogram.
  567. @param factor Normalization factor.
  568. */
  569. CVAPI(void) cvNormalizeHist( CvHistogram* hist, double factor );
  570. /** @brief Thresholds the histogram.
  571. The function clears histogram bins that are below the specified threshold.
  572. @param hist Pointer to the histogram.
  573. @param threshold Threshold level.
  574. */
  575. CVAPI(void) cvThreshHist( CvHistogram* hist, double threshold );
  576. /** Compares two histogram */
  577. CVAPI(double) cvCompareHist( const CvHistogram* hist1,
  578. const CvHistogram* hist2,
  579. int method);
  580. /** @brief Copies a histogram.
  581. The function makes a copy of the histogram. If the second histogram pointer \*dst is NULL, a new
  582. histogram of the same size as src is created. Otherwise, both histograms must have equal types and
  583. sizes. Then the function copies the bin values of the source histogram to the destination histogram
  584. and sets the same bin value ranges as in src.
  585. @param src Source histogram.
  586. @param dst Pointer to the destination histogram.
  587. */
  588. CVAPI(void) cvCopyHist( const CvHistogram* src, CvHistogram** dst );
  589. /** @brief Calculates bayesian probabilistic histograms
  590. (each or src and dst is an array of _number_ histograms */
  591. CVAPI(void) cvCalcBayesianProb( CvHistogram** src, int number,
  592. CvHistogram** dst);
  593. /** @brief Calculates array histogram
  594. @see cv::calcHist
  595. */
  596. CVAPI(void) cvCalcArrHist( CvArr** arr, CvHistogram* hist,
  597. int accumulate CV_DEFAULT(0),
  598. const CvArr* mask CV_DEFAULT(NULL) );
  599. /** @overload */
  600. CV_INLINE void cvCalcHist( IplImage** image, CvHistogram* hist,
  601. int accumulate CV_DEFAULT(0),
  602. const CvArr* mask CV_DEFAULT(NULL) )
  603. {
  604. cvCalcArrHist( (CvArr**)image, hist, accumulate, mask );
  605. }
  606. /** @brief Calculates back project
  607. @see cvCalcBackProject, cv::calcBackProject
  608. */
  609. CVAPI(void) cvCalcArrBackProject( CvArr** image, CvArr* dst,
  610. const CvHistogram* hist );
  611. #define cvCalcBackProject(image, dst, hist) cvCalcArrBackProject((CvArr**)image, dst, hist)
  612. /** @brief Locates a template within an image by using a histogram comparison.
  613. The function calculates the back projection by comparing histograms of the source image patches with
  614. the given histogram. The function is similar to matchTemplate, but instead of comparing the raster
  615. patch with all its possible positions within the search window, the function CalcBackProjectPatch
  616. compares histograms. See the algorithm diagram below:
  617. ![image](pics/backprojectpatch.png)
  618. @param image Source images (though, you may pass CvMat\*\* as well).
  619. @param dst Destination image.
  620. @param range
  621. @param hist Histogram.
  622. @param method Comparison method passed to cvCompareHist (see the function description).
  623. @param factor Normalization factor for histograms that affects the normalization scale of the
  624. destination image. Pass 1 if not sure.
  625. @see cvCalcBackProjectPatch
  626. */
  627. CVAPI(void) cvCalcArrBackProjectPatch( CvArr** image, CvArr* dst, CvSize range,
  628. CvHistogram* hist, int method,
  629. double factor );
  630. #define cvCalcBackProjectPatch( image, dst, range, hist, method, factor ) \
  631. cvCalcArrBackProjectPatch( (CvArr**)image, dst, range, hist, method, factor )
  632. /** @brief Divides one histogram by another.
  633. The function calculates the object probability density from two histograms as:
  634. \f[\texttt{disthist} (I)= \forkthree{0}{if \(\texttt{hist1}(I)=0\)}{\texttt{scale}}{if \(\texttt{hist1}(I) \ne 0\) and \(\texttt{hist2}(I) > \texttt{hist1}(I)\)}{\frac{\texttt{hist2}(I) \cdot \texttt{scale}}{\texttt{hist1}(I)}}{if \(\texttt{hist1}(I) \ne 0\) and \(\texttt{hist2}(I) \le \texttt{hist1}(I)\)}\f]
  635. @param hist1 First histogram (the divisor).
  636. @param hist2 Second histogram.
  637. @param dst_hist Destination histogram.
  638. @param scale Scale factor for the destination histogram.
  639. */
  640. CVAPI(void) cvCalcProbDensity( const CvHistogram* hist1, const CvHistogram* hist2,
  641. CvHistogram* dst_hist, double scale CV_DEFAULT(255) );
  642. /** @brief equalizes histogram of 8-bit single-channel image
  643. @see cv::equalizeHist
  644. */
  645. CVAPI(void) cvEqualizeHist( const CvArr* src, CvArr* dst );
  646. /** @brief Applies distance transform to binary image
  647. @see cv::distanceTransform
  648. */
  649. CVAPI(void) cvDistTransform( const CvArr* src, CvArr* dst,
  650. int distance_type CV_DEFAULT(CV_DIST_L2),
  651. int mask_size CV_DEFAULT(3),
  652. const float* mask CV_DEFAULT(NULL),
  653. CvArr* labels CV_DEFAULT(NULL),
  654. int labelType CV_DEFAULT(CV_DIST_LABEL_CCOMP));
  655. /** @brief Applies fixed-level threshold to grayscale image.
  656. This is a basic operation applied before retrieving contours
  657. @see cv::threshold
  658. */
  659. CVAPI(double) cvThreshold( const CvArr* src, CvArr* dst,
  660. double threshold, double max_value,
  661. int threshold_type );
  662. /** @brief Applies adaptive threshold to grayscale image.
  663. The two parameters for methods CV_ADAPTIVE_THRESH_MEAN_C and
  664. CV_ADAPTIVE_THRESH_GAUSSIAN_C are:
  665. neighborhood size (3, 5, 7 etc.),
  666. and a constant subtracted from mean (...,-3,-2,-1,0,1,2,3,...)
  667. @see cv::adaptiveThreshold
  668. */
  669. CVAPI(void) cvAdaptiveThreshold( const CvArr* src, CvArr* dst, double max_value,
  670. int adaptive_method CV_DEFAULT(CV_ADAPTIVE_THRESH_MEAN_C),
  671. int threshold_type CV_DEFAULT(CV_THRESH_BINARY),
  672. int block_size CV_DEFAULT(3),
  673. double param1 CV_DEFAULT(5));
  674. /** @brief Fills the connected component until the color difference gets large enough
  675. @see cv::floodFill
  676. */
  677. CVAPI(void) cvFloodFill( CvArr* image, CvPoint seed_point,
  678. CvScalar new_val, CvScalar lo_diff CV_DEFAULT(cvScalarAll(0)),
  679. CvScalar up_diff CV_DEFAULT(cvScalarAll(0)),
  680. CvConnectedComp* comp CV_DEFAULT(NULL),
  681. int flags CV_DEFAULT(4),
  682. CvArr* mask CV_DEFAULT(NULL));
  683. /****************************************************************************************\
  684. * Feature detection *
  685. \****************************************************************************************/
  686. /** @brief Runs canny edge detector
  687. @see cv::Canny
  688. */
  689. CVAPI(void) cvCanny( const CvArr* image, CvArr* edges, double threshold1,
  690. double threshold2, int aperture_size CV_DEFAULT(3) );
  691. /** @brief Calculates constraint image for corner detection
  692. Dx^2 * Dyy + Dxx * Dy^2 - 2 * Dx * Dy * Dxy.
  693. Applying threshold to the result gives coordinates of corners
  694. @see cv::preCornerDetect
  695. */
  696. CVAPI(void) cvPreCornerDetect( const CvArr* image, CvArr* corners,
  697. int aperture_size CV_DEFAULT(3) );
  698. /** @brief Calculates eigen values and vectors of 2x2
  699. gradient covariation matrix at every image pixel
  700. @see cv::cornerEigenValsAndVecs
  701. */
  702. CVAPI(void) cvCornerEigenValsAndVecs( const CvArr* image, CvArr* eigenvv,
  703. int block_size, int aperture_size CV_DEFAULT(3) );
  704. /** @brief Calculates minimal eigenvalue for 2x2 gradient covariation matrix at
  705. every image pixel
  706. @see cv::cornerMinEigenVal
  707. */
  708. CVAPI(void) cvCornerMinEigenVal( const CvArr* image, CvArr* eigenval,
  709. int block_size, int aperture_size CV_DEFAULT(3) );
  710. /** @brief Harris corner detector:
  711. Calculates det(M) - k*(trace(M)^2), where M is 2x2 gradient covariation matrix for each pixel
  712. @see cv::cornerHarris
  713. */
  714. CVAPI(void) cvCornerHarris( const CvArr* image, CvArr* harris_response,
  715. int block_size, int aperture_size CV_DEFAULT(3),
  716. double k CV_DEFAULT(0.04) );
  717. /** @brief Adjust corner position using some sort of gradient search
  718. @see cv::cornerSubPix
  719. */
  720. CVAPI(void) cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners,
  721. int count, CvSize win, CvSize zero_zone,
  722. CvTermCriteria criteria );
  723. /** @brief Finds a sparse set of points within the selected region
  724. that seem to be easy to track
  725. @see cv::goodFeaturesToTrack
  726. */
  727. CVAPI(void) cvGoodFeaturesToTrack( const CvArr* image, CvArr* eig_image,
  728. CvArr* temp_image, CvPoint2D32f* corners,
  729. int* corner_count, double quality_level,
  730. double min_distance,
  731. const CvArr* mask CV_DEFAULT(NULL),
  732. int block_size CV_DEFAULT(3),
  733. int use_harris CV_DEFAULT(0),
  734. double k CV_DEFAULT(0.04) );
  735. /** @brief Finds lines on binary image using one of several methods.
  736. line_storage is either memory storage or 1 x _max number of lines_ CvMat, its
  737. number of columns is changed by the function.
  738. method is one of CV_HOUGH_*;
  739. rho, theta and threshold are used for each of those methods;
  740. param1 ~ line length, param2 ~ line gap - for probabilistic,
  741. param1 ~ srn, param2 ~ stn - for multi-scale
  742. @see cv::HoughLines
  743. */
  744. CVAPI(CvSeq*) cvHoughLines2( CvArr* image, void* line_storage, int method,
  745. double rho, double theta, int threshold,
  746. double param1 CV_DEFAULT(0), double param2 CV_DEFAULT(0),
  747. double min_theta CV_DEFAULT(0), double max_theta CV_DEFAULT(CV_PI));
  748. /** @brief Finds circles in the image
  749. @see cv::HoughCircles
  750. */
  751. CVAPI(CvSeq*) cvHoughCircles( CvArr* image, void* circle_storage,
  752. int method, double dp, double min_dist,
  753. double param1 CV_DEFAULT(100),
  754. double param2 CV_DEFAULT(100),
  755. int min_radius CV_DEFAULT(0),
  756. int max_radius CV_DEFAULT(0));
  757. /** @brief Fits a line into set of 2d or 3d points in a robust way (M-estimator technique)
  758. @see cv::fitLine
  759. */
  760. CVAPI(void) cvFitLine( const CvArr* points, int dist_type, double param,
  761. double reps, double aeps, float* line );
  762. /****************************************************************************************\
  763. * Drawing *
  764. \****************************************************************************************/
  765. /****************************************************************************************\
  766. * Drawing functions work with images/matrices of arbitrary type. *
  767. * For color images the channel order is BGR[A] *
  768. * Antialiasing is supported only for 8-bit image now. *
  769. * All the functions include parameter color that means rgb value (that may be *
  770. * constructed with CV_RGB macro) for color images and brightness *
  771. * for grayscale images. *
  772. * If a drawn figure is partially or completely outside of the image, it is clipped.*
  773. \****************************************************************************************/
  774. #define CV_FILLED -1
  775. #define CV_AA 16
  776. /** @brief Draws 4-connected, 8-connected or antialiased line segment connecting two points
  777. @see cv::line
  778. */
  779. CVAPI(void) cvLine( CvArr* img, CvPoint pt1, CvPoint pt2,
  780. CvScalar color, int thickness CV_DEFAULT(1),
  781. int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) );
  782. /** @brief Draws a rectangle given two opposite corners of the rectangle (pt1 & pt2)
  783. if thickness<0 (e.g. thickness == CV_FILLED), the filled box is drawn
  784. @see cv::rectangle
  785. */
  786. CVAPI(void) cvRectangle( CvArr* img, CvPoint pt1, CvPoint pt2,
  787. CvScalar color, int thickness CV_DEFAULT(1),
  788. int line_type CV_DEFAULT(8),
  789. int shift CV_DEFAULT(0));
  790. /** @brief Draws a rectangle specified by a CvRect structure
  791. @see cv::rectangle
  792. */
  793. CVAPI(void) cvRectangleR( CvArr* img, CvRect r,
  794. CvScalar color, int thickness CV_DEFAULT(1),
  795. int line_type CV_DEFAULT(8),
  796. int shift CV_DEFAULT(0));
  797. /** @brief Draws a circle with specified center and radius.
  798. Thickness works in the same way as with cvRectangle
  799. @see cv::circle
  800. */
  801. CVAPI(void) cvCircle( CvArr* img, CvPoint center, int radius,
  802. CvScalar color, int thickness CV_DEFAULT(1),
  803. int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0));
  804. /** @brief Draws ellipse outline, filled ellipse, elliptic arc or filled elliptic sector
  805. depending on _thickness_, _start_angle_ and _end_angle_ parameters. The resultant figure
  806. is rotated by _angle_. All the angles are in degrees
  807. @see cv::ellipse
  808. */
  809. CVAPI(void) cvEllipse( CvArr* img, CvPoint center, CvSize axes,
  810. double angle, double start_angle, double end_angle,
  811. CvScalar color, int thickness CV_DEFAULT(1),
  812. int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0));
  813. CV_INLINE void cvEllipseBox( CvArr* img, CvBox2D box, CvScalar color,
  814. int thickness CV_DEFAULT(1),
  815. int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) )
  816. {
  817. CvSize axes = cvSize(
  818. cvRound(box.size.width*0.5),
  819. cvRound(box.size.height*0.5)
  820. );
  821. cvEllipse( img, cvPointFrom32f( box.center ), axes, box.angle,
  822. 0, 360, color, thickness, line_type, shift );
  823. }
  824. /** @brief Fills convex or monotonous polygon.
  825. @see cv::fillConvexPoly
  826. */
  827. CVAPI(void) cvFillConvexPoly( CvArr* img, const CvPoint* pts, int npts, CvScalar color,
  828. int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0));
  829. /** @brief Fills an area bounded by one or more arbitrary polygons
  830. @see cv::fillPoly
  831. */
  832. CVAPI(void) cvFillPoly( CvArr* img, CvPoint** pts, const int* npts,
  833. int contours, CvScalar color,
  834. int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) );
  835. /** @brief Draws one or more polygonal curves
  836. @see cv::polylines
  837. */
  838. CVAPI(void) cvPolyLine( CvArr* img, CvPoint** pts, const int* npts, int contours,
  839. int is_closed, CvScalar color, int thickness CV_DEFAULT(1),
  840. int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) );
  841. #define cvDrawRect cvRectangle
  842. #define cvDrawLine cvLine
  843. #define cvDrawCircle cvCircle
  844. #define cvDrawEllipse cvEllipse
  845. #define cvDrawPolyLine cvPolyLine
  846. /** @brief Clips the line segment connecting *pt1 and *pt2
  847. by the rectangular window
  848. (0<=x<img_size.width, 0<=y<img_size.height).
  849. @see cv::clipLine
  850. */
  851. CVAPI(int) cvClipLine( CvSize img_size, CvPoint* pt1, CvPoint* pt2 );
  852. /** @brief Initializes line iterator.
  853. Initially, line_iterator->ptr will point to pt1 (or pt2, see left_to_right description) location in
  854. the image. Returns the number of pixels on the line between the ending points.
  855. @see cv::LineIterator
  856. */
  857. CVAPI(int) cvInitLineIterator( const CvArr* image, CvPoint pt1, CvPoint pt2,
  858. CvLineIterator* line_iterator,
  859. int connectivity CV_DEFAULT(8),
  860. int left_to_right CV_DEFAULT(0));
  861. #define CV_NEXT_LINE_POINT( line_iterator ) \
  862. { \
  863. int _line_iterator_mask = (line_iterator).err < 0 ? -1 : 0; \
  864. (line_iterator).err += (line_iterator).minus_delta + \
  865. ((line_iterator).plus_delta & _line_iterator_mask); \
  866. (line_iterator).ptr += (line_iterator).minus_step + \
  867. ((line_iterator).plus_step & _line_iterator_mask); \
  868. }
  869. #define CV_FONT_HERSHEY_SIMPLEX 0
  870. #define CV_FONT_HERSHEY_PLAIN 1
  871. #define CV_FONT_HERSHEY_DUPLEX 2
  872. #define CV_FONT_HERSHEY_COMPLEX 3
  873. #define CV_FONT_HERSHEY_TRIPLEX 4
  874. #define CV_FONT_HERSHEY_COMPLEX_SMALL 5
  875. #define CV_FONT_HERSHEY_SCRIPT_SIMPLEX 6
  876. #define CV_FONT_HERSHEY_SCRIPT_COMPLEX 7
  877. #define CV_FONT_ITALIC 16
  878. #define CV_FONT_VECTOR0 CV_FONT_HERSHEY_SIMPLEX
  879. /** Font structure */
  880. typedef struct CvFont
  881. {
  882. const char* nameFont; //Qt:nameFont
  883. CvScalar color; //Qt:ColorFont -> cvScalar(blue_component, green_component, red_component[, alpha_component])
  884. int font_face; //Qt: bool italic /** =CV_FONT_* */
  885. const int* ascii; //!< font data and metrics
  886. const int* greek;
  887. const int* cyrillic;
  888. float hscale, vscale;
  889. float shear; //!< slope coefficient: 0 - normal, >0 - italic
  890. int thickness; //!< Qt: weight /** letters thickness */
  891. float dx; //!< horizontal interval between letters
  892. int line_type; //!< Qt: PointSize
  893. }
  894. CvFont;
  895. /** @brief Initializes font structure (OpenCV 1.x API).
  896. The function initializes the font structure that can be passed to text rendering functions.
  897. @param font Pointer to the font structure initialized by the function
  898. @param font_face Font name identifier. See cv::HersheyFonts and corresponding old CV_* identifiers.
  899. @param hscale Horizontal scale. If equal to 1.0f , the characters have the original width
  900. depending on the font type. If equal to 0.5f , the characters are of half the original width.
  901. @param vscale Vertical scale. If equal to 1.0f , the characters have the original height depending
  902. on the font type. If equal to 0.5f , the characters are of half the original height.
  903. @param shear Approximate tangent of the character slope relative to the vertical line. A zero
  904. value means a non-italic font, 1.0f means about a 45 degree slope, etc.
  905. @param thickness Thickness of the text strokes
  906. @param line_type Type of the strokes, see line description
  907. @sa cvPutText
  908. */
  909. CVAPI(void) cvInitFont( CvFont* font, int font_face,
  910. double hscale, double vscale,
  911. double shear CV_DEFAULT(0),
  912. int thickness CV_DEFAULT(1),
  913. int line_type CV_DEFAULT(8));
  914. CV_INLINE CvFont cvFont( double scale, int thickness CV_DEFAULT(1) )
  915. {
  916. CvFont font;
  917. cvInitFont( &font, CV_FONT_HERSHEY_PLAIN, scale, scale, 0, thickness, CV_AA );
  918. return font;
  919. }
  920. /** @brief Renders text stroke with specified font and color at specified location.
  921. CvFont should be initialized with cvInitFont
  922. @see cvInitFont, cvGetTextSize, cvFont, cv::putText
  923. */
  924. CVAPI(void) cvPutText( CvArr* img, const char* text, CvPoint org,
  925. const CvFont* font, CvScalar color );
  926. /** @brief Calculates bounding box of text stroke (useful for alignment)
  927. @see cv::getTextSize
  928. */
  929. CVAPI(void) cvGetTextSize( const char* text_string, const CvFont* font,
  930. CvSize* text_size, int* baseline );
  931. /** @brief Unpacks color value
  932. if arrtype is CV_8UC?, _color_ is treated as packed color value, otherwise the first channels
  933. (depending on arrtype) of destination scalar are set to the same value = _color_
  934. */
  935. CVAPI(CvScalar) cvColorToScalar( double packed_color, int arrtype );
  936. /** @brief Returns the polygon points which make up the given ellipse.
  937. The ellipse is define by the box of size 'axes' rotated 'angle' around the 'center'. A partial
  938. sweep of the ellipse arc can be done by specifying arc_start and arc_end to be something other than
  939. 0 and 360, respectively. The input array 'pts' must be large enough to hold the result. The total
  940. number of points stored into 'pts' is returned by this function.
  941. @see cv::ellipse2Poly
  942. */
  943. CVAPI(int) cvEllipse2Poly( CvPoint center, CvSize axes,
  944. int angle, int arc_start, int arc_end, CvPoint * pts, int delta );
  945. /** @brief Draws contour outlines or filled interiors on the image
  946. @see cv::drawContours
  947. */
  948. CVAPI(void) cvDrawContours( CvArr *img, CvSeq* contour,
  949. CvScalar external_color, CvScalar hole_color,
  950. int max_level, int thickness CV_DEFAULT(1),
  951. int line_type CV_DEFAULT(8),
  952. CvPoint offset CV_DEFAULT(cvPoint(0,0)));
  953. /** @} */
  954. #ifdef __cplusplus
  955. }
  956. #endif
  957. #endif