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