imgproc_c.h 50 KB

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