e330a28da010ac0dc39bf4198426158033e61c43
[opencv] / interfaces / swig / filtered / cv.h
1 # 1 "../../../cv/include/cv.h"
2 # 1 "<built-in>"
3 # 1 "<command line>"
4 # 1 "../../../cv/include/cv.h"
5 # 58 "../../../cv/include/cv.h"
6 # 1 "../../../cxcore/include/cxcore.h" 1
7 # 69 "../../../cxcore/include/cxcore.h"
8 # 1 "../../../cxcore/include/cxtypes.h" 1
9 # 144 "../../../cxcore/include/cxtypes.h"
10 typedef long long int64;
11 typedef unsigned long long uint64;
12
13
14
15 typedef unsigned char uchar;
16 typedef unsigned short ushort;
17
18
19 typedef signed char schar;
20
21
22
23
24 typedef void CvArr;
25
26 typedef union Cv32suf
27 {
28     int i;
29     unsigned u;
30     float f;
31 }
32 Cv32suf;
33
34 typedef union Cv64suf
35 {
36     int64 i;
37     uint64 u;
38     double f;
39 }
40 Cv64suf;
41 # 207 "../../../cxcore/include/cxtypes.h"
42 inline int cvRound( double value )
43 {
44 # 227 "../../../cxcore/include/cxtypes.h"
45     Cv64suf temp;
46     temp.f = value + 6755399441055744.0;
47     return (int)temp.u;
48
49 }
50
51
52 inline int cvFloor( double value )
53 {
54
55
56
57
58
59     int temp = cvRound(value);
60     Cv32suf diff;
61     diff.f = (float)(value - temp);
62     return temp - (diff.i < 0);
63
64 }
65
66
67 inline int cvCeil( double value )
68 {
69
70
71
72
73
74     int temp = cvRound(value);
75     Cv32suf diff;
76     diff.f = (float)(temp - value);
77     return temp + (diff.i < 0);
78
79 }
80
81
82
83
84 inline int cvIsNaN( double value )
85 {
86
87
88
89
90
91     Cv64suf ieee754;
92     ieee754.f = value;
93     return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) +
94            ((unsigned)ieee754.u != 0) > 0x7ff00000;
95
96 }
97
98
99 inline int cvIsInf( double value )
100 {
101
102
103
104
105
106     Cv64suf ieee754;
107     ieee754.f = value;
108     return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 &&
109            (unsigned)ieee754.u == 0;
110
111 }
112
113
114
115
116 typedef uint64 CvRNG;
117
118 inline CvRNG cvRNG( int64 seed = -1)
119 {
120     CvRNG rng = seed ? (uint64)seed : (uint64)(int64)-1;
121     return rng;
122 }
123
124
125 inline unsigned cvRandInt( CvRNG* rng )
126 {
127     uint64 temp = *rng;
128     temp = (uint64)(unsigned)temp*1554115554 + (temp >> 32);
129     *rng = temp;
130     return (unsigned)temp;
131 }
132
133
134 inline double cvRandReal( CvRNG* rng )
135 {
136     return cvRandInt(rng)*2.3283064365386962890625e-10 ;
137 }
138 # 362 "../../../cxcore/include/cxtypes.h"
139 typedef struct _IplImage
140 {
141     int nSize;
142     int ID;
143     int nChannels;
144     int alphaChannel;
145     int depth;
146
147     char colorModel[4];
148     char channelSeq[4];
149     int dataOrder;
150
151     int origin;
152
153     int align;
154
155     int width;
156     int height;
157     struct _IplROI *roi;
158     struct _IplImage *maskROI;
159     void *imageId;
160     struct _IplTileInfo *tileInfo;
161     int imageSize;
162
163
164     char *imageData;
165     int widthStep;
166     int BorderMode[4];
167     int BorderConst[4];
168     char *imageDataOrigin;
169
170
171 }
172 IplImage;
173
174 typedef struct _IplTileInfo IplTileInfo;
175
176 typedef struct _IplROI
177 {
178     int coi;
179     int xOffset;
180     int yOffset;
181     int width;
182     int height;
183 }
184 IplROI;
185
186 typedef struct _IplConvKernel
187 {
188     int nCols;
189     int nRows;
190     int anchorX;
191     int anchorY;
192     int *values;
193     int nShiftR;
194 }
195 IplConvKernel;
196
197 typedef struct _IplConvKernelFP
198 {
199     int nCols;
200     int nRows;
201     int anchorX;
202     int anchorY;
203     float *values;
204 }
205 IplConvKernelFP;
206 # 540 "../../../cxcore/include/cxtypes.h"
207 typedef struct CvMat
208 {
209     int type;
210     int step;
211
212
213     int* refcount;
214     int hdr_refcount;
215
216     union
217     {
218         uchar* ptr;
219         short* s;
220         int* i;
221         float* fl;
222         double* db;
223     } data;
224
225
226     union
227     {
228         int rows;
229         int height;
230     };
231
232     union
233     {
234         int cols;
235         int width;
236     };
237
238
239
240
241
242 }
243 CvMat;
244 # 617 "../../../cxcore/include/cxtypes.h"
245 inline CvMat cvMat( int rows, int cols, int type, void* data = NULL)
246 {
247     CvMat m;
248
249     assert( (unsigned)((type) & ((1 << 3) - 1)) <= 6 );
250     type = ((type) & ((1 << 3)*64 - 1));
251     m.type = 0x42420000 | (1 << 14) | type;
252     m.cols = cols;
253     m.rows = rows;
254     m.step = rows > 1 ? m.cols*(((((type) & ((64 - 1) << 3)) >> 3) + 1) << ((((sizeof(size_t)/4+1)*16384|0x3a50) >> ((type) & ((1 << 3) - 1))*2) & 3)) : 0;
255     m.data.ptr = (uchar*)data;
256     m.refcount = NULL;
257     m.hdr_refcount = 0;
258
259     return m;
260 }
261 # 647 "../../../cxcore/include/cxtypes.h"
262 inline double cvmGet( const CvMat* mat, int row, int col )
263 {
264     int type;
265
266     type = ((mat->type) & ((1 << 3)*64 - 1));
267     assert( (unsigned)row < (unsigned)mat->rows &&
268             (unsigned)col < (unsigned)mat->cols );
269
270     if( type == ((5) + (((1)-1) << 3)) )
271         return ((float*)(mat->data.ptr + (size_t)mat->step*row))[col];
272     else
273     {
274         assert( type == ((6) + (((1)-1) << 3)) );
275         return ((double*)(mat->data.ptr + (size_t)mat->step*row))[col];
276     }
277 }
278
279
280 inline void cvmSet( CvMat* mat, int row, int col, double value )
281 {
282     int type;
283     type = ((mat->type) & ((1 << 3)*64 - 1));
284     assert( (unsigned)row < (unsigned)mat->rows &&
285             (unsigned)col < (unsigned)mat->cols );
286
287     if( type == ((5) + (((1)-1) << 3)) )
288         ((float*)(mat->data.ptr + (size_t)mat->step*row))[col] = (float)value;
289     else
290     {
291         assert( type == ((6) + (((1)-1) << 3)) );
292         ((double*)(mat->data.ptr + (size_t)mat->step*row))[col] = (double)value;
293     }
294 }
295
296
297 inline int cvCvToIplDepth( int type )
298 {
299     int depth = ((type) & ((1 << 3) - 1));
300     return ((((sizeof(size_t)<<28)|0x8442211) >> ((depth) & ((1 << 3) - 1))*4) & 15)*8 | (depth == 1 || depth == 3 ||
301            depth == 4 ? 0x80000000 : 0);
302 }
303 # 700 "../../../cxcore/include/cxtypes.h"
304 typedef struct CvMatND
305 {
306     int type;
307     int dims;
308
309     int* refcount;
310     int hdr_refcount;
311
312     union
313     {
314         uchar* ptr;
315         float* fl;
316         double* db;
317         int* i;
318         short* s;
319     } data;
320
321     struct
322     {
323         int size;
324         int step;
325     }
326     dim[32];
327 }
328 CvMatND;
329 # 740 "../../../cxcore/include/cxtypes.h"
330 struct CvSet;
331
332 typedef struct CvSparseMat
333 {
334     int type;
335     int dims;
336     int* refcount;
337     int hdr_refcount;
338
339     struct CvSet* heap;
340     void** hashtable;
341     int hashsize;
342     int valoffset;
343     int idxoffset;
344     int size[32];
345 }
346 CvSparseMat;
347 # 767 "../../../cxcore/include/cxtypes.h"
348 typedef struct CvSparseNode
349 {
350     unsigned hashval;
351     struct CvSparseNode* next;
352 }
353 CvSparseNode;
354
355 typedef struct CvSparseMatIterator
356 {
357     CvSparseMat* mat;
358     CvSparseNode* node;
359     int curidx;
360 }
361 CvSparseMatIterator;
362 # 789 "../../../cxcore/include/cxtypes.h"
363 typedef int CvHistType;
364 # 805 "../../../cxcore/include/cxtypes.h"
365 typedef struct CvHistogram
366 {
367     int type;
368     CvArr* bins;
369     float thresh[32][2];
370     float** thresh2;
371     CvMatND mat;
372 }
373 CvHistogram;
374 # 835 "../../../cxcore/include/cxtypes.h"
375 typedef struct CvRect
376 {
377     int x;
378     int y;
379     int width;
380     int height;
381 }
382 CvRect;
383
384 inline CvRect cvRect( int x, int y, int width, int height )
385 {
386     CvRect r;
387
388     r.x = x;
389     r.y = y;
390     r.width = width;
391     r.height = height;
392
393     return r;
394 }
395
396
397 inline IplROI cvRectToROI( CvRect rect, int coi )
398 {
399     IplROI roi;
400     roi.xOffset = rect.x;
401     roi.yOffset = rect.y;
402     roi.width = rect.width;
403     roi.height = rect.height;
404     roi.coi = coi;
405
406     return roi;
407 }
408
409
410 inline CvRect cvROIToRect( IplROI roi )
411 {
412     return cvRect( roi.xOffset, roi.yOffset, roi.width, roi.height );
413 }
414
415
416
417
418
419
420
421 typedef struct CvTermCriteria
422 {
423     int type;
424
425
426     int max_iter;
427     double epsilon;
428 }
429 CvTermCriteria;
430
431 inline CvTermCriteria cvTermCriteria( int type, int max_iter, double epsilon )
432 {
433     CvTermCriteria t;
434
435     t.type = type;
436     t.max_iter = max_iter;
437     t.epsilon = (float)epsilon;
438
439     return t;
440 }
441
442
443
444
445 typedef struct CvPoint
446 {
447     int x;
448     int y;
449 }
450 CvPoint;
451
452
453 inline CvPoint cvPoint( int x, int y )
454 {
455     CvPoint p;
456
457     p.x = x;
458     p.y = y;
459
460     return p;
461 }
462
463
464 typedef struct CvPoint2D32f
465 {
466     float x;
467     float y;
468 }
469 CvPoint2D32f;
470
471
472 inline CvPoint2D32f cvPoint2D32f( double x, double y )
473 {
474     CvPoint2D32f p;
475
476     p.x = (float)x;
477     p.y = (float)y;
478
479     return p;
480 }
481
482
483 inline CvPoint2D32f cvPointTo32f( CvPoint point )
484 {
485     return cvPoint2D32f( (float)point.x, (float)point.y );
486 }
487
488
489 inline CvPoint cvPointFrom32f( CvPoint2D32f point )
490 {
491     CvPoint ipt;
492     ipt.x = cvRound(point.x);
493     ipt.y = cvRound(point.y);
494
495     return ipt;
496 }
497
498
499 typedef struct CvPoint3D32f
500 {
501     float x;
502     float y;
503     float z;
504 }
505 CvPoint3D32f;
506
507
508 inline CvPoint3D32f cvPoint3D32f( double x, double y, double z )
509 {
510     CvPoint3D32f p;
511
512     p.x = (float)x;
513     p.y = (float)y;
514     p.z = (float)z;
515
516     return p;
517 }
518
519
520 typedef struct CvPoint2D64f
521 {
522     double x;
523     double y;
524 }
525 CvPoint2D64f;
526
527
528 inline CvPoint2D64f cvPoint2D64f( double x, double y )
529 {
530     CvPoint2D64f p;
531
532     p.x = x;
533     p.y = y;
534
535     return p;
536 }
537
538
539 typedef struct CvPoint3D64f
540 {
541     double x;
542     double y;
543     double z;
544 }
545 CvPoint3D64f;
546
547
548 inline CvPoint3D64f cvPoint3D64f( double x, double y, double z )
549 {
550     CvPoint3D64f p;
551
552     p.x = x;
553     p.y = y;
554     p.z = z;
555
556     return p;
557 }
558
559
560
561
562 typedef struct
563 {
564     int width;
565     int height;
566 }
567 CvSize;
568
569 inline CvSize cvSize( int width, int height )
570 {
571     CvSize s;
572
573     s.width = width;
574     s.height = height;
575
576     return s;
577 }
578
579 typedef struct CvSize2D32f
580 {
581     float width;
582     float height;
583 }
584 CvSize2D32f;
585
586
587 inline CvSize2D32f cvSize2D32f( double width, double height )
588 {
589     CvSize2D32f s;
590
591     s.width = (float)width;
592     s.height = (float)height;
593
594     return s;
595 }
596
597 typedef struct CvBox2D
598 {
599     CvPoint2D32f center;
600     CvSize2D32f size;
601     float angle;
602
603 }
604 CvBox2D;
605
606
607
608 typedef struct CvLineIterator
609 {
610
611     uchar* ptr;
612
613
614     int err;
615     int plus_delta;
616     int minus_delta;
617     int plus_step;
618     int minus_step;
619 }
620 CvLineIterator;
621
622
623
624
625
626 typedef struct CvSlice
627 {
628     int start_index, end_index;
629 }
630 CvSlice;
631
632 inline CvSlice cvSlice( int start, int end )
633 {
634     CvSlice slice;
635     slice.start_index = start;
636     slice.end_index = end;
637
638     return slice;
639 }
640
641
642
643
644
645
646
647 typedef struct CvScalar
648 {
649     double val[4];
650 }
651 CvScalar;
652
653 inline CvScalar cvScalar( double val0, double val1 = 0,
654                                double val2 = 0, double val3 = 0)
655 {
656     CvScalar scalar;
657     scalar.val[0] = val0; scalar.val[1] = val1;
658     scalar.val[2] = val2; scalar.val[3] = val3;
659     return scalar;
660 }
661
662
663 inline CvScalar cvRealScalar( double val0 )
664 {
665     CvScalar scalar;
666     scalar.val[0] = val0;
667     scalar.val[1] = scalar.val[2] = scalar.val[3] = 0;
668     return scalar;
669 }
670
671 inline CvScalar cvScalarAll( double val0123 )
672 {
673     CvScalar scalar;
674     scalar.val[0] = val0123;
675     scalar.val[1] = val0123;
676     scalar.val[2] = val0123;
677     scalar.val[3] = val0123;
678     return scalar;
679 }
680
681
682
683
684
685
686
687 typedef struct CvMemBlock
688 {
689     struct CvMemBlock* prev;
690     struct CvMemBlock* next;
691 }
692 CvMemBlock;
693
694
695
696 typedef struct CvMemStorage
697 {
698     int signature;
699     CvMemBlock* bottom;
700     CvMemBlock* top;
701     struct CvMemStorage* parent;
702     int block_size;
703     int free_space;
704 }
705 CvMemStorage;
706
707
708
709
710
711
712 typedef struct CvMemStoragePos
713 {
714     CvMemBlock* top;
715     int free_space;
716 }
717 CvMemStoragePos;
718
719
720
721
722 typedef struct CvSeqBlock
723 {
724     struct CvSeqBlock* prev;
725     struct CvSeqBlock* next;
726     int start_index;
727
728     int count;
729     schar* data;
730 }
731 CvSeqBlock;
732 # 1217 "../../../cxcore/include/cxtypes.h"
733 typedef struct CvSeq
734 {
735     int flags; int header_size; struct CvSeq* h_prev; struct CvSeq* h_next; struct CvSeq* v_prev; struct CvSeq* v_next; int total; int elem_size; schar* block_max; schar* ptr; int delta_elems; CvMemStorage* storage; CvSeqBlock* free_blocks; CvSeqBlock* first;
736 }
737 CvSeq;
738 # 1237 "../../../cxcore/include/cxtypes.h"
739 typedef struct CvSetElem
740 {
741     int flags; struct CvSetElem* next_free;
742 }
743 CvSetElem;
744
745
746
747
748
749
750 typedef struct CvSet
751 {
752     int flags; int header_size; struct CvSeq* h_prev; struct CvSeq* h_next; struct CvSeq* v_prev; struct CvSeq* v_next; int total; int elem_size; schar* block_max; schar* ptr; int delta_elems; CvMemStorage* storage; CvSeqBlock* free_blocks; CvSeqBlock* first; CvSetElem* free_elems; int active_count;
753 }
754 CvSet;
755 # 1290 "../../../cxcore/include/cxtypes.h"
756 typedef struct CvGraphEdge
757 {
758     int flags; float weight; struct CvGraphEdge* next[2]; struct CvGraphVtx* vtx[2];
759 }
760 CvGraphEdge;
761
762 typedef struct CvGraphVtx
763 {
764     int flags; struct CvGraphEdge* first;
765 }
766 CvGraphVtx;
767
768 typedef struct CvGraphVtx2D
769 {
770     int flags; struct CvGraphEdge* first;
771     CvPoint2D32f* ptr;
772 }
773 CvGraphVtx2D;
774 # 1317 "../../../cxcore/include/cxtypes.h"
775 typedef struct CvGraph
776 {
777     int flags; int header_size; struct CvSeq* h_prev; struct CvSeq* h_next; struct CvSeq* v_prev; struct CvSeq* v_next; int total; int elem_size; schar* block_max; schar* ptr; int delta_elems; CvMemStorage* storage; CvSeqBlock* free_blocks; CvSeqBlock* first; CvSetElem* free_elems; int active_count; CvSet* edges;
778 }
779 CvGraph;
780
781
782
783
784
785 typedef struct CvChain
786 {
787     int flags; int header_size; struct CvSeq* h_prev; struct CvSeq* h_next; struct CvSeq* v_prev; struct CvSeq* v_next; int total; int elem_size; schar* block_max; schar* ptr; int delta_elems; CvMemStorage* storage; CvSeqBlock* free_blocks; CvSeqBlock* first;
788     CvPoint origin;
789 }
790 CvChain;
791
792
793
794
795
796
797
798 typedef struct CvContour
799 {
800     int flags; int header_size; struct CvSeq* h_prev; struct CvSeq* h_next; struct CvSeq* v_prev; struct CvSeq* v_next; int total; int elem_size; schar* block_max; schar* ptr; int delta_elems; CvMemStorage* storage; CvSeqBlock* free_blocks; CvSeqBlock* first; CvRect rect; int color; int reserved[3];
801 }
802 CvContour;
803
804 typedef CvContour CvPoint2DSeq;
805 # 1484 "../../../cxcore/include/cxtypes.h"
806 typedef struct CvSeqWriter
807 {
808     int header_size; CvSeq* seq; CvSeqBlock* block; schar* ptr; schar* block_min; schar* block_max;
809 }
810 CvSeqWriter;
811 # 1502 "../../../cxcore/include/cxtypes.h"
812 typedef struct CvSeqReader
813 {
814     int header_size; CvSeq* seq; CvSeqBlock* block; schar* ptr; schar* block_min; schar* block_max; int delta_index; schar* prev_elem;
815 }
816 CvSeqReader;
817 # 1622 "../../../cxcore/include/cxtypes.h"
818 typedef struct CvFileStorage CvFileStorage;
819 # 1632 "../../../cxcore/include/cxtypes.h"
820 typedef struct CvAttrList
821 {
822     const char** attr;
823     struct CvAttrList* next;
824 }
825 CvAttrList;
826
827 inline CvAttrList cvAttrList( const char** attr = NULL,
828                                  CvAttrList* next = NULL )
829 {
830     CvAttrList l;
831     l.attr = attr;
832     l.next = next;
833
834     return l;
835 }
836
837 struct CvTypeInfo;
838 # 1685 "../../../cxcore/include/cxtypes.h"
839 typedef struct CvString
840 {
841     int len;
842     char* ptr;
843 }
844 CvString;
845
846
847
848 typedef struct CvStringHashNode
849 {
850     unsigned hashval;
851     CvString str;
852     struct CvStringHashNode* next;
853 }
854 CvStringHashNode;
855
856 typedef struct CvGenericHash CvFileNodeHash;
857
858
859 typedef struct CvFileNode
860 {
861     int tag;
862     struct CvTypeInfo* info;
863
864     union
865     {
866         double f;
867         int i;
868         CvString str;
869         CvSeq* seq;
870         CvFileNodeHash* map;
871     } data;
872 }
873 CvFileNode;
874
875
876 extern "C" {
877
878 typedef int ( *CvIsInstanceFunc)( const void* struct_ptr );
879 typedef void ( *CvReleaseFunc)( void** struct_dblptr );
880 typedef void* ( *CvReadFunc)( CvFileStorage* storage, CvFileNode* node );
881 typedef void ( *CvWriteFunc)( CvFileStorage* storage, const char* name,
882                                       const void* struct_ptr, CvAttrList attributes );
883 typedef void* ( *CvCloneFunc)( const void* struct_ptr );
884
885 }
886
887
888 typedef struct CvTypeInfo
889 {
890     int flags;
891     int header_size;
892     struct CvTypeInfo* prev;
893     struct CvTypeInfo* next;
894     const char* type_name;
895     CvIsInstanceFunc is_instance;
896     CvReleaseFunc release;
897     CvReadFunc read;
898     CvWriteFunc write;
899     CvCloneFunc clone;
900 }
901 CvTypeInfo;
902
903
904
905
906 typedef struct CvPluginFuncInfo
907 {
908     void** func_addr;
909     void* default_func_addr;
910     const char* func_names;
911     int search_modules;
912     int loaded_from;
913 }
914 CvPluginFuncInfo;
915
916 typedef struct CvModuleInfo
917 {
918     struct CvModuleInfo* next;
919     const char* name;
920     const char* version;
921     CvPluginFuncInfo* func_tab;
922 }
923 CvModuleInfo;
924 # 70 "../../../cxcore/include/cxcore.h" 2
925 # 1 "../../../cxcore/include/cxerror.h" 1
926 # 47 "../../../cxcore/include/cxerror.h"
927 typedef int CVStatus;
928 # 71 "../../../cxcore/include/cxcore.h" 2
929 # 1 "../../../cxcore/include/cvver.h" 1
930 # 72 "../../../cxcore/include/cxcore.h" 2
931
932
933 extern "C" {
934 # 85 "../../../cxcore/include/cxcore.h"
935 extern "C" void* cvAlloc( size_t size );
936
937
938
939
940
941
942
943 extern "C" void cvFree_( void* ptr );
944
945
946
947 extern "C" IplImage* cvCreateImageHeader( CvSize size, int depth, int channels );
948
949
950 extern "C" IplImage* cvInitImageHeader( IplImage* image, CvSize size, int depth,
951                                    int channels, int origin = 0,
952                                    int align = 4);
953
954
955 extern "C" IplImage* cvCreateImage( CvSize size, int depth, int channels );
956
957
958 extern "C" void cvReleaseImageHeader( IplImage** image );
959
960
961 extern "C" void cvReleaseImage( IplImage** image );
962
963
964 extern "C" IplImage* cvCloneImage( const IplImage* image );
965
966
967
968 extern "C" void cvSetImageCOI( IplImage* image, int coi );
969
970
971 extern "C" int cvGetImageCOI( const IplImage* image );
972
973
974 extern "C" void cvSetImageROI( IplImage* image, CvRect rect );
975
976
977 extern "C" void cvResetImageROI( IplImage* image );
978
979
980 extern "C" CvRect cvGetImageROI( const IplImage* image );
981
982
983 extern "C" CvMat* cvCreateMatHeader( int rows, int cols, int type );
984
985
986
987
988 extern "C" CvMat* cvInitMatHeader( CvMat* mat, int rows, int cols,
989                               int type, void* data = NULL,
990                               int step = 0x7fffffff );
991
992
993 extern "C" CvMat* cvCreateMat( int rows, int cols, int type );
994
995
996
997 extern "C" void cvReleaseMat( CvMat** mat );
998
999
1000
1001 inline void cvDecRefData( CvArr* arr )
1002 {
1003     if( (((arr) != NULL && (((const CvMat*)(arr))->type & 0xFFFF0000) == 0x42420000 && ((const CvMat*)(arr))->cols > 0 && ((const CvMat*)(arr))->rows > 0) && ((const CvMat*)(arr))->data.ptr != NULL))
1004     {
1005         CvMat* mat = (CvMat*)arr;
1006         mat->data.ptr = NULL;
1007         if( mat->refcount != NULL && --*mat->refcount == 0 )
1008             (cvFree_(*(&mat->refcount)), *(&mat->refcount)=0);
1009         mat->refcount = NULL;
1010     }
1011     else if( (((arr) != NULL && (((const CvMatND*)(arr))->type & 0xFFFF0000) == 0x42430000) && ((const CvMatND*)(arr))->data.ptr != NULL))
1012     {
1013         CvMatND* mat = (CvMatND*)arr;
1014         mat->data.ptr = NULL;
1015         if( mat->refcount != NULL && --*mat->refcount == 0 )
1016             (cvFree_(*(&mat->refcount)), *(&mat->refcount)=0);
1017         mat->refcount = NULL;
1018     }
1019 }
1020
1021
1022 inline int cvIncRefData( CvArr* arr )
1023 {
1024     int refcount = 0;
1025     if( (((arr) != NULL && (((const CvMat*)(arr))->type & 0xFFFF0000) == 0x42420000 && ((const CvMat*)(arr))->cols > 0 && ((const CvMat*)(arr))->rows > 0) && ((const CvMat*)(arr))->data.ptr != NULL))
1026     {
1027         CvMat* mat = (CvMat*)arr;
1028         if( mat->refcount != NULL )
1029             refcount = ++*mat->refcount;
1030     }
1031     else if( (((arr) != NULL && (((const CvMatND*)(arr))->type & 0xFFFF0000) == 0x42430000) && ((const CvMatND*)(arr))->data.ptr != NULL))
1032     {
1033         CvMatND* mat = (CvMatND*)arr;
1034         if( mat->refcount != NULL )
1035             refcount = ++*mat->refcount;
1036     }
1037     return refcount;
1038 }
1039
1040
1041
1042 extern "C" CvMat* cvCloneMat( const CvMat* mat );
1043
1044
1045
1046
1047 extern "C" CvMat* cvGetSubRect( const CvArr* arr, CvMat* submat, CvRect rect );
1048
1049
1050
1051
1052 extern "C" CvMat* cvGetRows( const CvArr* arr, CvMat* submat,
1053                         int start_row, int end_row,
1054                         int delta_row = 1);
1055
1056 inline CvMat* cvGetRow( const CvArr* arr, CvMat* submat, int row )
1057 {
1058     return cvGetRows( arr, submat, row, row + 1, 1 );
1059 }
1060
1061
1062
1063
1064 extern "C" CvMat* cvGetCols( const CvArr* arr, CvMat* submat,
1065                         int start_col, int end_col );
1066
1067 inline CvMat* cvGetCol( const CvArr* arr, CvMat* submat, int col )
1068 {
1069     return cvGetCols( arr, submat, col, col + 1 );
1070 }
1071
1072
1073
1074
1075
1076 extern "C" CvMat* cvGetDiag( const CvArr* arr, CvMat* submat,
1077                             int diag = 0);
1078
1079
1080 extern "C" void cvScalarToRawData( const CvScalar* scalar, void* data, int type,
1081                               int extend_to_12 = 0 );
1082
1083 extern "C" void cvRawDataToScalar( const void* data, int type, CvScalar* scalar );
1084
1085
1086 extern "C" CvMatND* cvCreateMatNDHeader( int dims, const int* sizes, int type );
1087
1088
1089 extern "C" CvMatND* cvCreateMatND( int dims, const int* sizes, int type );
1090
1091
1092 extern "C" CvMatND* cvInitMatNDHeader( CvMatND* mat, int dims, const int* sizes,
1093                                     int type, void* data = NULL );
1094
1095
1096 inline void cvReleaseMatND( CvMatND** mat )
1097 {
1098     cvReleaseMat( (CvMat**)mat );
1099 }
1100
1101
1102 extern "C" CvMatND* cvCloneMatND( const CvMatND* mat );
1103
1104
1105 extern "C" CvSparseMat* cvCreateSparseMat( int dims, const int* sizes, int type );
1106
1107
1108 extern "C" void cvReleaseSparseMat( CvSparseMat** mat );
1109
1110
1111 extern "C" CvSparseMat* cvCloneSparseMat( const CvSparseMat* mat );
1112
1113
1114
1115 extern "C" CvSparseNode* cvInitSparseMatIterator( const CvSparseMat* mat,
1116                                               CvSparseMatIterator* mat_iterator );
1117
1118
1119 inline CvSparseNode* cvGetNextSparseNode( CvSparseMatIterator* mat_iterator )
1120 {
1121     if( mat_iterator->node->next )
1122         return mat_iterator->node = mat_iterator->node->next;
1123     else
1124     {
1125         int idx;
1126         for( idx = ++mat_iterator->curidx; idx < mat_iterator->mat->hashsize; idx++ )
1127         {
1128             CvSparseNode* node = (CvSparseNode*)mat_iterator->mat->hashtable[idx];
1129             if( node )
1130             {
1131                 mat_iterator->curidx = idx;
1132                 return mat_iterator->node = node;
1133             }
1134         }
1135         return NULL;
1136     }
1137 }
1138
1139
1140
1141
1142
1143 typedef struct CvNArrayIterator
1144 {
1145     int count;
1146     int dims;
1147     CvSize size;
1148     uchar* ptr[10];
1149     int stack[32];
1150     CvMatND* hdr[10];
1151
1152 }
1153 CvNArrayIterator;
1154 # 312 "../../../cxcore/include/cxcore.h"
1155 extern "C" int cvInitNArrayIterator( int count, CvArr** arrs,
1156                                  const CvArr* mask, CvMatND* stubs,
1157                                  CvNArrayIterator* array_iterator,
1158                                  int flags = 0 );
1159
1160
1161 extern "C" int cvNextNArraySlice( CvNArrayIterator* array_iterator );
1162
1163
1164
1165
1166 extern "C" int cvGetElemType( const CvArr* arr );
1167
1168
1169
1170 extern "C" int cvGetDims( const CvArr* arr, int* sizes = NULL );
1171
1172
1173
1174
1175
1176 extern "C" int cvGetDimSize( const CvArr* arr, int index );
1177
1178
1179
1180
1181 extern "C" uchar* cvPtr1D( const CvArr* arr, int idx0, int* type = NULL);
1182 extern "C" uchar* cvPtr2D( const CvArr* arr, int idx0, int idx1, int* type = NULL );
1183 extern "C" uchar* cvPtr3D( const CvArr* arr, int idx0, int idx1, int idx2,
1184                       int* type = NULL);
1185
1186
1187
1188
1189
1190 extern "C" uchar* cvPtrND( const CvArr* arr, const int* idx, int* type = NULL,
1191                       int create_node = 1,
1192                       unsigned* precalc_hashval = NULL);
1193
1194
1195 extern "C" CvScalar cvGet1D( const CvArr* arr, int idx0 );
1196 extern "C" CvScalar cvGet2D( const CvArr* arr, int idx0, int idx1 );
1197 extern "C" CvScalar cvGet3D( const CvArr* arr, int idx0, int idx1, int idx2 );
1198 extern "C" CvScalar cvGetND( const CvArr* arr, const int* idx );
1199
1200
1201 extern "C" double cvGetReal1D( const CvArr* arr, int idx0 );
1202 extern "C" double cvGetReal2D( const CvArr* arr, int idx0, int idx1 );
1203 extern "C" double cvGetReal3D( const CvArr* arr, int idx0, int idx1, int idx2 );
1204 extern "C" double cvGetRealND( const CvArr* arr, const int* idx );
1205
1206
1207 extern "C" void cvSet1D( CvArr* arr, int idx0, CvScalar value );
1208 extern "C" void cvSet2D( CvArr* arr, int idx0, int idx1, CvScalar value );
1209 extern "C" void cvSet3D( CvArr* arr, int idx0, int idx1, int idx2, CvScalar value );
1210 extern "C" void cvSetND( CvArr* arr, const int* idx, CvScalar value );
1211
1212
1213 extern "C" void cvSetReal1D( CvArr* arr, int idx0, double value );
1214 extern "C" void cvSetReal2D( CvArr* arr, int idx0, int idx1, double value );
1215 extern "C" void cvSetReal3D( CvArr* arr, int idx0,
1216                         int idx1, int idx2, double value );
1217 extern "C" void cvSetRealND( CvArr* arr, const int* idx, double value );
1218
1219
1220
1221 extern "C" void cvClearND( CvArr* arr, const int* idx );
1222
1223
1224
1225
1226
1227
1228 extern "C" CvMat* cvGetMat( const CvArr* arr, CvMat* header,
1229                        int* coi = NULL,
1230                        int allowND = 0);
1231
1232
1233 extern "C" IplImage* cvGetImage( const CvArr* arr, IplImage* image_header );
1234 # 403 "../../../cxcore/include/cxcore.h"
1235 extern "C" CvArr* cvReshapeMatND( const CvArr* arr,
1236                              int sizeof_header, CvArr* header,
1237                              int new_cn, int new_dims, int* new_sizes );
1238
1239
1240
1241
1242
1243 extern "C" CvMat* cvReshape( const CvArr* arr, CvMat* header,
1244                         int new_cn, int new_rows = 0 );
1245
1246
1247
1248 extern "C" void cvRepeat( const CvArr* src, CvArr* dst );
1249
1250
1251 extern "C" void cvCreateData( CvArr* arr );
1252
1253
1254 extern "C" void cvReleaseData( CvArr* arr );
1255
1256
1257
1258
1259 extern "C" void cvSetData( CvArr* arr, void* data, int step );
1260
1261
1262
1263
1264 extern "C" void cvGetRawData( const CvArr* arr, uchar** data,
1265                          int* step = NULL,
1266                          CvSize* roi_size = NULL);
1267
1268
1269 extern "C" CvSize cvGetSize( const CvArr* arr );
1270
1271
1272 extern "C" void cvCopy( const CvArr* src, CvArr* dst,
1273                      const CvArr* mask = NULL );
1274
1275
1276
1277 extern "C" void cvSet( CvArr* arr, CvScalar value,
1278                     const CvArr* mask = NULL );
1279
1280
1281 extern "C" void cvSetZero( CvArr* arr );
1282
1283
1284
1285
1286
1287 extern "C" void cvSplit( const CvArr* src, CvArr* dst0, CvArr* dst1,
1288                       CvArr* dst2, CvArr* dst3 );
1289
1290
1291
1292 extern "C" void cvMerge( const CvArr* src0, const CvArr* src1,
1293                       const CvArr* src2, const CvArr* src3,
1294                       CvArr* dst );
1295
1296
1297
1298 extern "C" void cvMixChannels( const CvArr** src, int src_count,
1299                             CvArr** dst, int dst_count,
1300                             const int* from_to, int pair_count );
1301
1302
1303
1304
1305
1306
1307 extern "C" void cvConvertScale( const CvArr* src, CvArr* dst,
1308                              double scale = 1,
1309                              double shift = 0 );
1310 # 488 "../../../cxcore/include/cxcore.h"
1311 extern "C" void cvConvertScaleAbs( const CvArr* src, CvArr* dst,
1312                                 double scale = 1,
1313                                 double shift = 0 );
1314
1315
1316
1317
1318
1319
1320
1321 extern "C" CvTermCriteria cvCheckTermCriteria( CvTermCriteria criteria,
1322                                            double default_eps,
1323                                            int default_max_iters );
1324
1325
1326
1327
1328
1329
1330 extern "C" void cvAdd( const CvArr* src1, const CvArr* src2, CvArr* dst,
1331                     const CvArr* mask = NULL);
1332
1333
1334 extern "C" void cvAddS( const CvArr* src, CvScalar value, CvArr* dst,
1335                      const CvArr* mask = NULL);
1336
1337
1338 extern "C" void cvSub( const CvArr* src1, const CvArr* src2, CvArr* dst,
1339                     const CvArr* mask = NULL);
1340
1341
1342 inline void cvSubS( const CvArr* src, CvScalar value, CvArr* dst,
1343                          const CvArr* mask = NULL)
1344 {
1345     cvAddS( src, cvScalar( -value.val[0], -value.val[1], -value.val[2], -value.val[3]),
1346             dst, mask );
1347 }
1348
1349
1350 extern "C" void cvSubRS( const CvArr* src, CvScalar value, CvArr* dst,
1351                       const CvArr* mask = NULL);
1352
1353
1354
1355 extern "C" void cvMul( const CvArr* src1, const CvArr* src2,
1356                     CvArr* dst, double scale = 1 );
1357
1358
1359
1360
1361 extern "C" void cvDiv( const CvArr* src1, const CvArr* src2,
1362                     CvArr* dst, double scale = 1);
1363
1364
1365 extern "C" void cvScaleAdd( const CvArr* src1, CvScalar scale,
1366                          const CvArr* src2, CvArr* dst );
1367
1368
1369
1370 extern "C" void cvAddWeighted( const CvArr* src1, double alpha,
1371                             const CvArr* src2, double beta,
1372                             double gamma, CvArr* dst );
1373
1374
1375 extern "C" double cvDotProduct( const CvArr* src1, const CvArr* src2 );
1376
1377
1378 extern "C" void cvAnd( const CvArr* src1, const CvArr* src2,
1379                   CvArr* dst, const CvArr* mask = NULL);
1380
1381
1382 extern "C" void cvAndS( const CvArr* src, CvScalar value,
1383                    CvArr* dst, const CvArr* mask = NULL);
1384
1385
1386 extern "C" void cvOr( const CvArr* src1, const CvArr* src2,
1387                  CvArr* dst, const CvArr* mask = NULL);
1388
1389
1390 extern "C" void cvOrS( const CvArr* src, CvScalar value,
1391                   CvArr* dst, const CvArr* mask = NULL);
1392
1393
1394 extern "C" void cvXor( const CvArr* src1, const CvArr* src2,
1395                   CvArr* dst, const CvArr* mask = NULL);
1396
1397
1398 extern "C" void cvXorS( const CvArr* src, CvScalar value,
1399                    CvArr* dst, const CvArr* mask = NULL);
1400
1401
1402 extern "C" void cvNot( const CvArr* src, CvArr* dst );
1403
1404
1405 extern "C" void cvInRange( const CvArr* src, const CvArr* lower,
1406                       const CvArr* upper, CvArr* dst );
1407
1408
1409 extern "C" void cvInRangeS( const CvArr* src, CvScalar lower,
1410                        CvScalar upper, CvArr* dst );
1411 # 600 "../../../cxcore/include/cxcore.h"
1412 extern "C" void cvCmp( const CvArr* src1, const CvArr* src2, CvArr* dst, int cmp_op );
1413
1414
1415 extern "C" void cvCmpS( const CvArr* src, double value, CvArr* dst, int cmp_op );
1416
1417
1418 extern "C" void cvMin( const CvArr* src1, const CvArr* src2, CvArr* dst );
1419
1420
1421 extern "C" void cvMax( const CvArr* src1, const CvArr* src2, CvArr* dst );
1422
1423
1424 extern "C" void cvMinS( const CvArr* src, double value, CvArr* dst );
1425
1426
1427 extern "C" void cvMaxS( const CvArr* src, double value, CvArr* dst );
1428
1429
1430 extern "C" void cvAbsDiff( const CvArr* src1, const CvArr* src2, CvArr* dst );
1431
1432
1433 extern "C" void cvAbsDiffS( const CvArr* src, CvArr* dst, CvScalar value );
1434 # 630 "../../../cxcore/include/cxcore.h"
1435 extern "C" void cvCartToPolar( const CvArr* x, const CvArr* y,
1436                             CvArr* magnitude, CvArr* angle = NULL,
1437                             int angle_in_degrees = 0);
1438
1439
1440
1441
1442 extern "C" void cvPolarToCart( const CvArr* magnitude, const CvArr* angle,
1443                             CvArr* x, CvArr* y,
1444                             int angle_in_degrees = 0);
1445
1446
1447 extern "C" void cvPow( const CvArr* src, CvArr* dst, double power );
1448
1449
1450
1451
1452 extern "C" void cvExp( const CvArr* src, CvArr* dst );
1453
1454
1455
1456
1457
1458 extern "C" void cvLog( const CvArr* src, CvArr* dst );
1459
1460
1461 extern "C" float cvFastArctan( float y, float x );
1462
1463
1464 extern "C" float cvCbrt( float value );
1465
1466
1467
1468
1469
1470
1471
1472 extern "C" int cvCheckArr( const CvArr* arr, int flags = 0,
1473                         double min_val = 0, double max_val = 0);
1474
1475
1476
1477
1478 extern "C" void cvRandArr( CvRNG* rng, CvArr* arr, int dist_type,
1479                       CvScalar param1, CvScalar param2 );
1480
1481 extern "C" void cvRandShuffle( CvArr* mat, CvRNG* rng,
1482                            double iter_factor = 1.);
1483
1484
1485 extern "C" int cvSolveCubic( const CvMat* coeffs, CvMat* roots );
1486
1487
1488
1489
1490
1491
1492 extern "C" void cvCrossProduct( const CvArr* src1, const CvArr* src2, CvArr* dst );
1493 # 698 "../../../cxcore/include/cxcore.h"
1494 extern "C" void cvGEMM( const CvArr* src1, const CvArr* src2, double alpha,
1495                      const CvArr* src3, double beta, CvArr* dst,
1496                      int tABC = 0);
1497
1498
1499
1500
1501 extern "C" void cvTransform( const CvArr* src, CvArr* dst,
1502                           const CvMat* transmat,
1503                           const CvMat* shiftvec = NULL);
1504
1505
1506
1507 extern "C" void cvPerspectiveTransform( const CvArr* src, CvArr* dst,
1508                                      const CvMat* mat );
1509
1510
1511 extern "C" void cvMulTransposed( const CvArr* src, CvArr* dst, int order,
1512                              const CvArr* delta = NULL,
1513                              double scale = 1. );
1514
1515
1516 extern "C" void cvTranspose( const CvArr* src, CvArr* dst );
1517
1518
1519
1520
1521
1522
1523 extern "C" void cvFlip( const CvArr* src, CvArr* dst = NULL,
1524                      int flip_mode = 0);
1525 # 737 "../../../cxcore/include/cxcore.h"
1526 extern "C" void cvSVD( CvArr* A, CvArr* W, CvArr* U = NULL,
1527                      CvArr* V = NULL, int flags = 0);
1528
1529
1530
1531 extern "C" void cvSVBkSb( const CvArr* W, const CvArr* U,
1532                         const CvArr* V, const CvArr* B,
1533                         CvArr* X, int flags );
1534
1535
1536
1537
1538
1539 extern "C" double cvInvert( const CvArr* src, CvArr* dst,
1540                          int method = 0);
1541
1542
1543
1544
1545 extern "C" int cvSolve( const CvArr* src1, const CvArr* src2, CvArr* dst,
1546                      int method = 0);
1547
1548
1549 extern "C" double cvDet( const CvArr* mat );
1550
1551
1552 extern "C" CvScalar cvTrace( const CvArr* mat );
1553
1554
1555 extern "C" void cvEigenVV( CvArr* mat, CvArr* evects,
1556                         CvArr* evals, double eps = 0);
1557
1558
1559 extern "C" void cvSetIdentity( CvArr* mat, CvScalar value = cvRealScalar(1) );
1560
1561
1562 extern "C" CvArr* cvRange( CvArr* mat, double start, double end );
1563 # 795 "../../../cxcore/include/cxcore.h"
1564 extern "C" void cvCalcCovarMatrix( const CvArr** vects, int count,
1565                                 CvArr* cov_mat, CvArr* avg, int flags );
1566
1567
1568
1569
1570 extern "C" void cvCalcPCA( const CvArr* data, CvArr* mean,
1571                         CvArr* eigenvals, CvArr* eigenvects, int flags );
1572
1573 extern "C" void cvProjectPCA( const CvArr* data, const CvArr* mean,
1574                            const CvArr* eigenvects, CvArr* result );
1575
1576 extern "C" void cvBackProjectPCA( const CvArr* proj, const CvArr* mean,
1577                                const CvArr* eigenvects, CvArr* result );
1578
1579
1580 extern "C" double cvMahalanobis( const CvArr* vec1, const CvArr* vec2, CvArr* mat );
1581
1582
1583
1584
1585
1586
1587
1588 extern "C" CvScalar cvSum( const CvArr* arr );
1589
1590
1591 extern "C" int cvCountNonZero( const CvArr* arr );
1592
1593
1594 extern "C" CvScalar cvAvg( const CvArr* arr, const CvArr* mask = NULL );
1595
1596
1597 extern "C" void cvAvgSdv( const CvArr* arr, CvScalar* mean, CvScalar* std_dev,
1598                        const CvArr* mask = NULL );
1599
1600
1601 extern "C" void cvMinMaxLoc( const CvArr* arr, double* min_val, double* max_val,
1602                           CvPoint* min_loc = NULL,
1603                           CvPoint* max_loc = NULL,
1604                           const CvArr* mask = NULL );
1605 # 854 "../../../cxcore/include/cxcore.h"
1606 extern "C" double cvNorm( const CvArr* arr1, const CvArr* arr2 = NULL,
1607                        int norm_type = 4,
1608                        const CvArr* mask = NULL );
1609
1610 extern "C" void cvNormalize( const CvArr* src, CvArr* dst,
1611                           double a = 1., double b = 0.,
1612                           int norm_type = 4,
1613                           const CvArr* mask = NULL );
1614
1615
1616
1617
1618
1619
1620
1621 extern "C" void cvReduce( const CvArr* src, CvArr* dst, int dim = -1,
1622                        int op = 0 );
1623 # 888 "../../../cxcore/include/cxcore.h"
1624 extern "C" void cvDFT( const CvArr* src, CvArr* dst, int flags,
1625                     int nonzero_rows = 0 );
1626
1627
1628
1629 extern "C" void cvMulSpectrums( const CvArr* src1, const CvArr* src2,
1630                              CvArr* dst, int flags );
1631
1632
1633 extern "C" int cvGetOptimalDFTSize( int size0 );
1634
1635
1636 extern "C" void cvDCT( const CvArr* src, CvArr* dst, int flags );
1637
1638
1639
1640
1641
1642
1643 extern "C" int cvSliceLength( CvSlice slice, const CvSeq* seq );
1644
1645
1646
1647
1648
1649 extern "C" CvMemStorage* cvCreateMemStorage( int block_size = 0);
1650
1651
1652
1653 extern "C" CvMemStorage* cvCreateChildMemStorage( CvMemStorage* parent );
1654
1655
1656
1657
1658 extern "C" void cvReleaseMemStorage( CvMemStorage** storage );
1659
1660
1661
1662
1663
1664
1665 extern "C" void cvClearMemStorage( CvMemStorage* storage );
1666
1667
1668 extern "C" void cvSaveMemStoragePos( const CvMemStorage* storage, CvMemStoragePos* pos );
1669
1670
1671 extern "C" void cvRestoreMemStoragePos( CvMemStorage* storage, CvMemStoragePos* pos );
1672
1673
1674 extern "C" void* cvMemStorageAlloc( CvMemStorage* storage, size_t size );
1675
1676
1677 extern "C" CvString cvMemStorageAllocString( CvMemStorage* storage, const char* ptr,
1678                                         int len = -1 );
1679
1680
1681 extern "C" CvSeq* cvCreateSeq( int seq_flags, int header_size,
1682                             int elem_size, CvMemStorage* storage );
1683
1684
1685
1686 extern "C" void cvSetSeqBlockSize( CvSeq* seq, int delta_elems );
1687
1688
1689
1690 extern "C" schar* cvSeqPush( CvSeq* seq, void* element = NULL);
1691
1692
1693
1694 extern "C" schar* cvSeqPushFront( CvSeq* seq, void* element = NULL);
1695
1696
1697
1698 extern "C" void cvSeqPop( CvSeq* seq, void* element = NULL);
1699
1700
1701
1702 extern "C" void cvSeqPopFront( CvSeq* seq, void* element = NULL);
1703
1704
1705
1706
1707
1708 extern "C" void cvSeqPushMulti( CvSeq* seq, void* elements,
1709                              int count, int in_front = 0 );
1710
1711
1712 extern "C" void cvSeqPopMulti( CvSeq* seq, void* elements,
1713                             int count, int in_front = 0 );
1714
1715
1716
1717 extern "C" schar* cvSeqInsert( CvSeq* seq, int before_index,
1718                             void* element = NULL);
1719
1720
1721 extern "C" void cvSeqRemove( CvSeq* seq, int index );
1722
1723
1724
1725
1726
1727 extern "C" void cvClearSeq( CvSeq* seq );
1728
1729
1730
1731
1732
1733 extern "C" schar* cvGetSeqElem( const CvSeq* seq, int index );
1734
1735
1736
1737 extern "C" int cvSeqElemIdx( const CvSeq* seq, const void* element,
1738                          CvSeqBlock** block = NULL );
1739
1740
1741 extern "C" void cvStartAppendToSeq( CvSeq* seq, CvSeqWriter* writer );
1742
1743
1744
1745 extern "C" void cvStartWriteSeq( int seq_flags, int header_size,
1746                               int elem_size, CvMemStorage* storage,
1747                               CvSeqWriter* writer );
1748
1749
1750
1751
1752
1753 extern "C" CvSeq* cvEndWriteSeq( CvSeqWriter* writer );
1754
1755
1756
1757
1758 extern "C" void cvFlushSeqWriter( CvSeqWriter* writer );
1759
1760
1761
1762
1763 extern "C" void cvStartReadSeq( const CvSeq* seq, CvSeqReader* reader,
1764                            int reverse = 0 );
1765
1766
1767
1768 extern "C" int cvGetSeqReaderPos( CvSeqReader* reader );
1769
1770
1771
1772
1773 extern "C" void cvSetSeqReaderPos( CvSeqReader* reader, int index,
1774                                  int is_relative = 0);
1775
1776
1777 extern "C" void* cvCvtSeqToArray( const CvSeq* seq, void* elements,
1778                                CvSlice slice = cvSlice(0, 0x3fffffff) );
1779
1780
1781
1782
1783 extern "C" CvSeq* cvMakeSeqHeaderForArray( int seq_type, int header_size,
1784                                        int elem_size, void* elements, int total,
1785                                        CvSeq* seq, CvSeqBlock* block );
1786
1787
1788 extern "C" CvSeq* cvSeqSlice( const CvSeq* seq, CvSlice slice,
1789                          CvMemStorage* storage = NULL,
1790                          int copy_data = 0);
1791
1792 inline CvSeq* cvCloneSeq( const CvSeq* seq, CvMemStorage* storage = NULL)
1793 {
1794     return cvSeqSlice( seq, cvSlice(0, 0x3fffffff), storage, 1 );
1795 }
1796
1797
1798 extern "C" void cvSeqRemoveSlice( CvSeq* seq, CvSlice slice );
1799
1800
1801 extern "C" void cvSeqInsertSlice( CvSeq* seq, int before_index, const CvArr* from_arr );
1802
1803
1804 typedef int (* CvCmpFunc)(const void* a, const void* b, void* userdata );
1805
1806
1807 extern "C" void cvSeqSort( CvSeq* seq, CvCmpFunc func, void* userdata = NULL );
1808
1809
1810 extern "C" schar* cvSeqSearch( CvSeq* seq, const void* elem, CvCmpFunc func,
1811                            int is_sorted, int* elem_idx,
1812                            void* userdata = NULL );
1813
1814
1815 extern "C" void cvSeqInvert( CvSeq* seq );
1816
1817
1818 extern "C" int cvSeqPartition( const CvSeq* seq, CvMemStorage* storage,
1819                             CvSeq** labels, CvCmpFunc is_equal, void* userdata );
1820
1821
1822 extern "C" void cvChangeSeqBlock( void* reader, int direction );
1823 extern "C" void cvCreateSeqBlock( CvSeqWriter* writer );
1824
1825
1826
1827 extern "C" CvSet* cvCreateSet( int set_flags, int header_size,
1828                             int elem_size, CvMemStorage* storage );
1829
1830
1831 extern "C" int cvSetAdd( CvSet* set_header, CvSetElem* elem = NULL,
1832                       CvSetElem** inserted_elem = NULL );
1833
1834
1835 inline CvSetElem* cvSetNew( CvSet* set_header )
1836 {
1837     CvSetElem* elem = set_header->free_elems;
1838     if( elem )
1839     {
1840         set_header->free_elems = elem->next_free;
1841         elem->flags = elem->flags & ((1 << 26) - 1);
1842         set_header->active_count++;
1843     }
1844     else
1845         cvSetAdd( set_header, NULL, (CvSetElem**)&elem );
1846     return elem;
1847 }
1848
1849
1850 inline void cvSetRemoveByPtr( CvSet* set_header, void* elem )
1851 {
1852     CvSetElem* _elem = (CvSetElem*)elem;
1853     assert( _elem->flags >= 0 );
1854     _elem->next_free = set_header->free_elems;
1855     _elem->flags = (_elem->flags & ((1 << 26) - 1)) | (1 << (sizeof(int)*8-1));
1856     set_header->free_elems = _elem;
1857     set_header->active_count--;
1858 }
1859
1860
1861 extern "C" void cvSetRemove( CvSet* set_header, int index );
1862
1863
1864
1865 inline CvSetElem* cvGetSetElem( const CvSet* set_header, int index )
1866 {
1867     CvSetElem* elem = (CvSetElem*)cvGetSeqElem( (CvSeq*)set_header, index );
1868     return elem && (((CvSetElem*)(elem))->flags >= 0) ? elem : 0;
1869 }
1870
1871
1872 extern "C" void cvClearSet( CvSet* set_header );
1873
1874
1875 extern "C" CvGraph* cvCreateGraph( int graph_flags, int header_size,
1876                                 int vtx_size, int edge_size,
1877                                 CvMemStorage* storage );
1878
1879
1880 extern "C" int cvGraphAddVtx( CvGraph* graph, const CvGraphVtx* vtx = NULL,
1881                            CvGraphVtx** inserted_vtx = NULL );
1882
1883
1884
1885 extern "C" int cvGraphRemoveVtx( CvGraph* graph, int index );
1886 extern "C" int cvGraphRemoveVtxByPtr( CvGraph* graph, CvGraphVtx* vtx );
1887
1888
1889
1890
1891
1892
1893 extern "C" int cvGraphAddEdge( CvGraph* graph,
1894                             int start_idx, int end_idx,
1895                             const CvGraphEdge* edge = NULL,
1896                             CvGraphEdge** inserted_edge = NULL );
1897
1898 extern "C" int cvGraphAddEdgeByPtr( CvGraph* graph,
1899                                CvGraphVtx* start_vtx, CvGraphVtx* end_vtx,
1900                                const CvGraphEdge* edge = NULL,
1901                                CvGraphEdge** inserted_edge = NULL );
1902
1903
1904 extern "C" void cvGraphRemoveEdge( CvGraph* graph, int start_idx, int end_idx );
1905 extern "C" void cvGraphRemoveEdgeByPtr( CvGraph* graph, CvGraphVtx* start_vtx,
1906                                      CvGraphVtx* end_vtx );
1907
1908
1909 extern "C" CvGraphEdge* cvFindGraphEdge( const CvGraph* graph, int start_idx, int end_idx );
1910 extern "C" CvGraphEdge* cvFindGraphEdgeByPtr( const CvGraph* graph,
1911                                            const CvGraphVtx* start_vtx,
1912                                            const CvGraphVtx* end_vtx );
1913
1914
1915
1916
1917 extern "C" void cvClearGraph( CvGraph* graph );
1918
1919
1920
1921 extern "C" int cvGraphVtxDegree( const CvGraph* graph, int vtx_idx );
1922 extern "C" int cvGraphVtxDegreeByPtr( const CvGraph* graph, const CvGraphVtx* vtx );
1923 # 1222 "../../../cxcore/include/cxcore.h"
1924 typedef struct CvGraphScanner
1925 {
1926     CvGraphVtx* vtx;
1927     CvGraphVtx* dst;
1928     CvGraphEdge* edge;
1929
1930     CvGraph* graph;
1931     CvSeq* stack;
1932     int index;
1933     int mask;
1934 }
1935 CvGraphScanner;
1936
1937
1938 extern "C" CvGraphScanner* cvCreateGraphScanner( CvGraph* graph,
1939                                              CvGraphVtx* vtx = NULL,
1940                                              int mask = -1);
1941
1942
1943 extern "C" void cvReleaseGraphScanner( CvGraphScanner** scanner );
1944
1945
1946 extern "C" int cvNextGraphItem( CvGraphScanner* scanner );
1947
1948
1949 extern "C" CvGraph* cvCloneGraph( const CvGraph* graph, CvMemStorage* storage );
1950 # 1269 "../../../cxcore/include/cxcore.h"
1951 extern "C" void cvLine( CvArr* img, CvPoint pt1, CvPoint pt2,
1952                      CvScalar color, int thickness = 1,
1953                      int line_type = 8, int shift = 0 );
1954
1955
1956
1957 extern "C" void cvRectangle( CvArr* img, CvPoint pt1, CvPoint pt2,
1958                           CvScalar color, int thickness = 1,
1959                           int line_type = 8,
1960                           int shift = 0);
1961
1962
1963
1964 extern "C" void cvCircle( CvArr* img, CvPoint center, int radius,
1965                        CvScalar color, int thickness = 1,
1966                        int line_type = 8, int shift = 0);
1967
1968
1969
1970
1971 extern "C" void cvEllipse( CvArr* img, CvPoint center, CvSize axes,
1972                         double angle, double start_angle, double end_angle,
1973                         CvScalar color, int thickness = 1,
1974                         int line_type = 8, int shift = 0);
1975
1976 inline void cvEllipseBox( CvArr* img, CvBox2D box, CvScalar color,
1977                                int thickness = 1,
1978                                int line_type = 8, int shift = 0 )
1979 {
1980     CvSize axes;
1981     axes.width = cvRound(box.size.height*0.5);
1982     axes.height = cvRound(box.size.width*0.5);
1983
1984     cvEllipse( img, cvPointFrom32f( box.center ), axes, box.angle,
1985                0, 360, color, thickness, line_type, shift );
1986 }
1987
1988
1989 extern "C" void cvFillConvexPoly( CvArr* img, CvPoint* pts, int npts, CvScalar color,
1990                                int line_type = 8, int shift = 0);
1991
1992
1993 extern "C" void cvFillPoly( CvArr* img, CvPoint** pts, int* npts, int contours, CvScalar color,
1994                          int line_type = 8, int shift = 0 );
1995
1996
1997 extern "C" void cvPolyLine( CvArr* img, CvPoint** pts, int* npts, int contours,
1998                          int is_closed, CvScalar color, int thickness = 1,
1999                          int line_type = 8, int shift = 0 );
2000 # 1328 "../../../cxcore/include/cxcore.h"
2001 extern "C" int cvClipLine( CvSize img_size, CvPoint* pt1, CvPoint* pt2 );
2002
2003
2004
2005
2006 extern "C" int cvInitLineIterator( const CvArr* image, CvPoint pt1, CvPoint pt2,
2007                                 CvLineIterator* line_iterator,
2008                                 int connectivity = 8,
2009                                 int left_to_right = 0);
2010 # 1365 "../../../cxcore/include/cxcore.h"
2011 typedef struct CvFont
2012 {
2013     int font_face;
2014     const int* ascii;
2015     const int* greek;
2016     const int* cyrillic;
2017     float hscale, vscale;
2018     float shear;
2019     int thickness;
2020     float dx;
2021     int line_type;
2022 }
2023 CvFont;
2024
2025
2026 extern "C" void cvInitFont( CvFont* font, int font_face,
2027                          double hscale, double vscale,
2028                          double shear = 0,
2029                          int thickness = 1,
2030                          int line_type = 8);
2031
2032 inline CvFont cvFont( double scale, int thickness = 1 )
2033 {
2034     CvFont font;
2035     cvInitFont( &font, 1, scale, scale, 0, thickness, 16 );
2036     return font;
2037 }
2038
2039
2040
2041 extern "C" void cvPutText( CvArr* img, const char* text, CvPoint org,
2042                         const CvFont* font, CvScalar color );
2043
2044
2045 extern "C" void cvGetTextSize( const char* text_string, const CvFont* font,
2046                             CvSize* text_size, int* baseline );
2047
2048
2049
2050
2051 extern "C" CvScalar cvColorToScalar( double packed_color, int arrtype );
2052
2053
2054
2055
2056
2057
2058
2059 extern "C" int cvEllipse2Poly( CvPoint center, CvSize axes,
2060                  int angle, int arc_start, int arc_end, CvPoint * pts, int delta );
2061
2062
2063 extern "C" void cvDrawContours( CvArr *img, CvSeq* contour,
2064                             CvScalar external_color, CvScalar hole_color,
2065                             int max_level, int thickness = 1,
2066                             int line_type = 8,
2067                             CvPoint offset = cvPoint(0,0));
2068
2069
2070
2071 extern "C" void cvLUT( const CvArr* src, CvArr* dst, const CvArr* lut );
2072
2073
2074
2075 typedef struct CvTreeNodeIterator
2076 {
2077     const void* node;
2078     int level;
2079     int max_level;
2080 }
2081 CvTreeNodeIterator;
2082
2083 extern "C" void cvInitTreeNodeIterator( CvTreeNodeIterator* tree_iterator,
2084                                    const void* first, int max_level );
2085 extern "C" void* cvNextTreeNode( CvTreeNodeIterator* tree_iterator );
2086 extern "C" void* cvPrevTreeNode( CvTreeNodeIterator* tree_iterator );
2087
2088
2089
2090
2091 extern "C" void cvInsertNodeIntoTree( void* node, void* parent, void* frame );
2092
2093
2094 extern "C" void cvRemoveNodeFromTree( void* node, void* frame );
2095
2096
2097
2098 extern "C" CvSeq* cvTreeToNodeSeq( const void* first, int header_size,
2099                               CvMemStorage* storage );
2100
2101
2102
2103 extern "C" void cvKMeans2( const CvArr* samples, int cluster_count,
2104                         CvArr* labels, CvTermCriteria termcrit );
2105
2106
2107
2108
2109
2110
2111 extern "C" int cvRegisterModule( const CvModuleInfo* module_info );
2112
2113
2114 extern "C" int cvUseOptimized( int on_off );
2115
2116
2117 extern "C" void cvGetModuleInfo( const char* module_name,
2118                               const char** version,
2119                               const char** loaded_addon_plugins );
2120
2121
2122 extern "C" int cvGetErrStatus( void );
2123
2124
2125 extern "C" void cvSetErrStatus( int status );
2126
2127
2128
2129
2130
2131
2132 extern "C" int cvGetErrMode( void );
2133
2134
2135 extern "C" int cvSetErrMode( int mode );
2136
2137
2138
2139
2140 extern "C" void cvError( int status, const char* func_name,
2141                     const char* err_msg, const char* file_name, int line );
2142
2143
2144 extern "C" const char* cvErrorStr( int status );
2145
2146
2147 extern "C" int cvGetErrInfo( const char** errcode_desc, const char** description,
2148                         const char** filename, int* line );
2149
2150
2151 extern "C" int cvErrorFromIppStatus( int ipp_status );
2152
2153 typedef int ( *CvErrorCallback)( int status, const char* func_name,
2154                     const char* err_msg, const char* file_name, int line, void* userdata );
2155
2156
2157 extern "C" CvErrorCallback cvRedirectError( CvErrorCallback error_handler,
2158                                        void* userdata = NULL,
2159                                        void** prev_userdata = NULL );
2160
2161
2162
2163
2164
2165
2166
2167 extern "C" int cvNulDevReport( int status, const char* func_name, const char* err_msg,
2168                           const char* file_name, int line, void* userdata );
2169
2170 extern "C" int cvStdErrReport( int status, const char* func_name, const char* err_msg,
2171                           const char* file_name, int line, void* userdata );
2172
2173 extern "C" int cvGuiBoxReport( int status, const char* func_name, const char* err_msg,
2174                           const char* file_name, int line, void* userdata );
2175
2176 typedef void* ( *CvAllocFunc)(size_t size, void* userdata);
2177 typedef int ( *CvFreeFunc)(void* pptr, void* userdata);
2178
2179
2180
2181 extern "C" void cvSetMemoryManager( CvAllocFunc alloc_func = NULL,
2182                                CvFreeFunc free_func = NULL,
2183                                void* userdata = NULL);
2184
2185
2186 typedef IplImage* (* Cv_iplCreateImageHeader)
2187                             (int,int,int,char*,char*,int,int,int,int,int,
2188                             IplROI*,IplImage*,void*,IplTileInfo*);
2189 typedef void (* Cv_iplAllocateImageData)(IplImage*,int,int);
2190 typedef void (* Cv_iplDeallocate)(IplImage*,int);
2191 typedef IplROI* (* Cv_iplCreateROI)(int,int,int,int,int);
2192 typedef IplImage* (* Cv_iplCloneImage)(const IplImage*);
2193
2194
2195 extern "C" void cvSetIPLAllocators( Cv_iplCreateImageHeader create_header,
2196                                Cv_iplAllocateImageData allocate_data,
2197                                Cv_iplDeallocate deallocate,
2198                                Cv_iplCreateROI create_roi,
2199                                Cv_iplCloneImage clone_image );
2200 # 1566 "../../../cxcore/include/cxcore.h"
2201 extern "C" CvFileStorage* cvOpenFileStorage( const char* filename,
2202                                           CvMemStorage* memstorage,
2203                                           int flags );
2204
2205
2206 extern "C" void cvReleaseFileStorage( CvFileStorage** fs );
2207
2208
2209 extern "C" const char* cvAttrValue( const CvAttrList* attr, const char* attr_name );
2210
2211
2212 extern "C" void cvStartWriteStruct( CvFileStorage* fs, const char* name,
2213                                 int struct_flags, const char* type_name = NULL,
2214                                 CvAttrList attributes = cvAttrList());
2215
2216
2217 extern "C" void cvEndWriteStruct( CvFileStorage* fs );
2218
2219
2220 extern "C" void cvWriteInt( CvFileStorage* fs, const char* name, int value );
2221
2222
2223 extern "C" void cvWriteReal( CvFileStorage* fs, const char* name, double value );
2224
2225
2226 extern "C" void cvWriteString( CvFileStorage* fs, const char* name,
2227                            const char* str, int quote = 0 );
2228
2229
2230 extern "C" void cvWriteComment( CvFileStorage* fs, const char* comment,
2231                             int eol_comment );
2232
2233
2234
2235 extern "C" void cvWrite( CvFileStorage* fs, const char* name, const void* ptr,
2236                          CvAttrList attributes = cvAttrList());
2237
2238
2239 extern "C" void cvStartNextStream( CvFileStorage* fs );
2240
2241
2242 extern "C" void cvWriteRawData( CvFileStorage* fs, const void* src,
2243                                 int len, const char* dt );
2244
2245
2246
2247 extern "C" CvStringHashNode* cvGetHashedKey( CvFileStorage* fs, const char* name,
2248                                         int len = -1,
2249                                         int create_missing = 0);
2250
2251
2252
2253 extern "C" CvFileNode* cvGetRootFileNode( const CvFileStorage* fs,
2254                                      int stream_index = 0 );
2255
2256
2257
2258 extern "C" CvFileNode* cvGetFileNode( CvFileStorage* fs, CvFileNode* map,
2259                                  const CvStringHashNode* key,
2260                                  int create_missing = 0 );
2261
2262
2263 extern "C" CvFileNode* cvGetFileNodeByName( const CvFileStorage* fs,
2264                                        const CvFileNode* map,
2265                                        const char* name );
2266
2267 inline int cvReadInt( const CvFileNode* node, int default_value = 0 )
2268 {
2269     return !node ? default_value :
2270         (((node->tag) & 7) == 1) ? node->data.i :
2271         (((node->tag) & 7) == 2) ? cvRound(node->data.f) : 0x7fffffff;
2272 }
2273
2274
2275 inline int cvReadIntByName( const CvFileStorage* fs, const CvFileNode* map,
2276                          const char* name, int default_value = 0 )
2277 {
2278     return cvReadInt( cvGetFileNodeByName( fs, map, name ), default_value );
2279 }
2280
2281
2282 inline double cvReadReal( const CvFileNode* node, double default_value = 0. )
2283 {
2284     return !node ? default_value :
2285         (((node->tag) & 7) == 1) ? (double)node->data.i :
2286         (((node->tag) & 7) == 2) ? node->data.f : 1e300;
2287 }
2288
2289
2290 inline double cvReadRealByName( const CvFileStorage* fs, const CvFileNode* map,
2291                         const char* name, double default_value = 0. )
2292 {
2293     return cvReadReal( cvGetFileNodeByName( fs, map, name ), default_value );
2294 }
2295
2296
2297 inline const char* cvReadString( const CvFileNode* node,
2298                         const char* default_value = NULL )
2299 {
2300     return !node ? default_value : (((node->tag) & 7) == 3) ? node->data.str.ptr : 0;
2301 }
2302
2303
2304 inline const char* cvReadStringByName( const CvFileStorage* fs, const CvFileNode* map,
2305                         const char* name, const char* default_value = NULL )
2306 {
2307     return cvReadString( cvGetFileNodeByName( fs, map, name ), default_value );
2308 }
2309
2310
2311
2312 extern "C" void* cvRead( CvFileStorage* fs, CvFileNode* node,
2313                         CvAttrList* attributes = NULL);
2314
2315
2316 inline void* cvReadByName( CvFileStorage* fs, const CvFileNode* map,
2317                               const char* name, CvAttrList* attributes = NULL )
2318 {
2319     return cvRead( fs, cvGetFileNodeByName( fs, map, name ), attributes );
2320 }
2321
2322
2323
2324 extern "C" void cvStartReadRawData( const CvFileStorage* fs, const CvFileNode* src,
2325                                CvSeqReader* reader );
2326
2327
2328 extern "C" void cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader,
2329                                int count, void* dst, const char* dt );
2330
2331
2332 extern "C" void cvReadRawData( const CvFileStorage* fs, const CvFileNode* src,
2333                           void* dst, const char* dt );
2334
2335
2336 extern "C" void cvWriteFileNode( CvFileStorage* fs, const char* new_node_name,
2337                             const CvFileNode* node, int embed );
2338
2339
2340 extern "C" const char* cvGetFileNodeName( const CvFileNode* node );
2341
2342
2343
2344 extern "C" void cvRegisterType( const CvTypeInfo* info );
2345 extern "C" void cvUnregisterType( const char* type_name );
2346 extern "C" CvTypeInfo* cvFirstType(void);
2347 extern "C" CvTypeInfo* cvFindType( const char* type_name );
2348 extern "C" CvTypeInfo* cvTypeOf( const void* struct_ptr );
2349
2350
2351 extern "C" void cvRelease( void** struct_ptr );
2352 extern "C" void* cvClone( const void* struct_ptr );
2353
2354
2355 extern "C" void cvSave( const char* filename, const void* struct_ptr,
2356                     const char* name = NULL,
2357                     const char* comment = NULL,
2358                     CvAttrList attributes = cvAttrList());
2359 extern "C" void* cvLoad( const char* filename,
2360                      CvMemStorage* memstorage = NULL,
2361                      const char* name = NULL,
2362                      const char** real_name = NULL );
2363
2364
2365
2366
2367
2368 extern "C" int64 cvGetTickCount( void );
2369 extern "C" double cvGetTickFrequency( void );
2370
2371
2372
2373
2374 extern "C" int cvGetNumThreads( void );
2375 extern "C" void cvSetNumThreads( int threads = 0 );
2376
2377 extern "C" int cvGetThreadNum( void );
2378
2379
2380 }
2381
2382 # 1 "../../../cxcore/include/cxcore.hpp" 1
2383 # 46 "../../../cxcore/include/cxcore.hpp"
2384 class CvImage
2385 {
2386 public:
2387     CvImage() : image(0), refcount(0) {}
2388     CvImage( CvSize size, int depth, int channels )
2389     {
2390         image = cvCreateImage( size, depth, channels );
2391         refcount = image ? new int(1) : 0;
2392     }
2393
2394     CvImage( IplImage* img ) : image(img)
2395     {
2396         refcount = image ? new int(1) : 0;
2397     }
2398
2399     CvImage( const CvImage& img ) : image(img.image), refcount(img.refcount)
2400     {
2401         if( refcount ) ++(*refcount);
2402     }
2403
2404     CvImage( const char* filename, const char* imgname=0, int color=-1 ) : image(0), refcount(0)
2405     { load( filename, imgname, color ); }
2406
2407     CvImage( CvFileStorage* fs, const char* mapname, const char* imgname ) : image(0), refcount(0)
2408     { read( fs, mapname, imgname ); }
2409
2410     CvImage( CvFileStorage* fs, const char* seqname, int idx ) : image(0), refcount(0)
2411     { read( fs, seqname, idx ); }
2412
2413     ~CvImage()
2414     {
2415         if( refcount && !(--*refcount) )
2416         {
2417             cvReleaseImage( &image );
2418             delete refcount;
2419         }
2420     }
2421
2422     CvImage clone() { return CvImage(image ? cvCloneImage(image) : 0); }
2423
2424     void create( CvSize size, int depth, int channels )
2425     {
2426         attach( cvCreateImage( size, depth, channels ));
2427     }
2428
2429     void release() { detach(); }
2430     void clear() { detach(); }
2431
2432     void attach( IplImage* img, bool use_refcount=true )
2433     {
2434         if( refcount )
2435         {
2436             if( --*refcount == 0 )
2437                 cvReleaseImage( &image );
2438             delete refcount;
2439         }
2440         image = img;
2441         refcount = use_refcount && image ? new int(1) : 0;
2442     }
2443
2444     void detach()
2445     {
2446         if( refcount )
2447         {
2448             if( --*refcount == 0 )
2449                 cvReleaseImage( &image );
2450             delete refcount;
2451             refcount = 0;
2452         }
2453         image = 0;
2454     }
2455
2456     bool load( const char* filename, const char* imgname=0, int color=-1 );
2457     bool read( CvFileStorage* fs, const char* mapname, const char* imgname );
2458     bool read( CvFileStorage* fs, const char* seqname, int idx );
2459     void save( const char* filename, const char* imgname );
2460     void write( CvFileStorage* fs, const char* imgname );
2461
2462     void show( const char* window_name );
2463     bool is_valid() { return image != 0; }
2464
2465     int width() const { return image ? image->width : 0; }
2466     int height() const { return image ? image->height : 0; }
2467
2468     CvSize size() const { return image ? cvSize(image->width, image->height) : cvSize(0,0); }
2469
2470     CvSize roi_size() const
2471     {
2472         return !image ? cvSize(0,0) :
2473             !image->roi ? cvSize(image->width,image->height) :
2474             cvSize(image->roi->width, image->roi->height);
2475     }
2476
2477     CvRect roi() const
2478     {
2479         return !image ? cvRect(0,0,0,0) :
2480             !image->roi ? cvRect(0,0,image->width,image->height) :
2481             cvRect(image->roi->xOffset,image->roi->yOffset,
2482                    image->roi->width,image->roi->height);
2483     }
2484
2485     int coi() const { return !image || !image->roi ? 0 : image->roi->coi; }
2486
2487     void set_roi(CvRect roi) { cvSetImageROI(image,roi); }
2488     void reset_roi() { cvResetImageROI(image); }
2489     void set_coi(int coi) { cvSetImageCOI(image,coi); }
2490     int depth() const { return image ? image->depth : 0; }
2491     int channels() const { return image ? image->nChannels : 0; }
2492     int pix_size() const { return image ? ((image->depth & 255)>>3)*image->nChannels : 0; }
2493
2494     uchar* data() { return image ? (uchar*)image->imageData : 0; }
2495     const uchar* data() const { return image ? (const uchar*)image->imageData : 0; }
2496     int step() const { return image ? image->widthStep : 0; }
2497     int origin() const { return image ? image->origin : 0; }
2498
2499     uchar* roi_row(int y)
2500     {
2501         assert(0<=y);
2502         assert(!image ?
2503                 1 : image->roi ?
2504                 y<image->roi->height : y<image->height);
2505
2506         return !image ? 0 :
2507             !image->roi ?
2508                 (uchar*)(image->imageData + y*image->widthStep) :
2509                 (uchar*)(image->imageData + (y+image->roi->yOffset)*image->widthStep +
2510                 image->roi->xOffset*((image->depth & 255)>>3)*image->nChannels);
2511     }
2512
2513     const uchar* roi_row(int y) const
2514     {
2515         assert(0<=y);
2516         assert(!image ?
2517                 1 : image->roi ?
2518                 y<image->roi->height : y<image->height);
2519
2520         return !image ? 0 :
2521             !image->roi ?
2522                 (const uchar*)(image->imageData + y*image->widthStep) :
2523                 (const uchar*)(image->imageData + (y+image->roi->yOffset)*image->widthStep +
2524                 image->roi->xOffset*((image->depth & 255)>>3)*image->nChannels);
2525     }
2526
2527     operator const IplImage* () const { return image; }
2528     operator IplImage* () { return image; }
2529
2530     CvImage& operator = (const CvImage& img)
2531     {
2532         if( img.refcount )
2533             ++*img.refcount;
2534         if( refcount && !(--*refcount) )
2535             cvReleaseImage( &image );
2536         image=img.image;
2537         refcount=img.refcount;
2538         return *this;
2539     }
2540
2541 protected:
2542     IplImage* image;
2543     int* refcount;
2544 };
2545
2546
2547 class CvMatrix
2548 {
2549 public:
2550     CvMatrix() : matrix(0) {}
2551     CvMatrix( int rows, int cols, int type )
2552     { matrix = cvCreateMat( rows, cols, type ); }
2553
2554     CvMatrix( int rows, int cols, int type, CvMat* hdr,
2555               void* data=0, int step=0x7fffffff )
2556     { matrix = cvInitMatHeader( hdr, rows, cols, type, data, step ); }
2557
2558     CvMatrix( int rows, int cols, int type, CvMemStorage* storage, bool alloc_data=true );
2559
2560     CvMatrix( int rows, int cols, int type, void* data, int step=0x7fffffff )
2561     { matrix = cvCreateMatHeader( rows, cols, type );
2562       cvSetData( matrix, data, step ); }
2563
2564     CvMatrix( CvMat* m )
2565     { matrix = m; }
2566
2567     CvMatrix( const CvMatrix& m )
2568     {
2569         matrix = m.matrix;
2570         addref();
2571     }
2572
2573     CvMatrix( const char* filename, const char* matname=0, int color=-1 ) : matrix(0)
2574     { load( filename, matname, color ); }
2575
2576     CvMatrix( CvFileStorage* fs, const char* mapname, const char* matname ) : matrix(0)
2577     { read( fs, mapname, matname ); }
2578
2579     CvMatrix( CvFileStorage* fs, const char* seqname, int idx ) : matrix(0)
2580     { read( fs, seqname, idx ); }
2581
2582     ~CvMatrix()
2583     {
2584         release();
2585     }
2586
2587     CvMatrix clone() { return CvMatrix(matrix ? cvCloneMat(matrix) : 0); }
2588
2589     void set( CvMat* m, bool add_ref )
2590     {
2591         release();
2592         matrix = m;
2593         if( add_ref )
2594             addref();
2595     }
2596
2597     void create( int rows, int cols, int type )
2598     {
2599         set( cvCreateMat( rows, cols, type ), false );
2600     }
2601
2602     void addref() const
2603     {
2604         if( matrix )
2605         {
2606             if( matrix->hdr_refcount )
2607                 ++matrix->hdr_refcount;
2608             else if( matrix->refcount )
2609                 ++*matrix->refcount;
2610         }
2611     }
2612
2613     void release()
2614     {
2615         if( matrix )
2616         {
2617             if( matrix->hdr_refcount )
2618             {
2619                 if( --matrix->hdr_refcount == 0 )
2620                     cvReleaseMat( &matrix );
2621             }
2622             else if( matrix->refcount )
2623             {
2624                 if( --*matrix->refcount == 0 )
2625                     (cvFree_(*(&matrix->refcount)), *(&matrix->refcount)=0);
2626             }
2627             matrix = 0;
2628         }
2629     }
2630
2631     void clear()
2632     {
2633         release();
2634     }
2635
2636     bool load( const char* filename, const char* matname=0, int color=-1 );
2637     bool read( CvFileStorage* fs, const char* mapname, const char* matname );
2638     bool read( CvFileStorage* fs, const char* seqname, int idx );
2639     void save( const char* filename, const char* matname );
2640     void write( CvFileStorage* fs, const char* matname );
2641
2642     void show( const char* window_name );
2643
2644     bool is_valid() { return matrix != 0; }
2645
2646     int rows() const { return matrix ? matrix->rows : 0; }
2647     int cols() const { return matrix ? matrix->cols : 0; }
2648
2649     CvSize size() const
2650     {
2651         return !matrix ? cvSize(0,0) : cvSize(matrix->rows,matrix->cols);
2652     }
2653
2654     int type() const { return matrix ? ((matrix->type) & ((1 << 3)*64 - 1)) : 0; }
2655     int depth() const { return matrix ? ((matrix->type) & ((1 << 3) - 1)) : 0; }
2656     int channels() const { return matrix ? ((((matrix->type) & ((64 - 1) << 3)) >> 3) + 1) : 0; }
2657     int pix_size() const { return matrix ? (((((matrix->type) & ((64 - 1) << 3)) >> 3) + 1) << ((((sizeof(size_t)/4+1)*16384|0x3a50) >> ((matrix->type) & ((1 << 3) - 1))*2) & 3)) : 0; }
2658
2659     uchar* data() { return matrix ? matrix->data.ptr : 0; }
2660     const uchar* data() const { return matrix ? matrix->data.ptr : 0; }
2661     int step() const { return matrix ? matrix->step : 0; }
2662
2663     void set_data( void* data, int step=0x7fffffff )
2664     { cvSetData( matrix, data, step ); }
2665
2666     uchar* row(int i) { return !matrix ? 0 : matrix->data.ptr + i*matrix->step; }
2667     const uchar* row(int i) const
2668     { return !matrix ? 0 : matrix->data.ptr + i*matrix->step; }
2669
2670     operator const CvMat* () const { return matrix; }
2671     operator CvMat* () { return matrix; }
2672
2673     CvMatrix& operator = (const CvMatrix& _m)
2674     {
2675         _m.addref();
2676         release();
2677         matrix = _m.matrix;
2678         return *this;
2679     }
2680
2681 protected:
2682     CvMat* matrix;
2683 };
2684
2685
2686 typedef IplImage* ( * CvLoadImageFunc)( const char* filename, int colorness );
2687 typedef CvMat* ( * CvLoadImageMFunc)( const char* filename, int colorness );
2688 typedef int ( * CvSaveImageFunc)( const char* filename, const CvArr* image );
2689 typedef void ( * CvShowImageFunc)( const char* windowname, const CvArr* image );
2690
2691 extern "C" int cvSetImageIOFunctions( CvLoadImageFunc _load_image, CvLoadImageMFunc _load_image_m,
2692                             CvSaveImageFunc _save_image, CvShowImageFunc _show_image );
2693
2694
2695
2696
2697
2698 struct CvModule
2699 {
2700     CvModule( CvModuleInfo* _info );
2701     ~CvModule();
2702     CvModuleInfo* info;
2703
2704     static CvModuleInfo* first;
2705     static CvModuleInfo* last;
2706 };
2707
2708 struct CvType
2709 {
2710     CvType( const char* type_name,
2711             CvIsInstanceFunc is_instance, CvReleaseFunc release=0,
2712             CvReadFunc read=0, CvWriteFunc write=0, CvCloneFunc clone=0 );
2713     ~CvType();
2714     CvTypeInfo* info;
2715
2716     static CvTypeInfo* first;
2717     static CvTypeInfo* last;
2718 };
2719 # 1748 "../../../cxcore/include/cxcore.h" 2
2720 # 59 "../../../cv/include/cv.h" 2
2721 # 1 "../../../cv/include/cvtypes.h" 1
2722 # 51 "../../../cv/include/cvtypes.h"
2723 typedef struct CvMoments
2724 {
2725     double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03;
2726     double mu20, mu11, mu02, mu30, mu21, mu12, mu03;
2727     double inv_sqrt_m00;
2728 }
2729 CvMoments;
2730
2731
2732 typedef struct CvHuMoments
2733 {
2734     double hu1, hu2, hu3, hu4, hu5, hu6, hu7;
2735 }
2736 CvHuMoments;
2737
2738
2739
2740 typedef struct CvConnectedComp
2741 {
2742     double area;
2743     CvScalar value;
2744     CvRect rect;
2745     CvSeq* contour;
2746
2747 }
2748 CvConnectedComp;
2749
2750
2751
2752
2753
2754 typedef struct _CvContourScanner* CvContourScanner;
2755 # 99 "../../../cv/include/cvtypes.h"
2756 typedef struct CvChainPtReader
2757 {
2758     int header_size; CvSeq* seq; CvSeqBlock* block; schar* ptr; schar* block_min; schar* block_max; int delta_index; schar* prev_elem;
2759     char code;
2760     CvPoint pt;
2761     schar deltas[8][2];
2762 }
2763 CvChainPtReader;
2764 # 116 "../../../cv/include/cvtypes.h"
2765 typedef struct CvContourTree
2766 {
2767     int flags; int header_size; struct CvSeq* h_prev; struct CvSeq* h_next; struct CvSeq* v_prev; struct CvSeq* v_next; int total; int elem_size; schar* block_max; schar* ptr; int delta_elems; CvMemStorage* storage; CvSeqBlock* free_blocks; CvSeqBlock* first;
2768     CvPoint p1;
2769     CvPoint p2;
2770 }
2771 CvContourTree;
2772
2773
2774 typedef struct CvConvexityDefect
2775 {
2776     CvPoint* start;
2777     CvPoint* end;
2778     CvPoint* depth_point;
2779     float depth;
2780 }
2781 CvConvexityDefect;
2782
2783
2784
2785 typedef size_t CvSubdiv2DEdge;
2786 # 150 "../../../cv/include/cvtypes.h"
2787 typedef struct CvQuadEdge2D
2788 {
2789     int flags; struct CvSubdiv2DPoint* pt[4]; CvSubdiv2DEdge next[4];
2790 }
2791 CvQuadEdge2D;
2792
2793 typedef struct CvSubdiv2DPoint
2794 {
2795     int flags; CvSubdiv2DEdge first; CvPoint2D32f pt;
2796 }
2797 CvSubdiv2DPoint;
2798 # 170 "../../../cv/include/cvtypes.h"
2799 typedef struct CvSubdiv2D
2800 {
2801     int flags; int header_size; struct CvSeq* h_prev; struct CvSeq* h_next; struct CvSeq* v_prev; struct CvSeq* v_next; int total; int elem_size; schar* block_max; schar* ptr; int delta_elems; CvMemStorage* storage; CvSeqBlock* free_blocks; CvSeqBlock* first; CvSetElem* free_elems; int active_count; CvSet* edges; int quad_edges; int is_geometry_valid; CvSubdiv2DEdge recent_edge; CvPoint2D32f topleft; CvPoint2D32f bottomright;
2802 }
2803 CvSubdiv2D;
2804
2805
2806 typedef enum CvSubdiv2DPointLocation
2807 {
2808     CV_PTLOC_ERROR = -2,
2809     CV_PTLOC_OUTSIDE_RECT = -1,
2810     CV_PTLOC_INSIDE = 0,
2811     CV_PTLOC_VERTEX = 1,
2812     CV_PTLOC_ON_EDGE = 2
2813 }
2814 CvSubdiv2DPointLocation;
2815
2816 typedef enum CvNextEdgeType
2817 {
2818     CV_NEXT_AROUND_ORG = 0x00,
2819     CV_NEXT_AROUND_DST = 0x22,
2820     CV_PREV_AROUND_ORG = 0x11,
2821     CV_PREV_AROUND_DST = 0x33,
2822     CV_NEXT_AROUND_LEFT = 0x13,
2823     CV_NEXT_AROUND_RIGHT = 0x31,
2824     CV_PREV_AROUND_LEFT = 0x20,
2825     CV_PREV_AROUND_RIGHT = 0x02
2826 }
2827 CvNextEdgeType;
2828 # 216 "../../../cv/include/cvtypes.h"
2829 typedef enum CvFilter
2830 {
2831     CV_GAUSSIAN_5x5 = 7
2832 }
2833 CvFilter;
2834
2835
2836
2837
2838
2839 typedef float* CvVect32f;
2840 typedef float* CvMatr32f;
2841 typedef double* CvVect64d;
2842 typedef double* CvMatr64d;
2843
2844 typedef struct CvMatrix3
2845 {
2846     float m[3][3];
2847 }
2848 CvMatrix3;
2849
2850
2851
2852 extern "C" {
2853
2854
2855 typedef float ( * CvDistanceFunction)( const float* a, const float* b, void* user_param );
2856
2857
2858 }
2859
2860
2861 typedef struct CvConDensation
2862 {
2863     int MP;
2864     int DP;
2865     float* DynamMatr;
2866     float* State;
2867     int SamplesNum;
2868     float** flSamples;
2869     float** flNewSamples;
2870     float* flConfidence;
2871     float* flCumulative;
2872     float* Temp;
2873     float* RandomSample;
2874     struct CvRandState* RandS;
2875 }
2876 CvConDensation;
2877
2878
2879
2880
2881
2882
2883
2884 typedef struct CvKalman
2885 {
2886     int MP;
2887     int DP;
2888     int CP;
2889
2890
2891
2892     float* PosterState;
2893     float* PriorState;
2894     float* DynamMatr;
2895     float* MeasurementMatr;
2896     float* MNCovariance;
2897     float* PNCovariance;
2898     float* KalmGainMatr;
2899     float* PriorErrorCovariance;
2900     float* PosterErrorCovariance;
2901     float* Temp1;
2902     float* Temp2;
2903
2904
2905     CvMat* state_pre;
2906
2907     CvMat* state_post;
2908
2909     CvMat* transition_matrix;
2910     CvMat* control_matrix;
2911
2912     CvMat* measurement_matrix;
2913     CvMat* process_noise_cov;
2914     CvMat* measurement_noise_cov;
2915     CvMat* error_cov_pre;
2916
2917     CvMat* gain;
2918
2919     CvMat* error_cov_post;
2920
2921     CvMat* temp1;
2922     CvMat* temp2;
2923     CvMat* temp3;
2924     CvMat* temp4;
2925     CvMat* temp5;
2926 }
2927 CvKalman;
2928 # 327 "../../../cv/include/cvtypes.h"
2929 typedef struct CvHaarFeature
2930 {
2931     int tilted;
2932     struct
2933     {
2934         CvRect r;
2935         float weight;
2936     } rect[3];
2937 }
2938 CvHaarFeature;
2939
2940 typedef struct CvHaarClassifier
2941 {
2942     int count;
2943     CvHaarFeature* haar_feature;
2944     float* threshold;
2945     int* left;
2946     int* right;
2947     float* alpha;
2948 }
2949 CvHaarClassifier;
2950
2951 typedef struct CvHaarStageClassifier
2952 {
2953     int count;
2954     float threshold;
2955     CvHaarClassifier* classifier;
2956
2957     int next;
2958     int child;
2959     int parent;
2960 }
2961 CvHaarStageClassifier;
2962
2963 typedef struct CvHidHaarClassifierCascade CvHidHaarClassifierCascade;
2964
2965 typedef struct CvHaarClassifierCascade
2966 {
2967     int flags;
2968     int count;
2969     CvSize orig_window_size;
2970     CvSize real_window_size;
2971     double scale;
2972     CvHaarStageClassifier* stage_classifier;
2973     CvHidHaarClassifierCascade* hid_cascade;
2974 }
2975 CvHaarClassifierCascade;
2976
2977 typedef struct CvAvgComp
2978 {
2979     CvRect rect;
2980     int neighbors;
2981 }
2982 CvAvgComp;
2983 # 60 "../../../cv/include/cv.h" 2
2984
2985
2986 extern "C" {
2987 # 71 "../../../cv/include/cv.h"
2988 extern "C" void cvCopyMakeBorder( const CvArr* src, CvArr* dst, CvPoint offset,
2989                               int bordertype, CvScalar value = cvScalarAll(0));
2990 # 81 "../../../cv/include/cv.h"
2991 extern "C" void cvSmooth( const CvArr* src, CvArr* dst,
2992                       int smoothtype = 2,
2993                       int param1 = 3,
2994                       int param2 = 0,
2995                       double param3 = 0,
2996                       double param4 = 0);
2997
2998
2999 extern "C" void cvFilter2D( const CvArr* src, CvArr* dst, const CvMat* kernel,
3000                         CvPoint anchor = cvPoint(-1,-1));
3001
3002
3003 extern "C" void cvIntegral( const CvArr* image, CvArr* sum,
3004                        CvArr* sqsum = NULL,
3005                        CvArr* tilted_sum = NULL);
3006
3007
3008
3009
3010
3011
3012 extern "C" void cvPyrDown( const CvArr* src, CvArr* dst,
3013                         int filter = CV_GAUSSIAN_5x5 );
3014
3015
3016
3017
3018
3019
3020 extern "C" void cvPyrUp( const CvArr* src, CvArr* dst,
3021                       int filter = CV_GAUSSIAN_5x5 );
3022
3023
3024 extern "C" CvMat** cvCreatePyramid( const CvArr* img, int extra_layers, double rate,
3025                                 const CvSize* layer_sizes = 0,
3026                                 CvArr* bufarr = 0,
3027                                 int calc = 1,
3028                                 int filter = CV_GAUSSIAN_5x5 );
3029
3030
3031 extern "C" void cvReleasePyramid( CvMat*** pyramid, int extra_layers );
3032
3033
3034
3035
3036
3037
3038 extern "C" void cvPyrSegmentation( IplImage* src, IplImage* dst,
3039                               CvMemStorage* storage, CvSeq** comp,
3040                               int level, double threshold1,
3041                               double threshold2 );
3042
3043
3044 extern "C" void cvPyrMeanShiftFiltering( const CvArr* src, CvArr* dst,
3045     double sp, double sr, int max_level = 1,
3046     CvTermCriteria termcrit = cvTermCriteria(1 +2,5,1));
3047
3048
3049 extern "C" void cvWatershed( const CvArr* image, CvArr* markers );
3050
3051
3052
3053
3054
3055 extern "C" void cvInpaint( const CvArr* src, const CvArr* inpaint_mask,
3056                        CvArr* dst, double inpaintRange, int flags );
3057
3058
3059
3060
3061
3062
3063
3064 extern "C" void cvSobel( const CvArr* src, CvArr* dst,
3065                     int xorder, int yorder,
3066                     int aperture_size = 3);
3067
3068
3069 extern "C" void cvLaplace( const CvArr* src, CvArr* dst,
3070                       int aperture_size = 3 );
3071 # 258 "../../../cv/include/cv.h"
3072 extern "C" void cvCvtColor( const CvArr* src, CvArr* dst, int code );
3073 # 269 "../../../cv/include/cv.h"
3074 extern "C" void cvResize( const CvArr* src, CvArr* dst,
3075                        int interpolation = 1);
3076
3077
3078 extern "C" void cvWarpAffine( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
3079                            int flags = 1 +8,
3080                            CvScalar fillval = cvScalarAll(0) );
3081
3082
3083 extern "C" CvMat* cvGetAffineTransform( const CvPoint2D32f * src,
3084                                     const CvPoint2D32f * dst,
3085                                     CvMat * map_matrix );
3086
3087
3088 extern "C" CvMat* cv2DRotationMatrix( CvPoint2D32f center, double angle,
3089                                    double scale, CvMat* map_matrix );
3090
3091
3092 extern "C" void cvWarpPerspective( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
3093                                 int flags = 1 +8,
3094                                 CvScalar fillval = cvScalarAll(0) );
3095
3096
3097 extern "C" CvMat* cvGetPerspectiveTransform( const CvPoint2D32f* src,
3098                                          const CvPoint2D32f* dst,
3099                                          CvMat* map_matrix );
3100
3101
3102 extern "C" void cvRemap( const CvArr* src, CvArr* dst,
3103                       const CvArr* mapx, const CvArr* mapy,
3104                       int flags = 1 +8,
3105                       CvScalar fillval = cvScalarAll(0) );
3106
3107
3108 extern "C" void cvLogPolar( const CvArr* src, CvArr* dst,
3109                          CvPoint2D32f center, double M,
3110                          int flags = 1 +8);
3111
3112
3113
3114
3115
3116
3117
3118 extern "C" IplConvKernel* cvCreateStructuringElementEx(
3119             int cols, int rows, int anchor_x, int anchor_y,
3120             int shape, int* values = NULL );
3121
3122
3123 extern "C" void cvReleaseStructuringElement( IplConvKernel** element );
3124
3125
3126
3127 extern "C" void cvErode( const CvArr* src, CvArr* dst,
3128                       IplConvKernel* element = NULL,
3129                       int iterations = 1 );
3130
3131
3132
3133 extern "C" void cvDilate( const CvArr* src, CvArr* dst,
3134                        IplConvKernel* element = NULL,
3135                        int iterations = 1 );
3136 # 339 "../../../cv/include/cv.h"
3137 extern "C" void cvMorphologyEx( const CvArr* src, CvArr* dst,
3138                              CvArr* temp, IplConvKernel* element,
3139                              int operation, int iterations = 1 );
3140
3141
3142 extern "C" void cvMoments( const CvArr* arr, CvMoments* moments, int binary = 0);
3143
3144
3145 extern "C" double cvGetSpatialMoment( CvMoments* moments, int x_order, int y_order );
3146 extern "C" double cvGetCentralMoment( CvMoments* moments, int x_order, int y_order );
3147 extern "C" double cvGetNormalizedCentralMoment( CvMoments* moments,
3148                                              int x_order, int y_order );
3149
3150
3151 extern "C" void cvGetHuMoments( CvMoments* moments, CvHuMoments* hu_moments );
3152
3153
3154
3155
3156
3157 extern "C" int cvSampleLine( const CvArr* image, CvPoint pt1, CvPoint pt2, void* buffer,
3158                           int connectivity = 8);
3159
3160
3161
3162
3163 extern "C" void cvGetRectSubPix( const CvArr* src, CvArr* dst, CvPoint2D32f center );
3164
3165
3166
3167
3168
3169
3170
3171 extern "C" void cvGetQuadrangleSubPix( const CvArr* src, CvArr* dst,
3172                                     const CvMat* map_matrix );
3173 # 386 "../../../cv/include/cv.h"
3174 extern "C" void cvMatchTemplate( const CvArr* image, const CvArr* templ,
3175                               CvArr* result, int method );
3176
3177
3178
3179 extern "C" float cvCalcEMD2( const CvArr* signature1,
3180                           const CvArr* signature2,
3181                           int distance_type,
3182                           CvDistanceFunction distance_func = NULL,
3183                           const CvArr* cost_matrix = NULL,
3184                           CvArr* flow = NULL,
3185                           float* lower_bound = NULL,
3186                           void* userdata = NULL);
3187
3188
3189
3190
3191
3192
3193
3194 extern "C" int cvFindContours( CvArr* image, CvMemStorage* storage, CvSeq** first_contour,
3195                             int header_size = sizeof(CvContour),
3196                             int mode = 1,
3197                             int method = 2,
3198                             CvPoint offset = cvPoint(0,0));
3199
3200
3201
3202
3203
3204
3205
3206 extern "C" CvContourScanner cvStartFindContours( CvArr* image, CvMemStorage* storage,
3207                             int header_size = sizeof(CvContour),
3208                             int mode = 1,
3209                             int method = 2,
3210                             CvPoint offset = cvPoint(0,0));
3211
3212
3213 extern "C" CvSeq* cvFindNextContour( CvContourScanner scanner );
3214
3215
3216
3217
3218 extern "C" void cvSubstituteContour( CvContourScanner scanner, CvSeq* new_contour );
3219
3220
3221
3222 extern "C" CvSeq* cvEndFindContours( CvContourScanner* scanner );
3223
3224
3225 extern "C" CvSeq* cvApproxChains( CvSeq* src_seq, CvMemStorage* storage,
3226                             int method = 2,
3227                             double parameter = 0,
3228                             int minimal_perimeter = 0,
3229                             int recursive = 0);
3230
3231
3232
3233
3234
3235 extern "C" void cvStartReadChainPoints( CvChain* chain, CvChainPtReader* reader );
3236
3237
3238 extern "C" CvPoint cvReadChainPoint( CvChainPtReader* reader );
3239 # 460 "../../../cv/include/cv.h"
3240 extern "C" void cvCalcOpticalFlowLK( const CvArr* prev, const CvArr* curr,
3241                                   CvSize win_size, CvArr* velx, CvArr* vely );
3242
3243
3244 extern "C" void cvCalcOpticalFlowBM( const CvArr* prev, const CvArr* curr,
3245                                   CvSize block_size, CvSize shift_size,
3246                                   CvSize max_range, int use_previous,
3247                                   CvArr* velx, CvArr* vely );
3248
3249
3250 extern "C" void cvCalcOpticalFlowHS( const CvArr* prev, const CvArr* curr,
3251                                   int use_previous, CvArr* velx, CvArr* vely,
3252                                   double lambda, CvTermCriteria criteria );
3253 # 483 "../../../cv/include/cv.h"
3254 extern "C" void cvCalcOpticalFlowPyrLK( const CvArr* prev, const CvArr* curr,
3255                                      CvArr* prev_pyr, CvArr* curr_pyr,
3256                                      const CvPoint2D32f* prev_features,
3257                                      CvPoint2D32f* curr_features,
3258                                      int count,
3259                                      CvSize win_size,
3260                                      int level,
3261                                      char* status,
3262                                      float* track_error,
3263                                      CvTermCriteria criteria,
3264                                      int flags );
3265
3266
3267
3268
3269 extern "C" void cvCalcAffineFlowPyrLK( const CvArr* prev, const CvArr* curr,
3270                                     CvArr* prev_pyr, CvArr* curr_pyr,
3271                                     const CvPoint2D32f* prev_features,
3272                                     CvPoint2D32f* curr_features,
3273                                     float* matrices, int count,
3274                                     CvSize win_size, int level,
3275                                     char* status, float* track_error,
3276                                     CvTermCriteria criteria, int flags );
3277
3278
3279 extern "C" int cvEstimateRigidTransform( const CvArr* A, const CvArr* B,
3280                                       CvMat* M, int full_affine );
3281 # 524 "../../../cv/include/cv.h"
3282 extern "C" void cvUpdateMotionHistory( const CvArr* silhouette, CvArr* mhi,
3283                                       double timestamp, double duration );
3284
3285
3286
3287 extern "C" void cvCalcMotionGradient( const CvArr* mhi, CvArr* mask, CvArr* orientation,
3288                                      double delta1, double delta2,
3289                                      int aperture_size = 3);
3290
3291
3292
3293
3294 extern "C" double cvCalcGlobalOrientation( const CvArr* orientation, const CvArr* mask,
3295                                         const CvArr* mhi, double timestamp,
3296                                         double duration );
3297
3298
3299
3300 extern "C" CvSeq* cvSegmentMotion( const CvArr* mhi, CvArr* seg_mask,
3301                                 CvMemStorage* storage,
3302                                 double timestamp, double seg_thresh );
3303
3304
3305
3306
3307 extern "C" void cvAcc( const CvArr* image, CvArr* sum,
3308                     const CvArr* mask = NULL );
3309
3310
3311 extern "C" void cvSquareAcc( const CvArr* image, CvArr* sqsum,
3312                           const CvArr* mask = NULL );
3313
3314
3315 extern "C" void cvMultiplyAcc( const CvArr* image1, const CvArr* image2, CvArr* acc,
3316                             const CvArr* mask = NULL );
3317
3318
3319 extern "C" void cvRunningAvg( const CvArr* image, CvArr* acc, double alpha,
3320                            const CvArr* mask = NULL );
3321 # 571 "../../../cv/include/cv.h"
3322 extern "C" int cvCamShift( const CvArr* prob_image, CvRect window,
3323                        CvTermCriteria criteria, CvConnectedComp* comp,
3324                        CvBox2D* box = NULL );
3325
3326
3327
3328 extern "C" int cvMeanShift( const CvArr* prob_image, CvRect window,
3329                         CvTermCriteria criteria, CvConnectedComp* comp );
3330
3331
3332 extern "C" CvConDensation* cvCreateConDensation( int dynam_params,
3333                                              int measure_params,
3334                                              int sample_count );
3335
3336
3337 extern "C" void cvReleaseConDensation( CvConDensation** condens );
3338
3339
3340 extern "C" void cvConDensUpdateByTime( CvConDensation* condens);
3341
3342
3343 extern "C" void cvConDensInitSampleSet( CvConDensation* condens, CvMat* lower_bound, CvMat* upper_bound );
3344
3345
3346 extern "C" CvKalman* cvCreateKalman( int dynam_params, int measure_params,
3347                                 int control_params = 0);
3348
3349
3350 extern "C" void cvReleaseKalman( CvKalman** kalman);
3351
3352
3353 extern "C" const CvMat* cvKalmanPredict( CvKalman* kalman,
3354                                      const CvMat* control = NULL);
3355
3356
3357
3358 extern "C" const CvMat* cvKalmanCorrect( CvKalman* kalman, const CvMat* measurement );
3359
3360
3361
3362
3363
3364
3365 extern "C" void cvInitSubdivDelaunay2D( CvSubdiv2D* subdiv, CvRect rect );
3366
3367
3368 extern "C" CvSubdiv2D* cvCreateSubdiv2D( int subdiv_type, int header_size,
3369                                       int vtx_size, int quadedge_size,
3370                                       CvMemStorage* storage );
3371
3372
3373
3374
3375 inline CvSubdiv2D* cvCreateSubdivDelaunay2D( CvRect rect, CvMemStorage* storage )
3376 {
3377     CvSubdiv2D* subdiv = cvCreateSubdiv2D( (4 << 9), sizeof(*subdiv),
3378                          sizeof(CvSubdiv2DPoint), sizeof(CvQuadEdge2D), storage );
3379
3380     cvInitSubdivDelaunay2D( subdiv, rect );
3381     return subdiv;
3382 }
3383
3384
3385
3386 extern "C" CvSubdiv2DPoint* cvSubdivDelaunay2DInsert( CvSubdiv2D* subdiv, CvPoint2D32f pt);
3387
3388
3389
3390
3391 extern "C" CvSubdiv2DPointLocation cvSubdiv2DLocate(
3392                                CvSubdiv2D* subdiv, CvPoint2D32f pt,
3393                                CvSubdiv2DEdge* edge,
3394                                CvSubdiv2DPoint** vertex = NULL );
3395
3396
3397 extern "C" void cvCalcSubdivVoronoi2D( CvSubdiv2D* subdiv );
3398
3399
3400
3401 extern "C" void cvClearSubdivVoronoi2D( CvSubdiv2D* subdiv );
3402
3403
3404
3405 extern "C" CvSubdiv2DPoint* cvFindNearestPoint2D( CvSubdiv2D* subdiv, CvPoint2D32f pt );
3406
3407
3408
3409
3410 inline CvSubdiv2DEdge cvSubdiv2DNextEdge( CvSubdiv2DEdge edge )
3411 {
3412     return (((CvQuadEdge2D*)((edge) & ~3))->next[(edge)&3]);
3413 }
3414
3415
3416 inline CvSubdiv2DEdge cvSubdiv2DRotateEdge( CvSubdiv2DEdge edge, int rotate )
3417 {
3418     return (edge & ~3) + ((edge + rotate) & 3);
3419 }
3420
3421 inline CvSubdiv2DEdge cvSubdiv2DSymEdge( CvSubdiv2DEdge edge )
3422 {
3423     return edge ^ 2;
3424 }
3425
3426 inline CvSubdiv2DEdge cvSubdiv2DGetEdge( CvSubdiv2DEdge edge, CvNextEdgeType type )
3427 {
3428     CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
3429     edge = e->next[(edge + (int)type) & 3];
3430     return (edge & ~3) + ((edge + ((int)type >> 4)) & 3);
3431 }
3432
3433
3434 inline CvSubdiv2DPoint* cvSubdiv2DEdgeOrg( CvSubdiv2DEdge edge )
3435 {
3436     CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
3437     return (CvSubdiv2DPoint*)e->pt[edge & 3];
3438 }
3439
3440
3441 inline CvSubdiv2DPoint* cvSubdiv2DEdgeDst( CvSubdiv2DEdge edge )
3442 {
3443     CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
3444     return (CvSubdiv2DPoint*)e->pt[(edge + 2) & 3];
3445 }
3446
3447
3448 inline double cvTriangleArea( CvPoint2D32f a, CvPoint2D32f b, CvPoint2D32f c )
3449 {
3450     return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
3451 }
3452 # 711 "../../../cv/include/cv.h"
3453 extern "C" CvSeq* cvApproxPoly( const void* src_seq,
3454                              int header_size, CvMemStorage* storage,
3455                              int method, double parameter,
3456                              int parameter2 = 0);
3457
3458
3459
3460
3461 extern "C" CvSeq* cvFindDominantPoints( CvSeq* contour, CvMemStorage* storage,
3462                                    int method = 1,
3463                                    double parameter1 = 0,
3464                                    double parameter2 = 0,
3465                                    double parameter3 = 0,
3466                                    double parameter4 = 0);
3467
3468
3469 extern "C" double cvArcLength( const void* curve,
3470                             CvSlice slice = cvSlice(0, 0x3fffffff),
3471                             int is_closed = -1);
3472
3473
3474
3475
3476 extern "C" CvRect cvBoundingRect( CvArr* points, int update = 0 );
3477
3478
3479 extern "C" double cvContourArea( const CvArr* contour,
3480                               CvSlice slice = cvSlice(0, 0x3fffffff));
3481
3482
3483 extern "C" CvBox2D cvMinAreaRect2( const CvArr* points,
3484                                 CvMemStorage* storage = NULL);
3485
3486
3487 extern "C" int cvMinEnclosingCircle( const CvArr* points,
3488                                   CvPoint2D32f* center, float* radius );
3489
3490
3491
3492
3493
3494
3495 extern "C" double cvMatchShapes( const void* object1, const void* object2,
3496                               int method, double parameter = 0);
3497
3498
3499 extern "C" CvContourTree* cvCreateContourTree( const CvSeq* contour,
3500                                             CvMemStorage* storage,
3501                                             double threshold );
3502
3503
3504 extern "C" CvSeq* cvContourFromContourTree( const CvContourTree* tree,
3505                                          CvMemStorage* storage,
3506                                          CvTermCriteria criteria );
3507
3508
3509
3510
3511 extern "C" double cvMatchContourTrees( const CvContourTree* tree1,
3512                                     const CvContourTree* tree2,
3513                                     int method, double threshold );
3514
3515
3516 extern "C" void cvCalcPGH( const CvSeq* contour, CvHistogram* hist );
3517
3518
3519
3520
3521
3522 extern "C" CvSeq* cvConvexHull2( const CvArr* input,
3523                              void* hull_storage = NULL,
3524                              int orientation = 1,
3525                              int return_points = 0);
3526
3527
3528 extern "C" int cvCheckContourConvexity( const CvArr* contour );
3529
3530
3531 extern "C" CvSeq* cvConvexityDefects( const CvArr* contour, const CvArr* convexhull,
3532                                    CvMemStorage* storage = NULL);
3533
3534
3535 extern "C" CvBox2D cvFitEllipse2( const CvArr* points );
3536
3537
3538 extern "C" CvRect cvMaxRect( const CvRect* rect1, const CvRect* rect2 );
3539
3540
3541 extern "C" void cvBoxPoints( CvBox2D box, CvPoint2D32f pt[4] );
3542
3543
3544
3545 extern "C" CvSeq* cvPointSeqFromMat( int seq_kind, const CvArr* mat,
3546                                  CvContour* contour_header,
3547                                  CvSeqBlock* block );
3548
3549
3550
3551
3552
3553 extern "C" double cvPointPolygonTest( const CvArr* contour,
3554                                   CvPoint2D32f pt, int measure_dist );
3555
3556
3557
3558
3559
3560
3561 extern "C" CvHistogram* cvCreateHist( int dims, int* sizes, int type,
3562                                    float** ranges = NULL,
3563                                    int uniform = 1);
3564
3565
3566 extern "C" void cvSetHistBinRanges( CvHistogram* hist, float** ranges,
3567                                 int uniform = 1);
3568
3569
3570 extern "C" CvHistogram* cvMakeHistHeaderForArray(
3571                             int dims, int* sizes, CvHistogram* hist,
3572                             float* data, float** ranges = NULL,
3573                             int uniform = 1);
3574
3575
3576 extern "C" void cvReleaseHist( CvHistogram** hist );
3577
3578
3579 extern "C" void cvClearHist( CvHistogram* hist );
3580
3581
3582 extern "C" void cvGetMinMaxHistValue( const CvHistogram* hist,
3583                                    float* min_value, float* max_value,
3584                                    int* min_idx = NULL,
3585                                    int* max_idx = NULL);
3586
3587
3588
3589
3590 extern "C" void cvNormalizeHist( CvHistogram* hist, double factor );
3591
3592
3593
3594 extern "C" void cvThreshHist( CvHistogram* hist, double threshold );
3595
3596
3597
3598
3599
3600
3601
3602 extern "C" double cvCompareHist( const CvHistogram* hist1,
3603                               const CvHistogram* hist2,
3604                               int method);
3605
3606
3607
3608 extern "C" void cvCopyHist( const CvHistogram* src, CvHistogram** dst );
3609
3610
3611
3612
3613 extern "C" void cvCalcBayesianProb( CvHistogram** src, int number,
3614                                 CvHistogram** dst);
3615
3616
3617 extern "C" void cvCalcArrHist( CvArr** arr, CvHistogram* hist,
3618                             int accumulate = 0,
3619                             const CvArr* mask = NULL );
3620
3621 inline void cvCalcHist( IplImage** image, CvHistogram* hist,
3622                              int accumulate = 0,
3623                              const CvArr* mask = NULL )
3624 {
3625     cvCalcArrHist( (CvArr**)image, hist, accumulate, mask );
3626 }
3627
3628
3629 extern "C" void cvCalcArrBackProject( CvArr** image, CvArr* dst,
3630                                    const CvHistogram* hist );
3631
3632
3633
3634
3635
3636 extern "C" void cvCalcArrBackProjectPatch( CvArr** image, CvArr* dst, CvSize range,
3637                                         CvHistogram* hist, int method,
3638                                         double factor );
3639
3640
3641
3642
3643
3644 extern "C" void cvCalcProbDensity( const CvHistogram* hist1, const CvHistogram* hist2,
3645                                 CvHistogram* dst_hist, double scale = 255 );
3646
3647
3648 extern "C" void cvEqualizeHist( const CvArr* src, CvArr* dst );
3649
3650
3651
3652
3653
3654
3655 extern "C" void cvSnakeImage( const IplImage* image, CvPoint* points,
3656                            int length, float* alpha,
3657                            float* beta, float* gamma,
3658                            int coeff_usage, CvSize win,
3659                            CvTermCriteria criteria, int calc_gradient = 1);
3660
3661
3662 extern "C" void cvCalcImageHomography( float* line, CvPoint3D32f* center,
3663                                     float* intrinsic, float* homography );
3664
3665
3666
3667
3668
3669
3670 extern "C" void cvDistTransform( const CvArr* src, CvArr* dst,
3671                               int distance_type = 2,
3672                               int mask_size = 3,
3673                               const float* mask = NULL,
3674                               CvArr* labels = NULL);
3675 # 948 "../../../cv/include/cv.h"
3676 extern "C" double cvThreshold( const CvArr* src, CvArr* dst,
3677                             double threshold, double max_value,
3678                             int threshold_type );
3679 # 960 "../../../cv/include/cv.h"
3680 extern "C" void cvAdaptiveThreshold( const CvArr* src, CvArr* dst, double max_value,
3681                                   int adaptive_method = 0,
3682                                   int threshold_type = 0,
3683                                   int block_size = 3,
3684                                   double param1 = 5);
3685
3686
3687
3688
3689
3690 extern "C" void cvFloodFill( CvArr* image, CvPoint seed_point,
3691                           CvScalar new_val, CvScalar lo_diff = cvScalarAll(0),
3692                           CvScalar up_diff = cvScalarAll(0),
3693                           CvConnectedComp* comp = NULL,
3694                           int flags = 4,
3695                           CvArr* mask = NULL);
3696 # 984 "../../../cv/include/cv.h"
3697 extern "C" void cvCanny( const CvArr* image, CvArr* edges, double threshold1,
3698                       double threshold2, int aperture_size = 3 );
3699
3700
3701
3702
3703 extern "C" void cvPreCornerDetect( const CvArr* image, CvArr* corners,
3704                               int aperture_size = 3 );
3705
3706
3707
3708 extern "C" void cvCornerEigenValsAndVecs( const CvArr* image, CvArr* eigenvv,
3709                                       int block_size, int aperture_size = 3 );
3710
3711
3712
3713 extern "C" void cvCornerMinEigenVal( const CvArr* image, CvArr* eigenval,
3714                                  int block_size, int aperture_size = 3 );
3715
3716
3717
3718 extern "C" void cvCornerHarris( const CvArr* image, CvArr* harris_responce,
3719                              int block_size, int aperture_size = 3,
3720                              double k = 0.04 );
3721
3722
3723 extern "C" void cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners,
3724                                  int count, CvSize win, CvSize zero_zone,
3725                                  CvTermCriteria criteria );
3726
3727
3728
3729 extern "C" void cvGoodFeaturesToTrack( const CvArr* image, CvArr* eig_image,
3730                                    CvArr* temp_image, CvPoint2D32f* corners,
3731                                    int* corner_count, double quality_level,
3732                                    double min_distance,
3733                                    const CvArr* mask = NULL,
3734                                    int block_size = 3,
3735                                    int use_harris = 0,
3736                                    double k = 0.04 );
3737 # 1037 "../../../cv/include/cv.h"
3738 extern "C" CvSeq* cvHoughLines2( CvArr* image, void* line_storage, int method,
3739                               double rho, double theta, int threshold,
3740                               double param1 = 0, double param2 = 0);
3741
3742
3743 extern "C" CvSeq* cvHoughCircles( CvArr* image, void* circle_storage,
3744                               int method, double dp, double min_dist,
3745                               double param1 = 100,
3746                               double param2 = 100,
3747                               int min_radius = 0,
3748                               int max_radius = 0);
3749
3750
3751 extern "C" void cvFitLine( const CvArr* points, int dist_type, double param,
3752                         double reps, double aeps, float* line );
3753
3754
3755
3756
3757
3758
3759
3760 extern "C" CvHaarClassifierCascade* cvLoadHaarClassifierCascade(
3761                     const char* directory, CvSize orig_window_size);
3762
3763 extern "C" void cvReleaseHaarClassifierCascade( CvHaarClassifierCascade** cascade );
3764
3765
3766
3767
3768
3769
3770 extern "C" CvSeq* cvHaarDetectObjects( const CvArr* image,
3771                      CvHaarClassifierCascade* cascade,
3772                      CvMemStorage* storage, double scale_factor = 1.1,
3773                      int min_neighbors = 3, int flags = 0,
3774                      CvSize min_size = cvSize(0,0));
3775
3776
3777 extern "C" void cvSetImagesForHaarClassifierCascade( CvHaarClassifierCascade* cascade,
3778                                                 const CvArr* sum, const CvArr* sqsum,
3779                                                 const CvArr* tilted_sum, double scale );
3780
3781
3782 extern "C" int cvRunHaarClassifierCascade( CvHaarClassifierCascade* cascade,
3783                                       CvPoint pt, int start_stage = 0);
3784
3785
3786
3787
3788
3789
3790 extern "C" void cvUndistort2( const CvArr* src, CvArr* dst,
3791                           const CvMat* intrinsic_matrix,
3792                           const CvMat* distortion_coeffs );
3793
3794
3795
3796 extern "C" void cvInitUndistortMap( const CvMat* intrinsic_matrix,
3797                                 const CvMat* distortion_coeffs,
3798                                 CvArr* mapx, CvArr* mapy );
3799
3800
3801 extern "C" int cvRodrigues2( const CvMat* src, CvMat* dst,
3802                          CvMat* jacobian = 0 );
3803
3804
3805 extern "C" void cvFindHomography( const CvMat* src_points,
3806                               const CvMat* dst_points,
3807                               CvMat* homography );
3808
3809
3810 extern "C" void cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ,
3811                            CvMat *matrixQx = NULL,
3812                            CvMat *matrixQy = NULL,
3813                            CvMat *matrixQz = NULL,
3814                            CvPoint3D64f *eulerAngles = NULL);
3815
3816
3817 extern "C" void cvDecomposeProjectionMatrix( const CvMat *projMatr, CvMat *calibMatr,
3818                                          CvMat *rotMatr, CvMat *posVect,
3819                                          CvMat *rotMatrX = NULL,
3820                                          CvMat *rotMatrY = NULL,
3821                                          CvMat *rotMatrZ = NULL,
3822                                          CvPoint3D64f *eulerAngles = NULL);
3823
3824
3825
3826 extern "C" void cvProjectPoints2( const CvMat* object_points, const CvMat* rotation_vector,
3827                               const CvMat* translation_vector, const CvMat* intrinsic_matrix,
3828                               const CvMat* distortion_coeffs, CvMat* image_points,
3829                               CvMat* dpdrot = NULL, CvMat* dpdt = NULL,
3830                               CvMat* dpdf = NULL, CvMat* dpdc = NULL,
3831                               CvMat* dpddist = NULL );
3832
3833
3834
3835 extern "C" void cvFindExtrinsicCameraParams2( const CvMat* object_points,
3836                                           const CvMat* image_points,
3837                                           const CvMat* intrinsic_matrix,
3838                                           const CvMat* distortion_coeffs,
3839                                           CvMat* rotation_vector,
3840                                           CvMat* translation_vector );
3841 # 1148 "../../../cv/include/cv.h"
3842 extern "C" void cvCalibrateCamera2( const CvMat* object_points,
3843                                 const CvMat* image_points,
3844                                 const CvMat* point_counts,
3845                                 CvSize image_size,
3846                                 CvMat* intrinsic_matrix,
3847                                 CvMat* distortion_coeffs,
3848                                 CvMat* rotation_vectors = NULL,
3849                                 CvMat* translation_vectors = NULL,
3850                                 int flags = 0 );
3851
3852
3853
3854
3855
3856
3857 extern "C" int cvFindChessboardCorners( const void* image, CvSize pattern_size,
3858                                     CvPoint2D32f* corners,
3859                                     int* corner_count = NULL,
3860                                     int flags = 1 );
3861
3862
3863 extern "C" void cvDrawChessboardCorners( CvArr* image, CvSize pattern_size,
3864                                      CvPoint2D32f* corners,
3865                                      int count, int pattern_was_found );
3866
3867 typedef struct CvPOSITObject CvPOSITObject;
3868
3869
3870 extern "C" CvPOSITObject* cvCreatePOSITObject( CvPoint3D32f* points, int point_count );
3871
3872
3873
3874
3875 extern "C" void cvPOSIT( CvPOSITObject* posit_object, CvPoint2D32f* image_points,
3876                        double focal_length, CvTermCriteria criteria,
3877                        CvMatr32f rotation_matrix, CvVect32f translation_vector);
3878
3879
3880 extern "C" void cvReleasePOSITObject( CvPOSITObject** posit_object );
3881
3882
3883
3884
3885
3886
3887
3888 extern "C" int cvRANSACUpdateNumIters( double p, double err_prob,
3889                                    int model_points, int max_iters );
3890
3891 extern "C" void cvConvertPointsHomogenious( const CvMat* src, CvMat* dst );
3892 # 1206 "../../../cv/include/cv.h"
3893 extern "C" int cvFindFundamentalMat( const CvMat* points1, const CvMat* points2,
3894                                  CvMat* fundamental_matrix,
3895                                  int method = (8 + 2),
3896                                  double param1 = 1., double param2 = 0.99,
3897                                  CvMat* status = NULL );
3898
3899
3900
3901
3902 extern "C" void cvComputeCorrespondEpilines( const CvMat* points,
3903                                          int which_image,
3904                                          const CvMat* fundamental_matrix,
3905                                          CvMat* correspondent_lines );
3906
3907
3908 }
3909
3910
3911
3912 # 1 "../../../cv/include/cv.hpp" 1
3913 # 57 "../../../cv/include/cv.hpp"
3914 typedef void (*CvRowFilterFunc)( const uchar* src, uchar* dst, void* params );
3915 typedef void (*CvColumnFilterFunc)( uchar** src, uchar* dst, int dst_step, int count, void* params );
3916
3917 class CvBaseImageFilter
3918 {
3919 public:
3920     CvBaseImageFilter();
3921
3922     CvBaseImageFilter( int _max_width, int _src_type, int _dst_type,
3923                        bool _is_separable, CvSize _ksize,
3924                        CvPoint _anchor=cvPoint(-1,-1),
3925                        int _border_mode=1,
3926                        CvScalar _border_value=cvScalarAll(0) );
3927     virtual ~CvBaseImageFilter();
3928 # 82 "../../../cv/include/cv.hpp"
3929     virtual void init( int _max_width, int _src_type, int _dst_type,
3930                        bool _is_separable, CvSize _ksize,
3931                        CvPoint _anchor=cvPoint(-1,-1),
3932                        int _border_mode=1,
3933                        CvScalar _border_value=cvScalarAll(0) );
3934
3935
3936     virtual void clear();
3937 # 105 "../../../cv/include/cv.hpp"
3938     virtual int process( const CvMat* _src, CvMat* _dst,
3939                          CvRect _src_roi=cvRect(0,0,-1,-1),
3940                          CvPoint _dst_origin=cvPoint(0,0), int _flags=0 );
3941
3942     int get_src_type() const { return src_type; }
3943     int get_dst_type() const { return dst_type; }
3944     int get_work_type() const { return work_type; }
3945     CvSize get_kernel_size() const { return ksize; }
3946     CvPoint get_anchor() const { return anchor; }
3947     int get_width() const { return prev_x_range.end_index - prev_x_range.start_index; }
3948     CvRowFilterFunc get_x_filter_func() const { return x_func; }
3949     CvColumnFilterFunc get_y_filter_func() const { return y_func; }
3950
3951 protected:
3952
3953     virtual void get_work_params();
3954
3955
3956
3957     virtual void start_process( CvSlice x_range, int width );
3958
3959
3960     virtual void make_y_border( int row_count, int top_rows, int bottom_rows );
3961
3962     virtual int fill_cyclic_buffer( const uchar* src, int src_step,
3963                                     int y, int y1, int y2 );
3964
3965     enum { ALIGN=32 };
3966
3967     int max_width;
3968
3969     int min_depth, src_type, dst_type, work_type;
3970
3971
3972
3973     CvRowFilterFunc x_func;
3974     CvColumnFilterFunc y_func;
3975
3976     uchar* buffer;
3977     uchar** rows;
3978     int top_rows, bottom_rows, max_rows;
3979     uchar *buf_start, *buf_end, *buf_head, *buf_tail;
3980     int buf_size, buf_step, buf_count, buf_max_count;
3981
3982     bool is_separable;
3983     CvSize ksize;
3984     CvPoint anchor;
3985     int max_ky, border_mode;
3986     CvScalar border_value;
3987     uchar* const_row;
3988     int* border_tab;
3989     int border_tab_sz1, border_tab_sz;
3990
3991     CvSlice prev_x_range;
3992     int prev_width;
3993 };
3994
3995
3996
3997 class CvSepFilter : public CvBaseImageFilter
3998 {
3999 public:
4000     CvSepFilter();
4001     CvSepFilter( int _max_width, int _src_type, int _dst_type,
4002                  const CvMat* _kx, const CvMat* _ky,
4003                  CvPoint _anchor=cvPoint(-1,-1),
4004                  int _border_mode=1,
4005                  CvScalar _border_value=cvScalarAll(0) );
4006     virtual ~CvSepFilter();
4007
4008     virtual void init( int _max_width, int _src_type, int _dst_type,
4009                        const CvMat* _kx, const CvMat* _ky,
4010                        CvPoint _anchor=cvPoint(-1,-1),
4011                        int _border_mode=1,
4012                        CvScalar _border_value=cvScalarAll(0) );
4013     virtual void init_deriv( int _max_width, int _src_type, int _dst_type,
4014                              int dx, int dy, int aperture_size, int flags=0 );
4015     virtual void init_gaussian( int _max_width, int _src_type, int _dst_type,
4016                                 int gaussian_size, double sigma );
4017
4018
4019     virtual void init( int _max_width, int _src_type, int _dst_type,
4020                        bool _is_separable, CvSize _ksize,
4021                        CvPoint _anchor=cvPoint(-1,-1),
4022                        int _border_mode=1,
4023                        CvScalar _border_value=cvScalarAll(0) );
4024
4025     virtual void clear();
4026     const CvMat* get_x_kernel() const { return kx; }
4027     const CvMat* get_y_kernel() const { return ky; }
4028     int get_x_kernel_flags() const { return kx_flags; }
4029     int get_y_kernel_flags() const { return ky_flags; }
4030
4031     enum { GENERIC=0, ASYMMETRICAL=1, SYMMETRICAL=2, POSITIVE=4, SUM_TO_1=8, INTEGER=16 };
4032     enum { NORMALIZE_KERNEL=1, FLIP_KERNEL=2 };
4033
4034     static void init_gaussian_kernel( CvMat* kernel, double sigma=-1 );
4035     static void init_sobel_kernel( CvMat* _kx, CvMat* _ky, int dx, int dy, int flags=0 );
4036     static void init_scharr_kernel( CvMat* _kx, CvMat* _ky, int dx, int dy, int flags=0 );
4037
4038 protected:
4039     CvMat *kx, *ky;
4040     int kx_flags, ky_flags;
4041 };
4042
4043
4044
4045 class CvLinearFilter : public CvBaseImageFilter
4046 {
4047 public:
4048     CvLinearFilter();
4049     CvLinearFilter( int _max_width, int _src_type, int _dst_type,
4050                     const CvMat* _kernel,
4051                     CvPoint _anchor=cvPoint(-1,-1),
4052                     int _border_mode=1,
4053                     CvScalar _border_value=cvScalarAll(0) );
4054     virtual ~CvLinearFilter();
4055
4056     virtual void init( int _max_width, int _src_type, int _dst_type,
4057                        const CvMat* _kernel,
4058                        CvPoint _anchor=cvPoint(-1,-1),
4059                        int _border_mode=1,
4060                        CvScalar _border_value=cvScalarAll(0) );
4061
4062
4063     virtual void init( int _max_width, int _src_type, int _dst_type,
4064                        bool _is_separable, CvSize _ksize,
4065                        CvPoint _anchor=cvPoint(-1,-1),
4066                        int _border_mode=1,
4067                        CvScalar _border_value=cvScalarAll(0) );
4068
4069     virtual void clear();
4070     const CvMat* get_kernel() const { return kernel; }
4071     uchar* get_kernel_sparse_buf() { return k_sparse; }
4072     int get_kernel_sparse_count() const { return k_sparse_count; }
4073
4074 protected:
4075     CvMat *kernel;
4076     uchar* k_sparse;
4077     int k_sparse_count;
4078 };
4079
4080
4081
4082 class CvBoxFilter : public CvBaseImageFilter
4083 {
4084 public:
4085     CvBoxFilter();
4086     CvBoxFilter( int _max_width, int _src_type, int _dst_type,
4087                  bool _normalized, CvSize _ksize,
4088                  CvPoint _anchor=cvPoint(-1,-1),
4089                  int _border_mode=1,
4090                  CvScalar _border_value=cvScalarAll(0) );
4091     virtual void init( int _max_width, int _src_type, int _dst_type,
4092                        bool _normalized, CvSize _ksize,
4093                        CvPoint _anchor=cvPoint(-1,-1),
4094                        int _border_mode=1,
4095                        CvScalar _border_value=cvScalarAll(0) );
4096
4097     virtual ~CvBoxFilter();
4098     bool is_normalized() const { return normalized; }
4099     double get_scale() const { return scale; }
4100     uchar* get_sum_buf() { return sum; }
4101     int* get_sum_count_ptr() { return &sum_count; }
4102
4103 protected:
4104     virtual void start_process( CvSlice x_range, int width );
4105
4106     uchar* sum;
4107     int sum_count;
4108     bool normalized;
4109     double scale;
4110 };
4111
4112
4113
4114 class CvLaplaceFilter : public CvSepFilter
4115 {
4116 public:
4117     CvLaplaceFilter();
4118     CvLaplaceFilter( int _max_width, int _src_type, int _dst_type,
4119                      bool _normalized, int _ksize,
4120                      int _border_mode=1,
4121                      CvScalar _border_value=cvScalarAll(0) );
4122     virtual ~CvLaplaceFilter();
4123     virtual void init( int _max_width, int _src_type, int _dst_type,
4124                        bool _normalized, int _ksize,
4125                        int _border_mode=1,
4126                        CvScalar _border_value=cvScalarAll(0) );
4127
4128
4129     virtual void init( int _max_width, int _src_type, int _dst_type,
4130                        bool _is_separable, CvSize _ksize,
4131                        CvPoint _anchor=cvPoint(-1,-1),
4132                        int _border_mode=1,
4133                        CvScalar _border_value=cvScalarAll(0) );
4134
4135     virtual void init( int _max_width, int _src_type, int _dst_type,
4136                        const CvMat* _kx, const CvMat* _ky,
4137                        CvPoint _anchor=cvPoint(-1,-1),
4138                        int _border_mode=1,
4139                        CvScalar _border_value=cvScalarAll(0) );
4140
4141     bool is_normalized() const { return normalized; }
4142     bool is_basic_laplacian() const { return basic_laplacian; }
4143 protected:
4144     void get_work_params();
4145
4146     bool basic_laplacian;
4147     bool normalized;
4148 };
4149
4150
4151
4152 class CvMorphology : public CvBaseImageFilter
4153 {
4154 public:
4155     CvMorphology();
4156     CvMorphology( int _operation, int _max_width, int _src_dst_type,
4157                   int _element_shape, CvMat* _element,
4158                   CvSize _ksize=cvSize(0,0), CvPoint _anchor=cvPoint(-1,-1),
4159                   int _border_mode=1,
4160                   CvScalar _border_value=cvScalarAll(0) );
4161     virtual ~CvMorphology();
4162     virtual void init( int _operation, int _max_width, int _src_dst_type,
4163                        int _element_shape, CvMat* _element,
4164                        CvSize _ksize=cvSize(0,0), CvPoint _anchor=cvPoint(-1,-1),
4165                        int _border_mode=1,
4166                        CvScalar _border_value=cvScalarAll(0) );
4167
4168
4169     virtual void init( int _max_width, int _src_type, int _dst_type,
4170                        bool _is_separable, CvSize _ksize,
4171                        CvPoint _anchor=cvPoint(-1,-1),
4172                        int _border_mode=1,
4173                        CvScalar _border_value=cvScalarAll(0) );
4174
4175     virtual void clear();
4176     const CvMat* get_element() const { return element; }
4177     int get_element_shape() const { return el_shape; }
4178     int get_operation() const { return operation; }
4179     uchar* get_element_sparse_buf() { return el_sparse; }
4180     int get_element_sparse_count() const { return el_sparse_count; }
4181
4182     enum { RECT=0, CROSS=1, ELLIPSE=2, CUSTOM=100, BINARY = 0, GRAYSCALE=256 };
4183     enum { ERODE=0, DILATE=1 };
4184
4185     static void init_binary_element( CvMat* _element, int _element_shape,
4186                                      CvPoint _anchor=cvPoint(-1,-1) );
4187 protected:
4188
4189     void start_process( CvSlice x_range, int width );
4190     int fill_cyclic_buffer( const uchar* src, int src_step,
4191                             int y0, int y1, int y2 );
4192     uchar* el_sparse;
4193     int el_sparse_count;
4194
4195     CvMat *element;
4196     int el_shape;
4197     int operation;
4198 };
4199 # 1226 "../../../cv/include/cv.h" 2