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 // source %myshadow, %myrelease macros
49 %include "cvswigmacros.i"
53 // %ignore, %rename must come before %include
54 %myshadow(cvCvtSeqToArray);
55 %myshadow(cvHaarDetectObjects);
56 %myshadow(cvSegmentMotion);
57 %myshadow(cvApproxPoly);
58 %myshadow(cvConvexHull2);
59 %newobject cvConvexHull2_Shadow; // shadowed functioned always returns new object
61 /* cvSnakeImage shadow uses a vector<CvPoint> and vector<float> */
62 %template(FloatVector) std::vector<float>;
63 %template(CvPointVector) std::vector<CvPoint>;
64 %myshadow(cvSnakeImage);
66 // must come after %ignore, %rename
69 /* return a typed CvSeq instead of generic for CvSubdiv2D edges -- see cvseq.i */
70 %rename (untyped_edges) CvSubdiv2D::edges;
71 %ignore CvSubdiv2D::edges;
72 %rename (edges) CvSubdiv2D::typed_edges;
74 /* Python doesn't know what to do with these */
75 %rename (asIplImage) operator IplImage*;
76 %rename (asCvMat) operator CvMat*;
77 %ignore operator const IplImage*;
78 %ignore operator const CvMat*;
80 /* Define sequence type for functions returning sequences */
81 %define %cast_seq( cvfunc, type )
82 %rename (cvfunc##Untyped) cvfunc;
85 seq = cvfunc##Untyped( *args )
90 %cast_seq( cvHoughCircles, CvSeq_float_3 );
91 %cast_seq( cvPyrSegmentation, CvSeq_CvConnectedComp );
92 %cast_seq( cvApproxChains, CvSeq_CvPoint);
93 %cast_seq( cvContourFromContourTree, CvSeq_CvPoint );
94 %cast_seq( cvConvexityDefects, CvSeq_CvConvexityDefect );
96 /* Special cases ... */
97 %rename(cvFindContoursUntyped) cvFindContours;
99 def cvFindContours( *args ):
100 count, seq = cvFindContoursUntyped( *args )
101 return count, CvSeq_CvPoint.cast(seq)
104 /* cvHoughLines2 returns a different type of sequence depending on its args */
105 %rename (cvHoughLinesUntyped) cvHoughLines2;
107 def cvHoughLines2( *args ):
108 seq = cvHoughLinesUntyped( *args )
109 type = CV_SEQ_ELTYPE(seq)
111 return CvSeq_CvPoint_2.cast(seq)
112 return CvSeq_float_2.cast(seq)
120 // Fix cvRelease* function to play nice w/ Python
121 // TODO some of these objects lack the delete method -- why???
122 %myrelease(cv, cvReleaseImage, CvMat); // IplImage is CvMat in Python
123 %myrelease(cv, cvReleaseMat, CvMat);
124 %myrelease(cv, cvReleaseStructuringElement, IplConvKernel);
125 %myrelease(cv, cvReleaseConDensation, CvConDensation);
126 %myrelease(cv, cvReleaseKalman, CvKalman);
127 %myrelease(cv, cvReleaseHist, CvHistogram);
128 %myrelease(cv, cvReleaseHaarClassifierCascade, CvHaarClassifierCascade);
129 //%myrelease(cvReleasePOSITObject, CvPOSITObject);
130 %myrelease(cv, cvReleaseImageHeader, CvMat); // IplImage is CvMat
131 %myrelease(cv, cvReleaseMatND, CvMatND);
132 %myrelease(cv, cvReleaseSparseMat, CvSparseMat);
133 %myrelease(cv, cvReleaseMemStorage, CvMemStorage);
134 %myrelease(cv, cvReleaseGraphScanner, CvGraphScanner);
135 //%myrelease(cvReleaseFileStorage, CvFileStorage);
137 // TODO implement this