0074db7dba2fc00df8230466977f5f42907c3e3f
[opencv] / interfaces / swig / octave / cvshadow.i
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 //  By downloading, copying, installing or using the software you agree to this license.
6 //  If you do not agree to this license, do not download, install,
7 //  copy or use the software.
8 //
9 //
10 //                        Intel License Agreement
11 //                For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
15 //
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
18 //
19 //   * Redistribution's of source code must retain the above copyright notice,
20 //     this list of conditions and the following disclaimer.
21 //
22 //   * Redistribution's in binary form must reproduce the above copyright notice,
23 //     this list of conditions and the following disclaimer in the documentation
24 //     and/or other materials provided with the distribution.
25 //
26 //   * The name of Intel Corporation may not be used to endorse or promote products
27 //     derived from this software without specific prior written permission.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 //M*/
41
42 /* This file contains custom python shadow class code for certain troublesome functions */
43
44 %{
45 #include "cvshadow.h"
46 %}
47
48 %define %myshadow(function)
49 %ignore function;
50 %rename (function) function##_Shadow;
51 %enddef
52
53 %include "stl.i"
54
55 // %ignore, %rename must come before %include
56 %myshadow(cvCvtSeqToArray);
57 %myshadow(cvArcLength);
58 %myshadow(cvHaarDetectObjects);
59 %myshadow(cvSegmentMotion);
60 %myshadow(cvApproxPoly);
61 %myshadow(cvContourPerimeter);
62 %myshadow(cvConvexHull2);
63 %newobject cvConvexHull2; // shadowed functioned always returns new object
64
65 /* cvSnakeImage shadow uses a vector<CvPoint> and vector<float> */ 
66 %template(FloatVector)   std::vector<float>;
67 %template(CvPointVector) std::vector<CvPoint>;
68 %myshadow(cvSnakeImage);
69
70 // eliminates need for IplImage ** typemap
71 %rename (cvCalcImageHist) cvCalcHist;
72
73 // must come after %ignore, %rename
74 %include "cvshadow.h"
75
76 /* return a typed CvSeq instead of generic for CvSubdiv2D edges -- see cvseq.i */
77 %rename (untyped_edges) CvSubdiv2D::edges;
78 %ignore CvSubdiv2D::edges;
79 %rename (edges) CvSubdiv2D::typed_edges;
80
81 /* Octave doesn't know what to do with these */
82 %rename (asIplImage) operator IplImage*;
83 %rename (asCvMat) operator CvMat*;
84 %ignore operator const IplImage*;
85 %ignore operator const CvMat*;
86
87 /* Define sequence type for functions returning sequences */
88 %define %cast_seq( cvfunc, type )
89 %rename (cvfunc##Untyped) cvfunc;
90 %enddef
91
92 %cast_seq( cvHoughCircles, CvSeq_float_3 );
93 %cast_seq( cvPyrSegmentation, CvSeq_CvConnectedComp );
94 %cast_seq( cvApproxChains, CvSeq_CvPoint);
95 %cast_seq( cvContourFromContourTree, CvSeq_CvPoint );
96 %cast_seq( cvConvexityDefects, CvSeq_CvConvexityDefect );
97
98 /* Special cases ... */
99 %rename(cvFindContoursUntyped) cvFindContours;
100
101 /* cvHoughLines2 returns a different type of sequence depending on its args */
102 %rename (cvHoughLinesUntyped) cvHoughLines2;
103
104 // cvPointSeqFromMat
105 // cvSeqPartition
106 // cvSeqSlice
107 // cvTreeToNodeSeq
108
109 /*
110 // cvRelease* functions don't consider Octave's reference count
111 // so we get a double-free error when the reference count reaches zero.
112 // Instead, make these no-ops.
113 %define %myrelease(function)
114 %ignore function;
115 %rename (function) function##_Shadow;
116 %inline %{
117 void function##_Shadow(PyObject * obj){
118 }
119 %}
120 %enddef
121
122 %myrelease(cvReleaseImage);
123 %myrelease(cvReleaseMat);
124 %myrelease(cvReleaseStructuringElement);
125 %myrelease(cvReleaseConDensation);
126 %myrelease(cvReleaseKalman);
127 %myrelease(cvReleaseHist);
128 %myrelease(cvReleaseHaarClassifierCascade);
129 %myrelease(cvReleasePOSITObject);
130 %myrelease(cvReleaseImageHeader);
131 %myrelease(cvReleaseMatND);
132 %myrelease(cvReleaseSparseMat);
133 %myrelease(cvReleaseMemStorage);
134 %myrelease(cvReleaseGraphScanner);
135 %myrelease(cvReleaseFileStorage);
136 %myrelease(cvRelease);
137 %myrelease(cvReleaseCapture);
138 %myrelease(cvReleaseVideoWriter);
139 */