cv.h 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209
  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. // Intel License Agreement
  11. // For Open Source Computer Vision Library
  12. //
  13. // Copyright (C) 2000, Intel Corporation, all rights reserved.
  14. // Third party copyrights are property of their respective owners.
  15. //
  16. // Redistribution and use in source and binary forms, with or without modification,
  17. // are permitted provided that the following conditions are met:
  18. //
  19. // * Redistribution's of source code must retain the above copyright notice,
  20. // this list of conditions and the following disclaimer.
  21. //
  22. // * Redistribution's in binary form must reproduce the above copyright notice,
  23. // this list of conditions and the following disclaimer in the documentation
  24. // and/or other materials provided with the distribution.
  25. //
  26. // * The name of Intel Corporation may not be used to endorse or promote products
  27. // derived from this software without specific prior written permission.
  28. //
  29. // This software is provided by the copyright holders and contributors "as is" and
  30. // any express or implied warranties, including, but not limited to, the implied
  31. // warranties of merchantability and fitness for a particular purpose are disclaimed.
  32. // In no event shall the Intel Corporation or contributors be liable for any direct,
  33. // indirect, incidental, special, exemplary, or consequential damages
  34. // (including, but not limited to, procurement of substitute goods or services;
  35. // loss of use, data, or profits; or business interruption) however caused
  36. // and on any theory of liability, whether in contract, strict liability,
  37. // or tort (including negligence or otherwise) arising in any way out of
  38. // the use of this software, even if advised of the possibility of such damage.
  39. //
  40. //M*/
  41. #ifndef _CV_H_
  42. #define _CV_H_
  43. #ifdef __IPL_H__
  44. #define HAVE_IPL
  45. #endif
  46. #ifndef SKIP_INCLUDES
  47. #if defined(_CH_)
  48. #pragma package <chopencv>
  49. #include <chdl.h>
  50. LOAD_CHDL(cv)
  51. #endif
  52. #endif
  53. #include "cxcore.h"
  54. #include "cvtypes.h"
  55. #ifdef __cplusplus
  56. extern "C" {
  57. #endif
  58. /****************************************************************************************\
  59. * Image Processing *
  60. \****************************************************************************************/
  61. /* Copies source 2D array inside of the larger destination array and
  62. makes a border of the specified type (IPL_BORDER_*) around the copied area. */
  63. CVAPI(void) cvCopyMakeBorder( const CvArr* src, CvArr* dst, CvPoint offset,
  64. int bordertype, CvScalar value CV_DEFAULT(cvScalarAll(0)));
  65. #define CV_BLUR_NO_SCALE 0
  66. #define CV_BLUR 1
  67. #define CV_GAUSSIAN 2
  68. #define CV_MEDIAN 3
  69. #define CV_BILATERAL 4
  70. /* Smoothes array (removes noise) */
  71. CVAPI(void) cvSmooth( const CvArr* src, CvArr* dst,
  72. int smoothtype CV_DEFAULT(CV_GAUSSIAN),
  73. int param1 CV_DEFAULT(3),
  74. int param2 CV_DEFAULT(0),
  75. double param3 CV_DEFAULT(0),
  76. double param4 CV_DEFAULT(0));
  77. /* Convolves the image with the kernel */
  78. CVAPI(void) cvFilter2D( const CvArr* src, CvArr* dst, const CvMat* kernel,
  79. CvPoint anchor CV_DEFAULT(cvPoint(-1,-1)));
  80. /* Finds integral image: SUM(X,Y) = sum(x<X,y<Y)I(x,y) */
  81. CVAPI(void) cvIntegral( const CvArr* image, CvArr* sum,
  82. CvArr* sqsum CV_DEFAULT(NULL),
  83. CvArr* tilted_sum CV_DEFAULT(NULL));
  84. /*
  85. Smoothes the input image with gaussian kernel and then down-samples it.
  86. dst_width = floor(src_width/2)[+1],
  87. dst_height = floor(src_height/2)[+1]
  88. */
  89. CVAPI(void) cvPyrDown( const CvArr* src, CvArr* dst,
  90. int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
  91. /*
  92. Up-samples image and smoothes the result with gaussian kernel.
  93. dst_width = src_width*2,
  94. dst_height = src_height*2
  95. */
  96. CVAPI(void) cvPyrUp( const CvArr* src, CvArr* dst,
  97. int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
  98. /* Builds the whole pyramid at once. Output array of CvMat headers (levels[*])
  99. is initialized with the headers of subsequent pyramid levels */
  100. /*CVAPI void cvCalcPyramid( const CvArr* src, CvArr* container,
  101. CvMat* levels, int level_count,
  102. int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );*/
  103. /* Splits color or grayscale image into multiple connected components
  104. of nearly the same color/brightness using modification of Burt algorithm.
  105. comp with contain a pointer to sequence (CvSeq)
  106. of connected components (CvConnectedComp) */
  107. CVAPI(void) cvPyrSegmentation( IplImage* src, IplImage* dst,
  108. CvMemStorage* storage, CvSeq** comp,
  109. int level, double threshold1,
  110. double threshold2 );
  111. /* Filters image using meanshift algorithm */
  112. CVAPI(void) cvPyrMeanShiftFiltering( const CvArr* src, CvArr* dst,
  113. double sp, double sr, int max_level CV_DEFAULT(1),
  114. CvTermCriteria termcrit CV_DEFAULT(cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,5,1)));
  115. /* Segments image using seed "markers" */
  116. CVAPI(void) cvWatershed( const CvArr* image, CvArr* markers );
  117. #define CV_INPAINT_NS 0
  118. #define CV_INPAINT_TELEA 1
  119. /* Inpaints the selected region in the image */
  120. CVAPI(void) cvInpaint( const CvArr* src, const CvArr* inpaint_mask,
  121. CvArr* dst, double inpaintRange, int flags );
  122. #define CV_SCHARR -1
  123. #define CV_MAX_SOBEL_KSIZE 7
  124. /* Calculates an image derivative using generalized Sobel
  125. (aperture_size = 1,3,5,7) or Scharr (aperture_size = -1) operator.
  126. Scharr can be used only for the first dx or dy derivative */
  127. CVAPI(void) cvSobel( const CvArr* src, CvArr* dst,
  128. int xorder, int yorder,
  129. int aperture_size CV_DEFAULT(3));
  130. /* Calculates the image Laplacian: (d2/dx + d2/dy)I */
  131. CVAPI(void) cvLaplace( const CvArr* src, CvArr* dst,
  132. int aperture_size CV_DEFAULT(3) );
  133. /* Constants for color conversion */
  134. #define CV_BGR2BGRA 0
  135. #define CV_RGB2RGBA CV_BGR2BGRA
  136. #define CV_BGRA2BGR 1
  137. #define CV_RGBA2RGB CV_BGRA2BGR
  138. #define CV_BGR2RGBA 2
  139. #define CV_RGB2BGRA CV_BGR2RGBA
  140. #define CV_RGBA2BGR 3
  141. #define CV_BGRA2RGB CV_RGBA2BGR
  142. #define CV_BGR2RGB 4
  143. #define CV_RGB2BGR CV_BGR2RGB
  144. #define CV_BGRA2RGBA 5
  145. #define CV_RGBA2BGRA CV_BGRA2RGBA
  146. #define CV_BGR2GRAY 6
  147. #define CV_RGB2GRAY 7
  148. #define CV_GRAY2BGR 8
  149. #define CV_GRAY2RGB CV_GRAY2BGR
  150. #define CV_GRAY2BGRA 9
  151. #define CV_GRAY2RGBA CV_GRAY2BGRA
  152. #define CV_BGRA2GRAY 10
  153. #define CV_RGBA2GRAY 11
  154. #define CV_BGR2BGR565 12
  155. #define CV_RGB2BGR565 13
  156. #define CV_BGR5652BGR 14
  157. #define CV_BGR5652RGB 15
  158. #define CV_BGRA2BGR565 16
  159. #define CV_RGBA2BGR565 17
  160. #define CV_BGR5652BGRA 18
  161. #define CV_BGR5652RGBA 19
  162. #define CV_GRAY2BGR565 20
  163. #define CV_BGR5652GRAY 21
  164. #define CV_BGR2BGR555 22
  165. #define CV_RGB2BGR555 23
  166. #define CV_BGR5552BGR 24
  167. #define CV_BGR5552RGB 25
  168. #define CV_BGRA2BGR555 26
  169. #define CV_RGBA2BGR555 27
  170. #define CV_BGR5552BGRA 28
  171. #define CV_BGR5552RGBA 29
  172. #define CV_GRAY2BGR555 30
  173. #define CV_BGR5552GRAY 31
  174. #define CV_BGR2XYZ 32
  175. #define CV_RGB2XYZ 33
  176. #define CV_XYZ2BGR 34
  177. #define CV_XYZ2RGB 35
  178. #define CV_BGR2YCrCb 36
  179. #define CV_RGB2YCrCb 37
  180. #define CV_YCrCb2BGR 38
  181. #define CV_YCrCb2RGB 39
  182. #define CV_BGR2HSV 40
  183. #define CV_RGB2HSV 41
  184. #define CV_BGR2Lab 44
  185. #define CV_RGB2Lab 45
  186. #define CV_BayerBG2BGR 46
  187. #define CV_BayerGB2BGR 47
  188. #define CV_BayerRG2BGR 48
  189. #define CV_BayerGR2BGR 49
  190. #define CV_BayerBG2RGB CV_BayerRG2BGR
  191. #define CV_BayerGB2RGB CV_BayerGR2BGR
  192. #define CV_BayerRG2RGB CV_BayerBG2BGR
  193. #define CV_BayerGR2RGB CV_BayerGB2BGR
  194. #define CV_BGR2Luv 50
  195. #define CV_RGB2Luv 51
  196. #define CV_BGR2HLS 52
  197. #define CV_RGB2HLS 53
  198. #define CV_HSV2BGR 54
  199. #define CV_HSV2RGB 55
  200. #define CV_Lab2BGR 56
  201. #define CV_Lab2RGB 57
  202. #define CV_Luv2BGR 58
  203. #define CV_Luv2RGB 59
  204. #define CV_HLS2BGR 60
  205. #define CV_HLS2RGB 61
  206. #define CV_COLORCVT_MAX 100
  207. /* Converts input array pixels from one color space to another */
  208. CVAPI(void) cvCvtColor( const CvArr* src, CvArr* dst, int code );
  209. #define CV_INTER_NN 0
  210. #define CV_INTER_LINEAR 1
  211. #define CV_INTER_CUBIC 2
  212. #define CV_INTER_AREA 3
  213. #define CV_WARP_FILL_OUTLIERS 8
  214. #define CV_WARP_INVERSE_MAP 16
  215. /* Resizes image (input array is resized to fit the destination array) */
  216. CVAPI(void) cvResize( const CvArr* src, CvArr* dst,
  217. int interpolation CV_DEFAULT( CV_INTER_LINEAR ));
  218. /* Warps image with affine transform */
  219. CVAPI(void) cvWarpAffine( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
  220. int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
  221. CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
  222. /* Computes affine transform matrix for mapping src[i] to dst[i] (i=0,1,2) */
  223. CVAPI(CvMat*) cvGetAffineTransform( const CvPoint2D32f * src,
  224. const CvPoint2D32f * dst,
  225. CvMat * map_matrix );
  226. /* Computes rotation_matrix matrix */
  227. CVAPI(CvMat*) cv2DRotationMatrix( CvPoint2D32f center, double angle,
  228. double scale, CvMat* map_matrix );
  229. /* Warps image with perspective (projective) transform */
  230. CVAPI(void) cvWarpPerspective( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
  231. int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
  232. CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
  233. /* Computes perspective transform matrix for mapping src[i] to dst[i] (i=0,1,2,3) */
  234. CVAPI(CvMat*) cvGetPerspectiveTransform( const CvPoint2D32f* src,
  235. const CvPoint2D32f* dst,
  236. CvMat* map_matrix );
  237. /* Performs generic geometric transformation using the specified coordinate maps */
  238. CVAPI(void) cvRemap( const CvArr* src, CvArr* dst,
  239. const CvArr* mapx, const CvArr* mapy,
  240. int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
  241. CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
  242. /* Performs forward or inverse log-polar image transform */
  243. CVAPI(void) cvLogPolar( const CvArr* src, CvArr* dst,
  244. CvPoint2D32f center, double M,
  245. int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
  246. #define CV_SHAPE_RECT 0
  247. #define CV_SHAPE_CROSS 1
  248. #define CV_SHAPE_ELLIPSE 2
  249. #define CV_SHAPE_CUSTOM 100
  250. /* creates structuring element used for morphological operations */
  251. CVAPI(IplConvKernel*) cvCreateStructuringElementEx(
  252. int cols, int rows, int anchor_x, int anchor_y,
  253. int shape, int* values CV_DEFAULT(NULL) );
  254. /* releases structuring element */
  255. CVAPI(void) cvReleaseStructuringElement( IplConvKernel** element );
  256. /* erodes input image (applies minimum filter) one or more times.
  257. If element pointer is NULL, 3x3 rectangular element is used */
  258. CVAPI(void) cvErode( const CvArr* src, CvArr* dst,
  259. IplConvKernel* element CV_DEFAULT(NULL),
  260. int iterations CV_DEFAULT(1) );
  261. /* dilates input image (applies maximum filter) one or more times.
  262. If element pointer is NULL, 3x3 rectangular element is used */
  263. CVAPI(void) cvDilate( const CvArr* src, CvArr* dst,
  264. IplConvKernel* element CV_DEFAULT(NULL),
  265. int iterations CV_DEFAULT(1) );
  266. #define CV_MOP_OPEN 2
  267. #define CV_MOP_CLOSE 3
  268. #define CV_MOP_GRADIENT 4
  269. #define CV_MOP_TOPHAT 5
  270. #define CV_MOP_BLACKHAT 6
  271. /* Performs complex morphological transformation */
  272. CVAPI(void) cvMorphologyEx( const CvArr* src, CvArr* dst,
  273. CvArr* temp, IplConvKernel* element,
  274. int operation, int iterations CV_DEFAULT(1) );
  275. /* Calculates all spatial and central moments up to the 3rd order */
  276. CVAPI(void) cvMoments( const CvArr* arr, CvMoments* moments, int binary CV_DEFAULT(0));
  277. /* Retrieve particular spatial, central or normalized central moments */
  278. CVAPI(double) cvGetSpatialMoment( CvMoments* moments, int x_order, int y_order );
  279. CVAPI(double) cvGetCentralMoment( CvMoments* moments, int x_order, int y_order );
  280. CVAPI(double) cvGetNormalizedCentralMoment( CvMoments* moments,
  281. int x_order, int y_order );
  282. /* Calculates 7 Hu's invariants from precalculated spatial and central moments */
  283. CVAPI(void) cvGetHuMoments( CvMoments* moments, CvHuMoments* hu_moments );
  284. /*********************************** data sampling **************************************/
  285. /* Fetches pixels that belong to the specified line segment and stores them to the buffer.
  286. Returns the number of retrieved points. */
  287. CVAPI(int) cvSampleLine( const CvArr* image, CvPoint pt1, CvPoint pt2, void* buffer,
  288. int connectivity CV_DEFAULT(8));
  289. /* Retrieves the rectangular image region with specified center from the input array.
  290. dst(x,y) <- src(x + center.x - dst_width/2, y + center.y - dst_height/2).
  291. Values of pixels with fractional coordinates are retrieved using bilinear interpolation*/
  292. CVAPI(void) cvGetRectSubPix( const CvArr* src, CvArr* dst, CvPoint2D32f center );
  293. /* Retrieves quadrangle from the input array.
  294. matrixarr = ( a11 a12 | b1 ) dst(x,y) <- src(A[x y]' + b)
  295. ( a21 a22 | b2 ) (bilinear interpolation is used to retrieve pixels
  296. with fractional coordinates)
  297. */
  298. CVAPI(void) cvGetQuadrangleSubPix( const CvArr* src, CvArr* dst,
  299. const CvMat* map_matrix );
  300. /* Methods for comparing two array */
  301. #define CV_TM_SQDIFF 0
  302. #define CV_TM_SQDIFF_NORMED 1
  303. #define CV_TM_CCORR 2
  304. #define CV_TM_CCORR_NORMED 3
  305. #define CV_TM_CCOEFF 4
  306. #define CV_TM_CCOEFF_NORMED 5
  307. /* Measures similarity between template and overlapped windows in the source image
  308. and fills the resultant image with the measurements */
  309. CVAPI(void) cvMatchTemplate( const CvArr* image, const CvArr* templ,
  310. CvArr* result, int method );
  311. /* Computes earth mover distance between
  312. two weighted point sets (called signatures) */
  313. CVAPI(float) cvCalcEMD2( const CvArr* signature1,
  314. const CvArr* signature2,
  315. int distance_type,
  316. CvDistanceFunction distance_func CV_DEFAULT(NULL),
  317. const CvArr* cost_matrix CV_DEFAULT(NULL),
  318. CvArr* flow CV_DEFAULT(NULL),
  319. float* lower_bound CV_DEFAULT(NULL),
  320. void* userdata CV_DEFAULT(NULL));
  321. /****************************************************************************************\
  322. * Contours retrieving *
  323. \****************************************************************************************/
  324. /* Retrieves outer and optionally inner boundaries of white (non-zero) connected
  325. components in the black (zero) background */
  326. CVAPI(int) cvFindContours( CvArr* image, CvMemStorage* storage, CvSeq** first_contour,
  327. int header_size CV_DEFAULT(sizeof(CvContour)),
  328. int mode CV_DEFAULT(CV_RETR_LIST),
  329. int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
  330. CvPoint offset CV_DEFAULT(cvPoint(0,0)));
  331. /* Initalizes contour retrieving process.
  332. Calls cvStartFindContours.
  333. Calls cvFindNextContour until null pointer is returned
  334. or some other condition becomes true.
  335. Calls cvEndFindContours at the end. */
  336. CVAPI(CvContourScanner) cvStartFindContours( CvArr* image, CvMemStorage* storage,
  337. int header_size CV_DEFAULT(sizeof(CvContour)),
  338. int mode CV_DEFAULT(CV_RETR_LIST),
  339. int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
  340. CvPoint offset CV_DEFAULT(cvPoint(0,0)));
  341. /* Retrieves next contour */
  342. CVAPI(CvSeq*) cvFindNextContour( CvContourScanner scanner );
  343. /* Substitutes the last retrieved contour with the new one
  344. (if the substitutor is null, the last retrieved contour is removed from the tree) */
  345. CVAPI(void) cvSubstituteContour( CvContourScanner scanner, CvSeq* new_contour );
  346. /* Releases contour scanner and returns pointer to the first outer contour */
  347. CVAPI(CvSeq*) cvEndFindContours( CvContourScanner* scanner );
  348. /* Approximates a single Freeman chain or a tree of chains to polygonal curves */
  349. CVAPI(CvSeq*) cvApproxChains( CvSeq* src_seq, CvMemStorage* storage,
  350. int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
  351. double parameter CV_DEFAULT(0),
  352. int minimal_perimeter CV_DEFAULT(0),
  353. int recursive CV_DEFAULT(0));
  354. /* Initalizes Freeman chain reader.
  355. The reader is used to iteratively get coordinates of all the chain points.
  356. If the Freeman codes should be read as is, a simple sequence reader should be used */
  357. CVAPI(void) cvStartReadChainPoints( CvChain* chain, CvChainPtReader* reader );
  358. /* Retrieves the next chain point */
  359. CVAPI(CvPoint) cvReadChainPoint( CvChainPtReader* reader );
  360. /****************************************************************************************\
  361. * Motion Analysis *
  362. \****************************************************************************************/
  363. /************************************ optical flow ***************************************/
  364. /* Calculates optical flow for 2 images using classical Lucas & Kanade algorithm */
  365. CVAPI(void) cvCalcOpticalFlowLK( const CvArr* prev, const CvArr* curr,
  366. CvSize win_size, CvArr* velx, CvArr* vely );
  367. /* Calculates optical flow for 2 images using block matching algorithm */
  368. CVAPI(void) cvCalcOpticalFlowBM( const CvArr* prev, const CvArr* curr,
  369. CvSize block_size, CvSize shift_size,
  370. CvSize max_range, int use_previous,
  371. CvArr* velx, CvArr* vely );
  372. /* Calculates Optical flow for 2 images using Horn & Schunck algorithm */
  373. CVAPI(void) cvCalcOpticalFlowHS( const CvArr* prev, const CvArr* curr,
  374. int use_previous, CvArr* velx, CvArr* vely,
  375. double lambda, CvTermCriteria criteria );
  376. #define CV_LKFLOW_PYR_A_READY 1
  377. #define CV_LKFLOW_PYR_B_READY 2
  378. #define CV_LKFLOW_INITIAL_GUESSES 4
  379. /* It is Lucas & Kanade method, modified to use pyramids.
  380. Also it does several iterations to get optical flow for
  381. every point at every pyramid level.
  382. Calculates optical flow between two images for certain set of points (i.e.
  383. it is a "sparse" optical flow, which is opposite to the previous 3 methods) */
  384. CVAPI(void) cvCalcOpticalFlowPyrLK( const CvArr* prev, const CvArr* curr,
  385. CvArr* prev_pyr, CvArr* curr_pyr,
  386. const CvPoint2D32f* prev_features,
  387. CvPoint2D32f* curr_features,
  388. int count,
  389. CvSize win_size,
  390. int level,
  391. char* status,
  392. float* track_error,
  393. CvTermCriteria criteria,
  394. int flags );
  395. /* Modification of a previous sparse optical flow algorithm to calculate
  396. affine flow */
  397. /*CVAPI void cvCalcAffineFlowPyrLK( const CvArr* prev, const CvArr* curr,
  398. CvArr* prev_pyr, CvArr* curr_pyr,
  399. CvPoint2D32f* prev_features,
  400. CvPoint2D32f* curr_features,
  401. float* matrices, int count,
  402. CvSize win_size, int level,
  403. char* status, float* track_error,
  404. CvTermCriteria criteria, int flags );*/
  405. /********************************* motion templates *************************************/
  406. /****************************************************************************************\
  407. * All the motion template functions work only with single channel images. *
  408. * Silhouette image must have depth IPL_DEPTH_8U or IPL_DEPTH_8S *
  409. * Motion history image must have depth IPL_DEPTH_32F, *
  410. * Gradient mask - IPL_DEPTH_8U or IPL_DEPTH_8S, *
  411. * Motion orientation image - IPL_DEPTH_32F *
  412. * Segmentation mask - IPL_DEPTH_32F *
  413. * All the angles are in degrees, all the times are in milliseconds *
  414. \****************************************************************************************/
  415. /* Updates motion history image given motion silhouette */
  416. CVAPI(void) cvUpdateMotionHistory( const CvArr* silhouette, CvArr* mhi,
  417. double timestamp, double duration );
  418. /* Calculates gradient of the motion history image and fills
  419. a mask indicating where the gradient is valid */
  420. CVAPI(void) cvCalcMotionGradient( const CvArr* mhi, CvArr* mask, CvArr* orientation,
  421. double delta1, double delta2,
  422. int aperture_size CV_DEFAULT(3));
  423. /* Calculates average motion direction within a selected motion region
  424. (region can be selected by setting ROIs and/or by composing a valid gradient mask
  425. with the region mask) */
  426. CVAPI(double) cvCalcGlobalOrientation( const CvArr* orientation, const CvArr* mask,
  427. const CvArr* mhi, double timestamp,
  428. double duration );
  429. /* Splits a motion history image into a few parts corresponding to separate independent motions
  430. (e.g. left hand, right hand) */
  431. CVAPI(CvSeq*) cvSegmentMotion( const CvArr* mhi, CvArr* seg_mask,
  432. CvMemStorage* storage,
  433. double timestamp, double seg_thresh );
  434. /*********************** Background statistics accumulation *****************************/
  435. /* Adds image to accumulator */
  436. CVAPI(void) cvAcc( const CvArr* image, CvArr* sum,
  437. const CvArr* mask CV_DEFAULT(NULL) );
  438. /* Adds squared image to accumulator */
  439. CVAPI(void) cvSquareAcc( const CvArr* image, CvArr* sqsum,
  440. const CvArr* mask CV_DEFAULT(NULL) );
  441. /* Adds a product of two images to accumulator */
  442. CVAPI(void) cvMultiplyAcc( const CvArr* image1, const CvArr* image2, CvArr* acc,
  443. const CvArr* mask CV_DEFAULT(NULL) );
  444. /* Adds image to accumulator with weights: acc = acc*(1-alpha) + image*alpha */
  445. CVAPI(void) cvRunningAvg( const CvArr* image, CvArr* acc, double alpha,
  446. const CvArr* mask CV_DEFAULT(NULL) );
  447. /****************************************************************************************\
  448. * Tracking *
  449. \****************************************************************************************/
  450. /* Implements CAMSHIFT algorithm - determines object position, size and orientation
  451. from the object histogram back project (extension of meanshift) */
  452. CVAPI(int) cvCamShift( const CvArr* prob_image, CvRect window,
  453. CvTermCriteria criteria, CvConnectedComp* comp,
  454. CvBox2D* box CV_DEFAULT(NULL) );
  455. /* Implements MeanShift algorithm - determines object position
  456. from the object histogram back project */
  457. CVAPI(int) cvMeanShift( const CvArr* prob_image, CvRect window,
  458. CvTermCriteria criteria, CvConnectedComp* comp );
  459. /* Creates ConDensation filter state */
  460. CVAPI(CvConDensation*) cvCreateConDensation( int dynam_params,
  461. int measure_params,
  462. int sample_count );
  463. /* Releases ConDensation filter state */
  464. CVAPI(void) cvReleaseConDensation( CvConDensation** condens );
  465. /* Updates ConDensation filter by time (predict future state of the system) */
  466. CVAPI(void) cvConDensUpdateByTime( CvConDensation* condens);
  467. /* Initializes ConDensation filter samples */
  468. CVAPI(void) cvConDensInitSampleSet( CvConDensation* condens, CvMat* lower_bound, CvMat* upper_bound );
  469. /* Creates Kalman filter and sets A, B, Q, R and state to some initial values */
  470. CVAPI(CvKalman*) cvCreateKalman( int dynam_params, int measure_params,
  471. int control_params CV_DEFAULT(0));
  472. /* Releases Kalman filter state */
  473. CVAPI(void) cvReleaseKalman( CvKalman** kalman);
  474. /* Updates Kalman filter by time (predicts future state of the system) */
  475. CVAPI(const CvMat*) cvKalmanPredict( CvKalman* kalman,
  476. const CvMat* control CV_DEFAULT(NULL));
  477. /* Updates Kalman filter by measurement
  478. (corrects state of the system and internal matrices) */
  479. CVAPI(const CvMat*) cvKalmanCorrect( CvKalman* kalman, const CvMat* measurement );
  480. /****************************************************************************************\
  481. * Planar subdivisions *
  482. \****************************************************************************************/
  483. /* Initializes Delaunay triangulation */
  484. CVAPI(void) cvInitSubdivDelaunay2D( CvSubdiv2D* subdiv, CvRect rect );
  485. /* Creates new subdivision */
  486. CVAPI(CvSubdiv2D*) cvCreateSubdiv2D( int subdiv_type, int header_size,
  487. int vtx_size, int quadedge_size,
  488. CvMemStorage* storage );
  489. /************************* high-level subdivision functions ***************************/
  490. /* Simplified Delaunay diagram creation */
  491. CV_INLINE CvSubdiv2D* cvCreateSubdivDelaunay2D( CvRect rect, CvMemStorage* storage )
  492. {
  493. CvSubdiv2D* subdiv = cvCreateSubdiv2D( CV_SEQ_KIND_SUBDIV2D, sizeof(*subdiv),
  494. sizeof(CvSubdiv2DPoint), sizeof(CvQuadEdge2D), storage );
  495. cvInitSubdivDelaunay2D( subdiv, rect );
  496. return subdiv;
  497. }
  498. /* Inserts new point to the Delaunay triangulation */
  499. CVAPI(CvSubdiv2DPoint*) cvSubdivDelaunay2DInsert( CvSubdiv2D* subdiv, CvPoint2D32f pt);
  500. /* Locates a point within the Delaunay triangulation (finds the edge
  501. the point is left to or belongs to, or the triangulation point the given
  502. point coinsides with */
  503. CVAPI(CvSubdiv2DPointLocation) cvSubdiv2DLocate(
  504. CvSubdiv2D* subdiv, CvPoint2D32f pt,
  505. CvSubdiv2DEdge* edge,
  506. CvSubdiv2DPoint** vertex CV_DEFAULT(NULL) );
  507. /* Calculates Voronoi tesselation (i.e. coordinates of Voronoi points) */
  508. CVAPI(void) cvCalcSubdivVoronoi2D( CvSubdiv2D* subdiv );
  509. /* Removes all Voronoi points from the tesselation */
  510. CVAPI(void) cvClearSubdivVoronoi2D( CvSubdiv2D* subdiv );
  511. /* Finds the nearest to the given point vertex in subdivision. */
  512. CVAPI(CvSubdiv2DPoint*) cvFindNearestPoint2D( CvSubdiv2D* subdiv, CvPoint2D32f pt );
  513. /************ Basic quad-edge navigation and operations ************/
  514. CV_INLINE CvSubdiv2DEdge cvSubdiv2DNextEdge( CvSubdiv2DEdge edge )
  515. {
  516. return CV_SUBDIV2D_NEXT_EDGE(edge);
  517. }
  518. CV_INLINE CvSubdiv2DEdge cvSubdiv2DRotateEdge( CvSubdiv2DEdge edge, int rotate )
  519. {
  520. return (edge & ~3) + ((edge + rotate) & 3);
  521. }
  522. CV_INLINE CvSubdiv2DEdge cvSubdiv2DSymEdge( CvSubdiv2DEdge edge )
  523. {
  524. return edge ^ 2;
  525. }
  526. CV_INLINE CvSubdiv2DEdge cvSubdiv2DGetEdge( CvSubdiv2DEdge edge, CvNextEdgeType type )
  527. {
  528. CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
  529. edge = e->next[(edge + (int)type) & 3];
  530. return (edge & ~3) + ((edge + ((int)type >> 4)) & 3);
  531. }
  532. CV_INLINE CvSubdiv2DPoint* cvSubdiv2DEdgeOrg( CvSubdiv2DEdge edge )
  533. {
  534. CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
  535. return (CvSubdiv2DPoint*)e->pt[edge & 3];
  536. }
  537. CV_INLINE CvSubdiv2DPoint* cvSubdiv2DEdgeDst( CvSubdiv2DEdge edge )
  538. {
  539. CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
  540. return (CvSubdiv2DPoint*)e->pt[(edge + 2) & 3];
  541. }
  542. CV_INLINE double cvTriangleArea( CvPoint2D32f a, CvPoint2D32f b, CvPoint2D32f c )
  543. {
  544. return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
  545. }
  546. /****************************************************************************************\
  547. * Contour Processing and Shape Analysis *
  548. \****************************************************************************************/
  549. #define CV_POLY_APPROX_DP 0
  550. /* Approximates a single polygonal curve (contour) or
  551. a tree of polygonal curves (contours) */
  552. CVAPI(CvSeq*) cvApproxPoly( const void* src_seq,
  553. int header_size, CvMemStorage* storage,
  554. int method, double parameter,
  555. int parameter2 CV_DEFAULT(0));
  556. #define CV_DOMINANT_IPAN 1
  557. /* Finds high-curvature points of the contour */
  558. CVAPI(CvSeq*) cvFindDominantPoints( CvSeq* contour, CvMemStorage* storage,
  559. int method CV_DEFAULT(CV_DOMINANT_IPAN),
  560. double parameter1 CV_DEFAULT(0),
  561. double parameter2 CV_DEFAULT(0),
  562. double parameter3 CV_DEFAULT(0),
  563. double parameter4 CV_DEFAULT(0));
  564. /* Calculates perimeter of a contour or length of a part of contour */
  565. CVAPI(double) cvArcLength( const void* curve,
  566. CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ),
  567. int is_closed CV_DEFAULT(-1));
  568. #define cvContourPerimeter( contour ) cvArcLength( contour, CV_WHOLE_SEQ, 1 )
  569. /* Calculates contour boundning rectangle (update=1) or
  570. just retrieves pre-calculated rectangle (update=0) */
  571. CVAPI(CvRect) cvBoundingRect( CvArr* points, int update CV_DEFAULT(0) );
  572. /* Calculates area of a contour or contour segment */
  573. CVAPI(double) cvContourArea( const CvArr* contour,
  574. CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ));
  575. /* Finds minimum area rotated rectangle bounding a set of points */
  576. CVAPI(CvBox2D) cvMinAreaRect2( const CvArr* points,
  577. CvMemStorage* storage CV_DEFAULT(NULL));
  578. /* Finds minimum enclosing circle for a set of points */
  579. CVAPI(int) cvMinEnclosingCircle( const CvArr* points,
  580. CvPoint2D32f* center, float* radius );
  581. #define CV_CONTOURS_MATCH_I1 1
  582. #define CV_CONTOURS_MATCH_I2 2
  583. #define CV_CONTOURS_MATCH_I3 3
  584. /* Compares two contours by matching their moments */
  585. CVAPI(double) cvMatchShapes( const void* object1, const void* object2,
  586. int method, double parameter CV_DEFAULT(0));
  587. /* Builds hierarhical representation of a contour */
  588. CVAPI(CvContourTree*) cvCreateContourTree( const CvSeq* contour,
  589. CvMemStorage* storage,
  590. double threshold );
  591. /* Reconstruct (completelly or partially) contour a from contour tree */
  592. CVAPI(CvSeq*) cvContourFromContourTree( const CvContourTree* tree,
  593. CvMemStorage* storage,
  594. CvTermCriteria criteria );
  595. /* Compares two contour trees */
  596. #define CV_CONTOUR_TREES_MATCH_I1 1
  597. CVAPI(double) cvMatchContourTrees( const CvContourTree* tree1,
  598. const CvContourTree* tree2,
  599. int method, double threshold );
  600. /* Calculates histogram of a contour */
  601. CVAPI(void) cvCalcPGH( const CvSeq* contour, CvHistogram* hist );
  602. #define CV_CLOCKWISE 1
  603. #define CV_COUNTER_CLOCKWISE 2
  604. /* Calculates exact convex hull of 2d point set */
  605. CVAPI(CvSeq*) cvConvexHull2( const CvArr* input,
  606. void* hull_storage CV_DEFAULT(NULL),
  607. int orientation CV_DEFAULT(CV_CLOCKWISE),
  608. int return_points CV_DEFAULT(0));
  609. /* Checks whether the contour is convex or not (returns 1 if convex, 0 if not) */
  610. CVAPI(int) cvCheckContourConvexity( const CvArr* contour );
  611. /* Finds convexity defects for the contour */
  612. CVAPI(CvSeq*) cvConvexityDefects( const CvArr* contour, const CvArr* convexhull,
  613. CvMemStorage* storage CV_DEFAULT(NULL));
  614. /* Fits ellipse into a set of 2d points */
  615. CVAPI(CvBox2D) cvFitEllipse2( const CvArr* points );
  616. /* Finds minimum rectangle containing two given rectangles */
  617. CVAPI(CvRect) cvMaxRect( const CvRect* rect1, const CvRect* rect2 );
  618. /* Finds coordinates of the box vertices */
  619. CVAPI(void) cvBoxPoints( CvBox2D box, CvPoint2D32f pt[4] );
  620. /* Initializes sequence header for a matrix (column or row vector) of points -
  621. a wrapper for cvMakeSeqHeaderForArray (it does not initialize bounding rectangle!!!) */
  622. CVAPI(CvSeq*) cvPointSeqFromMat( int seq_kind, const CvArr* mat,
  623. CvContour* contour_header,
  624. CvSeqBlock* block );
  625. /* Checks whether the point is inside polygon, outside, on an edge (at a vertex).
  626. Returns positive, negative or zero value, correspondingly.
  627. Optionally, measures a signed distance between
  628. the point and the nearest polygon edge (measure_dist=1) */
  629. CVAPI(double) cvPointPolygonTest( const CvArr* contour,
  630. CvPoint2D32f pt, int measure_dist );
  631. /****************************************************************************************\
  632. * Histogram functions *
  633. \****************************************************************************************/
  634. /* Creates new histogram */
  635. CVAPI(CvHistogram*) cvCreateHist( int dims, int* sizes, int type,
  636. float** ranges CV_DEFAULT(NULL),
  637. int uniform CV_DEFAULT(1));
  638. /* Assignes histogram bin ranges */
  639. CVAPI(void) cvSetHistBinRanges( CvHistogram* hist, float** ranges,
  640. int uniform CV_DEFAULT(1));
  641. /* Creates histogram header for array */
  642. CVAPI(CvHistogram*) cvMakeHistHeaderForArray(
  643. int dims, int* sizes, CvHistogram* hist,
  644. float* data, float** ranges CV_DEFAULT(NULL),
  645. int uniform CV_DEFAULT(1));
  646. /* Releases histogram */
  647. CVAPI(void) cvReleaseHist( CvHistogram** hist );
  648. /* Clears all the histogram bins */
  649. CVAPI(void) cvClearHist( CvHistogram* hist );
  650. /* Finds indices and values of minimum and maximum histogram bins */
  651. CVAPI(void) cvGetMinMaxHistValue( const CvHistogram* hist,
  652. float* min_value, float* max_value,
  653. int* min_idx CV_DEFAULT(NULL),
  654. int* max_idx CV_DEFAULT(NULL));
  655. /* Normalizes histogram by dividing all bins by sum of the bins, multiplied by <factor>.
  656. After that sum of histogram bins is equal to <factor> */
  657. CVAPI(void) cvNormalizeHist( CvHistogram* hist, double factor );
  658. /* Clear all histogram bins that are below the threshold */
  659. CVAPI(void) cvThreshHist( CvHistogram* hist, double threshold );
  660. #define CV_COMP_CORREL 0
  661. #define CV_COMP_CHISQR 1
  662. #define CV_COMP_INTERSECT 2
  663. #define CV_COMP_BHATTACHARYYA 3
  664. /* Compares two histogram */
  665. CVAPI(double) cvCompareHist( const CvHistogram* hist1,
  666. const CvHistogram* hist2,
  667. int method);
  668. /* Copies one histogram to another. Destination histogram is created if
  669. the destination pointer is NULL */
  670. CVAPI(void) cvCopyHist( const CvHistogram* src, CvHistogram** dst );
  671. /* Calculates bayesian probabilistic histograms
  672. (each or src and dst is an array of <number> histograms */
  673. CVAPI(void) cvCalcBayesianProb( CvHistogram** src, int number,
  674. CvHistogram** dst);
  675. /* Calculates array histogram */
  676. CVAPI(void) cvCalcArrHist( CvArr** arr, CvHistogram* hist,
  677. int accumulate CV_DEFAULT(0),
  678. const CvArr* mask CV_DEFAULT(NULL) );
  679. CV_INLINE void cvCalcHist( IplImage** image, CvHistogram* hist,
  680. int accumulate CV_DEFAULT(0),
  681. const CvArr* mask CV_DEFAULT(NULL) )
  682. {
  683. cvCalcArrHist( (CvArr**)image, hist, accumulate, mask );
  684. }
  685. /* Calculates back project */
  686. CVAPI(void) cvCalcArrBackProject( CvArr** image, CvArr* dst,
  687. const CvHistogram* hist );
  688. #define cvCalcBackProject(image, dst, hist) cvCalcArrBackProject((CvArr**)image, dst, hist)
  689. /* Does some sort of template matching but compares histograms of
  690. template and each window location */
  691. CVAPI(void) cvCalcArrBackProjectPatch( CvArr** image, CvArr* dst, CvSize range,
  692. CvHistogram* hist, int method,
  693. double factor );
  694. #define cvCalcBackProjectPatch( image, dst, range, hist, method, factor ) \
  695. cvCalcArrBackProjectPatch( (CvArr**)image, dst, range, hist, method, factor )
  696. /* calculates probabilistic density (divides one histogram by another) */
  697. CVAPI(void) cvCalcProbDensity( const CvHistogram* hist1, const CvHistogram* hist2,
  698. CvHistogram* dst_hist, double scale CV_DEFAULT(255) );
  699. /* equalizes histogram of 8-bit single-channel image */
  700. CVAPI(void) cvEqualizeHist( const CvArr* src, CvArr* dst );
  701. #define CV_VALUE 1
  702. #define CV_ARRAY 2
  703. /* Updates active contour in order to minimize its cummulative
  704. (internal and external) energy. */
  705. CVAPI(void) cvSnakeImage( const IplImage* image, CvPoint* points,
  706. int length, float* alpha,
  707. float* beta, float* gamma,
  708. int coeff_usage, CvSize win,
  709. CvTermCriteria criteria, int calc_gradient CV_DEFAULT(1));
  710. /* Calculates the cooficients of the homography matrix */
  711. CVAPI(void) cvCalcImageHomography( float* line, CvPoint3D32f* center,
  712. float* intrinsic, float* homography );
  713. #define CV_DIST_MASK_3 3
  714. #define CV_DIST_MASK_5 5
  715. #define CV_DIST_MASK_PRECISE 0
  716. /* Applies distance transform to binary image */
  717. CVAPI(void) cvDistTransform( const CvArr* src, CvArr* dst,
  718. int distance_type CV_DEFAULT(CV_DIST_L2),
  719. int mask_size CV_DEFAULT(3),
  720. const float* mask CV_DEFAULT(NULL),
  721. CvArr* labels CV_DEFAULT(NULL));
  722. /* Types of thresholding */
  723. #define CV_THRESH_BINARY 0 /* value = value > threshold ? max_value : 0 */
  724. #define CV_THRESH_BINARY_INV 1 /* value = value > threshold ? 0 : max_value */
  725. #define CV_THRESH_TRUNC 2 /* value = value > threshold ? threshold : value */
  726. #define CV_THRESH_TOZERO 3 /* value = value > threshold ? value : 0 */
  727. #define CV_THRESH_TOZERO_INV 4 /* value = value > threshold ? 0 : value */
  728. #define CV_THRESH_MASK 7
  729. #define CV_THRESH_OTSU 8 /* use Otsu algorithm to choose the optimal threshold value;
  730. combine the flag with one of the above CV_THRESH_* values */
  731. /* Applies fixed-level threshold to grayscale image.
  732. This is a basic operation applied before retrieving contours */
  733. CVAPI(void) cvThreshold( const CvArr* src, CvArr* dst,
  734. double threshold, double max_value,
  735. int threshold_type );
  736. #define CV_ADAPTIVE_THRESH_MEAN_C 0
  737. #define CV_ADAPTIVE_THRESH_GAUSSIAN_C 1
  738. /* Applies adaptive threshold to grayscale image.
  739. The two parameters for methods CV_ADAPTIVE_THRESH_MEAN_C and
  740. CV_ADAPTIVE_THRESH_GAUSSIAN_C are:
  741. neighborhood size (3, 5, 7 etc.),
  742. and a constant subtracted from mean (...,-3,-2,-1,0,1,2,3,...) */
  743. CVAPI(void) cvAdaptiveThreshold( const CvArr* src, CvArr* dst, double max_value,
  744. int adaptive_method CV_DEFAULT(CV_ADAPTIVE_THRESH_MEAN_C),
  745. int threshold_type CV_DEFAULT(CV_THRESH_BINARY),
  746. int block_size CV_DEFAULT(3),
  747. double param1 CV_DEFAULT(5));
  748. #define CV_FLOODFILL_FIXED_RANGE (1 << 16)
  749. #define CV_FLOODFILL_MASK_ONLY (1 << 17)
  750. /* Fills the connected component until the color difference gets large enough */
  751. CVAPI(void) cvFloodFill( CvArr* image, CvPoint seed_point,
  752. CvScalar new_val, CvScalar lo_diff CV_DEFAULT(cvScalarAll(0)),
  753. CvScalar up_diff CV_DEFAULT(cvScalarAll(0)),
  754. CvConnectedComp* comp CV_DEFAULT(NULL),
  755. int flags CV_DEFAULT(4),
  756. CvArr* mask CV_DEFAULT(NULL));
  757. /****************************************************************************************\
  758. * Feature detection *
  759. \****************************************************************************************/
  760. #define CV_CANNY_L2_GRADIENT (1 << 31)
  761. /* Runs canny edge detector */
  762. CVAPI(void) cvCanny( const CvArr* image, CvArr* edges, double threshold1,
  763. double threshold2, int aperture_size CV_DEFAULT(3) );
  764. /* Calculates constraint image for corner detection
  765. Dx^2 * Dyy + Dxx * Dy^2 - 2 * Dx * Dy * Dxy.
  766. Applying threshold to the result gives coordinates of corners */
  767. CVAPI(void) cvPreCornerDetect( const CvArr* image, CvArr* corners,
  768. int aperture_size CV_DEFAULT(3) );
  769. /* Calculates eigen values and vectors of 2x2
  770. gradient covariation matrix at every image pixel */
  771. CVAPI(void) cvCornerEigenValsAndVecs( const CvArr* image, CvArr* eigenvv,
  772. int block_size, int aperture_size CV_DEFAULT(3) );
  773. /* Calculates minimal eigenvalue for 2x2 gradient covariation matrix at
  774. every image pixel */
  775. CVAPI(void) cvCornerMinEigenVal( const CvArr* image, CvArr* eigenval,
  776. int block_size, int aperture_size CV_DEFAULT(3) );
  777. /* Harris corner detector:
  778. Calculates det(M) - k*(trace(M)^2), where M is 2x2 gradient covariation matrix for each pixel */
  779. CVAPI(void) cvCornerHarris( const CvArr* image, CvArr* harris_responce,
  780. int block_size, int aperture_size CV_DEFAULT(3),
  781. double k CV_DEFAULT(0.04) );
  782. /* Adjust corner position using some sort of gradient search */
  783. CVAPI(void) cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners,
  784. int count, CvSize win, CvSize zero_zone,
  785. CvTermCriteria criteria );
  786. /* Finds a sparse set of points within the selected region
  787. that seem to be easy to track */
  788. CVAPI(void) cvGoodFeaturesToTrack( const CvArr* image, CvArr* eig_image,
  789. CvArr* temp_image, CvPoint2D32f* corners,
  790. int* corner_count, double quality_level,
  791. double min_distance,
  792. const CvArr* mask CV_DEFAULT(NULL),
  793. int block_size CV_DEFAULT(3),
  794. int use_harris CV_DEFAULT(0),
  795. double k CV_DEFAULT(0.04) );
  796. #define CV_HOUGH_STANDARD 0
  797. #define CV_HOUGH_PROBABILISTIC 1
  798. #define CV_HOUGH_MULTI_SCALE 2
  799. #define CV_HOUGH_GRADIENT 3
  800. /* Finds lines on binary image using one of several methods.
  801. line_storage is either memory storage or 1 x <max number of lines> CvMat, its
  802. number of columns is changed by the function.
  803. method is one of CV_HOUGH_*;
  804. rho, theta and threshold are used for each of those methods;
  805. param1 ~ line length, param2 ~ line gap - for probabilistic,
  806. param1 ~ srn, param2 ~ stn - for multi-scale */
  807. CVAPI(CvSeq*) cvHoughLines2( CvArr* image, void* line_storage, int method,
  808. double rho, double theta, int threshold,
  809. double param1 CV_DEFAULT(0), double param2 CV_DEFAULT(0));
  810. /* Finds circles in the image */
  811. CVAPI(CvSeq*) cvHoughCircles( CvArr* image, void* circle_storage,
  812. int method, double dp, double min_dist,
  813. double param1 CV_DEFAULT(100),
  814. double param2 CV_DEFAULT(100),
  815. int min_radius CV_DEFAULT(0),
  816. int max_radius CV_DEFAULT(0));
  817. /* Fits a line into set of 2d or 3d points in a robust way (M-estimator technique) */
  818. CVAPI(void) cvFitLine( const CvArr* points, int dist_type, double param,
  819. double reps, double aeps, float* line );
  820. /****************************************************************************************\
  821. * Haar-like Object Detection functions *
  822. \****************************************************************************************/
  823. /* Loads haar classifier cascade from a directory.
  824. It is obsolete: convert your cascade to xml and use cvLoad instead */
  825. CVAPI(CvHaarClassifierCascade*) cvLoadHaarClassifierCascade(
  826. const char* directory, CvSize orig_window_size);
  827. CVAPI(void) cvReleaseHaarClassifierCascade( CvHaarClassifierCascade** cascade );
  828. #define CV_HAAR_DO_CANNY_PRUNING 1
  829. #define CV_HAAR_SCALE_IMAGE 2
  830. CVAPI(CvSeq*) cvHaarDetectObjects( const CvArr* image,
  831. CvHaarClassifierCascade* cascade,
  832. CvMemStorage* storage, double scale_factor CV_DEFAULT(1.1),
  833. int min_neighbors CV_DEFAULT(3), int flags CV_DEFAULT(0),
  834. CvSize min_size CV_DEFAULT(cvSize(0,0)));
  835. /* sets images for haar classifier cascade */
  836. CVAPI(void) cvSetImagesForHaarClassifierCascade( CvHaarClassifierCascade* cascade,
  837. const CvArr* sum, const CvArr* sqsum,
  838. const CvArr* tilted_sum, double scale );
  839. /* runs the cascade on the specified window */
  840. CVAPI(int) cvRunHaarClassifierCascade( CvHaarClassifierCascade* cascade,
  841. CvPoint pt, int start_stage CV_DEFAULT(0));
  842. /****************************************************************************************\
  843. * Camera Calibration and Rectification functions *
  844. \****************************************************************************************/
  845. /* transforms the input image to compensate lens distortion */
  846. CVAPI(void) cvUndistort2( const CvArr* src, CvArr* dst,
  847. const CvMat* intrinsic_matrix,
  848. const CvMat* distortion_coeffs );
  849. /* computes transformation map from intrinsic camera parameters
  850. that can used by cvRemap */
  851. CVAPI(void) cvInitUndistortMap( const CvMat* intrinsic_matrix,
  852. const CvMat* distortion_coeffs,
  853. CvArr* mapx, CvArr* mapy );
  854. /* converts rotation vector to rotation matrix or vice versa */
  855. CVAPI(int) cvRodrigues2( const CvMat* src, CvMat* dst,
  856. CvMat* jacobian CV_DEFAULT(0) );
  857. /* finds perspective transformation between the object plane and image (view) plane */
  858. CVAPI(void) cvFindHomography( const CvMat* src_points,
  859. const CvMat* dst_points,
  860. CvMat* homography );
  861. /* projects object points to the view plane using
  862. the specified extrinsic and intrinsic camera parameters */
  863. CVAPI(void) cvProjectPoints2( const CvMat* object_points, const CvMat* rotation_vector,
  864. const CvMat* translation_vector, const CvMat* intrinsic_matrix,
  865. const CvMat* distortion_coeffs, CvMat* image_points,
  866. CvMat* dpdrot CV_DEFAULT(NULL), CvMat* dpdt CV_DEFAULT(NULL),
  867. CvMat* dpdf CV_DEFAULT(NULL), CvMat* dpdc CV_DEFAULT(NULL),
  868. CvMat* dpddist CV_DEFAULT(NULL) );
  869. /* finds extrinsic camera parameters from
  870. a few known corresponding point pairs and intrinsic parameters */
  871. CVAPI(void) cvFindExtrinsicCameraParams2( const CvMat* object_points,
  872. const CvMat* image_points,
  873. const CvMat* intrinsic_matrix,
  874. const CvMat* distortion_coeffs,
  875. CvMat* rotation_vector,
  876. CvMat* translation_vector );
  877. #define CV_CALIB_USE_INTRINSIC_GUESS 1
  878. #define CV_CALIB_FIX_ASPECT_RATIO 2
  879. #define CV_CALIB_FIX_PRINCIPAL_POINT 4
  880. #define CV_CALIB_ZERO_TANGENT_DIST 8
  881. /* finds intrinsic and extrinsic camera parameters
  882. from a few views of known calibration pattern */
  883. CVAPI(void) cvCalibrateCamera2( const CvMat* object_points,
  884. const CvMat* image_points,
  885. const CvMat* point_counts,
  886. CvSize image_size,
  887. CvMat* intrinsic_matrix,
  888. CvMat* distortion_coeffs,
  889. CvMat* rotation_vectors CV_DEFAULT(NULL),
  890. CvMat* translation_vectors CV_DEFAULT(NULL),
  891. int flags CV_DEFAULT(0) );
  892. #define CV_CALIB_CB_ADAPTIVE_THRESH 1
  893. #define CV_CALIB_CB_NORMALIZE_IMAGE 2
  894. #define CV_CALIB_CB_FILTER_QUADS 4
  895. /* Detects corners on a chessboard calibration pattern */
  896. CVAPI(int) cvFindChessboardCorners( const void* image, CvSize pattern_size,
  897. CvPoint2D32f* corners,
  898. int* corner_count CV_DEFAULT(NULL),
  899. int flags CV_DEFAULT(CV_CALIB_CB_ADAPTIVE_THRESH) );
  900. /* Draws individual chessboard corners or the whole chessboard detected */
  901. CVAPI(void) cvDrawChessboardCorners( CvArr* image, CvSize pattern_size,
  902. CvPoint2D32f* corners,
  903. int count, int pattern_was_found );
  904. typedef struct CvPOSITObject CvPOSITObject;
  905. /* Allocates and initializes CvPOSITObject structure before doing cvPOSIT */
  906. CVAPI(CvPOSITObject*) cvCreatePOSITObject( CvPoint3D32f* points, int point_count );
  907. /* Runs POSIT (POSe from ITeration) algorithm for determining 3d position of
  908. an object given its model and projection in a weak-perspective case */
  909. CVAPI(void) cvPOSIT( CvPOSITObject* posit_object, CvPoint2D32f* image_points,
  910. double focal_length, CvTermCriteria criteria,
  911. CvMatr32f rotation_matrix, CvVect32f translation_vector);
  912. /* Releases CvPOSITObject structure */
  913. CVAPI(void) cvReleasePOSITObject( CvPOSITObject** posit_object );
  914. /****************************************************************************************\
  915. * Epipolar Geometry *
  916. \****************************************************************************************/
  917. CVAPI(void) cvConvertPointsHomogenious( const CvMat* src, CvMat* dst );
  918. /* Calculates fundamental matrix given a set of corresponding points */
  919. #define CV_FM_7POINT 1
  920. #define CV_FM_8POINT 2
  921. #define CV_FM_LMEDS_ONLY 4
  922. #define CV_FM_RANSAC_ONLY 8
  923. #define CV_FM_LMEDS (CV_FM_LMEDS_ONLY + CV_FM_8POINT)
  924. #define CV_FM_RANSAC (CV_FM_RANSAC_ONLY + CV_FM_8POINT)
  925. CVAPI(int) cvFindFundamentalMat( const CvMat* points1, const CvMat* points2,
  926. CvMat* fundamental_matrix,
  927. int method CV_DEFAULT(CV_FM_RANSAC),
  928. double param1 CV_DEFAULT(1.), double param2 CV_DEFAULT(0.99),
  929. CvMat* status CV_DEFAULT(NULL) );
  930. /* For each input point on one of images
  931. computes parameters of the corresponding
  932. epipolar line on the other image */
  933. CVAPI(void) cvComputeCorrespondEpilines( const CvMat* points,
  934. int which_image,
  935. const CvMat* fundamental_matrix,
  936. CvMat* correspondent_lines );
  937. #ifdef __cplusplus
  938. }
  939. #endif
  940. #ifdef __cplusplus
  941. #include "cv.hpp"
  942. #endif
  943. /****************************************************************************************\
  944. * Backward compatibility *
  945. \****************************************************************************************/
  946. #ifndef CV_NO_BACKWARD_COMPATIBILITY
  947. #include "cvcompat.h"
  948. #endif
  949. #endif /*_CV_H_*/