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