1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
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.
10 // Intel License Agreement
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
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.
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.
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.
50 /* spatial and central moments */
51 typedef struct CvMoments
53 double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03; /* spatial moments */
54 double mu20, mu11, mu02, mu30, mu21, mu12, mu03; /* central moments */
55 double inv_sqrt_m00; /* m00 != 0 ? 1/sqrt(m00) : 0 */
60 typedef struct CvHuMoments
62 double hu1, hu2, hu3, hu4, hu5, hu6, hu7; /* Hu invariants */
66 /**************************** Connected Component **************************************/
68 typedef struct CvConnectedComp
70 double area; /* area of the connected component */
71 CvScalar value; /* average color of the connected component */
72 CvRect rect; /* ROI of the component */
73 CvSeq* contour; /* optional component boundary
74 (the contour might have child contours corresponding to the holes)*/
79 Internal structure that is used for sequental retrieving contours from the image.
80 It supports both hierarchical and plane variants of Suzuki algorithm.
82 typedef struct _CvContourScanner* CvContourScanner;
84 /* contour retrieval mode */
85 #define CV_RETR_EXTERNAL 0
86 #define CV_RETR_LIST 1
87 #define CV_RETR_CCOMP 2
88 #define CV_RETR_TREE 3
90 /* contour approximation method */
91 #define CV_CHAIN_CODE 0
92 #define CV_CHAIN_APPROX_NONE 1
93 #define CV_CHAIN_APPROX_SIMPLE 2
94 #define CV_CHAIN_APPROX_TC89_L1 3
95 #define CV_CHAIN_APPROX_TC89_KCOS 4
96 #define CV_LINK_RUNS 5
98 /* Freeman chain reader state */
99 typedef struct CvChainPtReader
101 CV_SEQ_READER_FIELDS()
108 /* initializes 8-element array for fast access to 3x3 neighborhood of a pixel */
109 #define CV_INIT_3X3_DELTAS( deltas, step, nch ) \
110 ((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \
111 (deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \
112 (deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \
113 (deltas)[6] = (step), (deltas)[7] = (step) + (nch))
115 /* Contour tree header */
116 typedef struct CvContourTree
119 CvPoint p1; /* the first point of the binary tree root segment */
120 CvPoint p2; /* the last point of the binary tree root segment */
124 /* Finds a sequence of convexity defects of given contour */
125 typedef struct CvConvexityDefect
127 CvPoint* start; /* point of the contour where the defect begins */
128 CvPoint* end; /* point of the contour where the defect ends */
129 CvPoint* depth_point; /* the farthest from the convex hull point within the defect */
130 float depth; /* distance between the farthest point and the convex hull */
134 /************ Data structures and related enumerations for Planar Subdivisions ************/
136 typedef size_t CvSubdiv2DEdge;
138 #define CV_QUADEDGE2D_FIELDS() \
140 struct CvSubdiv2DPoint* pt[4]; \
141 CvSubdiv2DEdge next[4];
143 #define CV_SUBDIV2D_POINT_FIELDS()\
145 CvSubdiv2DEdge first; \
148 #define CV_SUBDIV2D_VIRTUAL_POINT_FLAG (1 << 30)
150 typedef struct CvQuadEdge2D
152 CV_QUADEDGE2D_FIELDS()
156 typedef struct CvSubdiv2DPoint
158 CV_SUBDIV2D_POINT_FIELDS()
162 #define CV_SUBDIV2D_FIELDS() \
165 int is_geometry_valid; \
166 CvSubdiv2DEdge recent_edge; \
167 CvPoint2D32f topleft; \
168 CvPoint2D32f bottomright;
170 typedef struct CvSubdiv2D
177 typedef enum CvSubdiv2DPointLocation
180 CV_PTLOC_OUTSIDE_RECT = -1,
185 CvSubdiv2DPointLocation;
187 typedef enum CvNextEdgeType
189 CV_NEXT_AROUND_ORG = 0x00,
190 CV_NEXT_AROUND_DST = 0x22,
191 CV_PREV_AROUND_ORG = 0x11,
192 CV_PREV_AROUND_DST = 0x33,
193 CV_NEXT_AROUND_LEFT = 0x13,
194 CV_NEXT_AROUND_RIGHT = 0x31,
195 CV_PREV_AROUND_LEFT = 0x20,
196 CV_PREV_AROUND_RIGHT = 0x02
200 /* get the next edge with the same origin point (counterwise) */
201 #define CV_SUBDIV2D_NEXT_EDGE( edge ) (((CvQuadEdge2D*)((edge) & ~3))->next[(edge)&3])
204 /* Defines for Distance Transform */
205 #define CV_DIST_USER -1 /* User defined distance */
206 #define CV_DIST_L1 1 /* distance = |x1-x2| + |y1-y2| */
207 #define CV_DIST_L2 2 /* the simple euclidean distance */
208 #define CV_DIST_C 3 /* distance = max(|x1-x2|,|y1-y2|) */
209 #define CV_DIST_L12 4 /* L1-L2 metric: distance = 2(sqrt(1+x*x/2) - 1)) */
210 #define CV_DIST_FAIR 5 /* distance = c^2(|x|/c-log(1+|x|/c)), c = 1.3998 */
211 #define CV_DIST_WELSCH 6 /* distance = c^2/2(1-exp(-(x/c)^2)), c = 2.9846 */
212 #define CV_DIST_HUBER 7 /* distance = |x|<c ? x^2/2 : c(|x|-c/2), c=1.345 */
215 /* Filters used in pyramid decomposition */
216 typedef enum CvFilter
222 /****************************************************************************************/
223 /* Older definitions */
224 /****************************************************************************************/
226 typedef float* CvVect32f;
227 typedef float* CvMatr32f;
228 typedef double* CvVect64d;
229 typedef double* CvMatr64d;
231 typedef struct CvMatrix3
242 typedef float (CV_CDECL * CvDistanceFunction)( const float* a, const float* b, void* user_param );
248 typedef struct CvConDensation
252 float* DynamMatr; /* Matrix of the linear Dynamics system */
253 float* State; /* Vector of State */
254 int SamplesNum; /* Number of the Samples */
255 float** flSamples; /* arr of the Sample Vectors */
256 float** flNewSamples; /* temporary array of the Sample Vectors */
257 float* flConfidence; /* Confidence for each Sample */
258 float* flCumulative; /* Cumulative confidence */
259 float* Temp; /* Temporary vector */
260 float* RandomSample; /* RandomVector to update sample set */
261 struct CvRandState* RandS; /* Array of structures to generate random vectors */
266 standard Kalman filter (in G. Welch' and G. Bishop's notation):
268 x(k)=A*x(k-1)+B*u(k)+w(k) p(w)~N(0,Q)
269 z(k)=H*x(k)+v(k), p(v)~N(0,R)
271 typedef struct CvKalman
273 int MP; /* number of measurement vector dimensions */
274 int DP; /* number of state vector dimensions */
275 int CP; /* number of control vector dimensions */
277 /* backward compatibility fields */
279 float* PosterState; /* =state_pre->data.fl */
280 float* PriorState; /* =state_post->data.fl */
281 float* DynamMatr; /* =transition_matrix->data.fl */
282 float* MeasurementMatr; /* =measurement_matrix->data.fl */
283 float* MNCovariance; /* =measurement_noise_cov->data.fl */
284 float* PNCovariance; /* =process_noise_cov->data.fl */
285 float* KalmGainMatr; /* =gain->data.fl */
286 float* PriorErrorCovariance;/* =error_cov_pre->data.fl */
287 float* PosterErrorCovariance;/* =error_cov_post->data.fl */
288 float* Temp1; /* temp1->data.fl */
289 float* Temp2; /* temp2->data.fl */
292 CvMat* state_pre; /* predicted state (x'(k)):
293 x(k)=A*x(k-1)+B*u(k) */
294 CvMat* state_post; /* corrected state (x(k)):
295 x(k)=x'(k)+K(k)*(z(k)-H*x'(k)) */
296 CvMat* transition_matrix; /* state transition matrix (A) */
297 CvMat* control_matrix; /* control matrix (B)
298 (it is not used if there is no control)*/
299 CvMat* measurement_matrix; /* measurement matrix (H) */
300 CvMat* process_noise_cov; /* process noise covariance matrix (Q) */
301 CvMat* measurement_noise_cov; /* measurement noise covariance matrix (R) */
302 CvMat* error_cov_pre; /* priori error estimate covariance matrix (P'(k)):
303 P'(k)=A*P(k-1)*At + Q)*/
304 CvMat* gain; /* Kalman gain matrix (K(k)):
305 K(k)=P'(k)*Ht*inv(H*P'(k)*Ht+R)*/
306 CvMat* error_cov_post; /* posteriori error estimate covariance matrix (P(k)):
307 P(k)=(I-K(k)*H)*P'(k) */
308 CvMat* temp1; /* temporary matrices */
317 /*********************** Haar-like Object Detection structures **************************/
318 #define CV_HAAR_MAGIC_VAL 0x42500000
319 #define CV_TYPE_NAME_HAAR "opencv-haar-classifier"
321 #define CV_IS_HAAR_CLASSIFIER( haar ) \
323 (((const CvHaarClassifierCascade*)(haar))->flags & CV_MAGIC_MASK)==CV_HAAR_MAGIC_VAL)
325 #define CV_HAAR_FEATURE_MAX 3
327 typedef struct CvHaarFeature
334 } rect[CV_HAAR_FEATURE_MAX];
338 typedef struct CvHaarClassifier
341 CvHaarFeature* haar_feature;
349 typedef struct CvHaarStageClassifier
353 CvHaarClassifier* classifier;
359 CvHaarStageClassifier;
361 typedef struct CvHidHaarClassifierCascade CvHidHaarClassifierCascade;
363 typedef struct CvHaarClassifierCascade
367 CvSize orig_window_size;
368 CvSize real_window_size;
370 CvHaarStageClassifier* stage_classifier;
371 CvHidHaarClassifierCascade* hid_cascade;
373 CvHaarClassifierCascade;
375 typedef struct CvAvgComp
382 struct CvFeatureTree;
384 #endif /*_CVTYPES_H_*/