1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
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.
10 // Intel License Agreement
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
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.
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.
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.
42 /* This file contains custom python shadow class code for certain troublesome functions */
48 %define %myshadow(function)
50 %rename (function) function##_Shadow;
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
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);
70 // eliminates need for IplImage ** typemap
71 %rename (cvCalcImageHist) cvCalcHist;
74 def cvCalcHist(*args):
75 return cvCalcArrHist(*args)
79 // must come after %ignore, %rename
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;
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*;
93 /* Define sequence type for functions returning sequences */
94 %define %cast_seq( cvfunc, type )
95 %rename (cvfunc##Untyped) cvfunc;
99 seq = cvfunc##Untyped( *args )
100 return type.cast(seq)
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 );
111 /* Special cases ... */
112 %rename(cvFindContoursUntyped) cvFindContours;
115 def cvFindContours( *args ):
116 count, seq = cvFindContoursUntyped( *args )
117 return count, CvSeq_CvPoint.cast(seq)
121 /* cvHoughLines2 returns a different type of sequence depending on its args */
122 %rename (cvHoughLinesUntyped) cvHoughLines2;
125 def cvHoughLines2( *args ):
126 seq = cvHoughLinesUntyped( *args )
127 type = CV_SEQ_ELTYPE(seq)
129 return CvSeq_CvPoint_2.cast(seq)
130 return CvSeq_float_2.cast(seq)
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)
145 %rename (function) function##_Shadow;
147 void function##_Shadow(PyObject * obj){
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);