]> rtime.felk.cvut.cz Git - opencv.git/blob - opencv/interfaces/swig/octave/cvshadow.i
Some improvements for the Octave bindings & samples.
[opencv.git] / 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 %pythoncode %{
74 def cvCalcHist(*args):
75         return cvCalcArrHist(*args)
76 %}
77 */
78
79 // must come after %ignore, %rename
80 %include "cvshadow.h"
81
82 /* return a typed CvSeq instead of generic for CvSubdiv2D edges -- see cvseq.i */
83 %rename (untyped_edges) CvSubdiv2D::edges;
84 %ignore CvSubdiv2D::edges;
85 %rename (edges) CvSubdiv2D::typed_edges;
86
87 /* Octave doesn't know what to do with these */
88 %rename (asIplImage) operator IplImage*;
89 %rename (asCvMat) operator CvMat*;
90 %ignore operator const IplImage*;
91 %ignore operator const CvMat*;
92
93 /* Define sequence type for functions returning sequences */
94 %define %cast_seq( cvfunc, type )
95 %rename (cvfunc##Untyped) cvfunc;
96 /*
97 %pythoncode %{
98 def cvfunc(*args):
99         seq = cvfunc##Untyped( *args )
100         return type.cast(seq)
101 %}
102 */
103 %enddef
104
105 %cast_seq( cvHoughCircles, CvSeq_float_3 );
106 %cast_seq( cvPyrSegmentation, CvSeq_CvConnectedComp );
107 %cast_seq( cvApproxChains, CvSeq_CvPoint);
108 %cast_seq( cvContourFromContourTree, CvSeq_CvPoint );
109 %cast_seq( cvConvexityDefects, CvSeq_CvConvexityDefect );
110
111 /* Special cases ... */
112 %rename(cvFindContoursUntyped) cvFindContours;
113 /*
114 %pythoncode %{
115 def cvFindContours( *args ):
116         count, seq = cvFindContoursUntyped( *args )
117         return count, CvSeq_CvPoint.cast(seq)
118 %}
119 */
120
121 /* cvHoughLines2 returns a different type of sequence depending on its args */
122 %rename (cvHoughLinesUntyped) cvHoughLines2;
123 /*
124 %pythoncode %{
125 def cvHoughLines2( *args ):
126         seq = cvHoughLinesUntyped( *args )
127         type = CV_SEQ_ELTYPE(seq) 
128         if type == CV_32SC4:
129                 return CvSeq_CvPoint_2.cast(seq)
130         return CvSeq_float_2.cast(seq)
131 %}
132 */
133
134 // cvPointSeqFromMat
135 // cvSeqPartition
136 // cvSeqSlice
137 // cvTreeToNodeSeq
138
139 /*
140 // cvRelease* functions don't consider Octave's reference count
141 // so we get a double-free error when the reference count reaches zero.
142 // Instead, make these no-ops.
143 %define %myrelease(function)
144 %ignore function;
145 %rename (function) function##_Shadow;
146 %inline %{
147 void function##_Shadow(PyObject * obj){
148 }
149 %}
150 %enddef
151
152 %myrelease(cvReleaseImage);
153 %myrelease(cvReleaseMat);
154 %myrelease(cvReleaseStructuringElement);
155 %myrelease(cvReleaseConDensation);
156 %myrelease(cvReleaseKalman);
157 %myrelease(cvReleaseHist);
158 %myrelease(cvReleaseHaarClassifierCascade);
159 %myrelease(cvReleasePOSITObject);
160 %myrelease(cvReleaseImageHeader);
161 %myrelease(cvReleaseMatND);
162 %myrelease(cvReleaseSparseMat);
163 %myrelease(cvReleaseMemStorage);
164 %myrelease(cvReleaseGraphScanner);
165 %myrelease(cvReleaseFileStorage);
166 %myrelease(cvRelease);
167 %myrelease(cvReleaseCapture);
168 %myrelease(cvReleaseVideoWriter);
169 */