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.
43 // 2004-03-23, Mark Asbach <asbach@ient.rwth-aachen.de>
44 // Institute of Communications Engineering, RWTH Aachen University
47 %extend IplImage { ~IplImage () { IplImage * dummy = self; cvReleaseImage (& dummy); } }
48 %extend CvMat { ~CvMat () { CvMat * dummy = self; cvReleaseMat (& dummy); } }
49 %extend CvMatND { ~CvMatND () { CvMatND * dummy = self; cvReleaseMatND (& dummy); } }
50 %extend CvSparseMat { ~CvSparseMat () { CvSparseMat * dummy = self; cvReleaseSparseMat (& dummy); } }
51 %extend CvMemStorage { ~CvMemStorage () { CvMemStorage * dummy = self; cvReleaseMemStorage (& dummy); } }
52 %extend CvGraphScanner { ~CvGraphScanner () { CvGraphScanner * dummy = self; cvReleaseGraphScanner (& dummy); } }
53 %extend CvFileStorage { ~CvFileStorage () { CvFileStorage * dummy = self; cvReleaseFileStorage (& dummy); } }
54 %extend IplConvKernel { ~IplConvKernel () { IplConvKernel * dummy = self; cvReleaseStructuringElement (& dummy); } }
55 %extend CvKalman { ~CvKalman () { CvKalman * dummy = self; cvReleaseKalman (& dummy); } }
56 %extend CvConDensation { ~CvConDensation () { CvConDensation * dummy = self; cvReleaseConDensation (& dummy); } }
57 %extend CvHistogram { ~CvHistogram () { CvHistogram * dummy = self; cvReleaseHist (& dummy); } }
58 %extend CvHaarClassifierCascade { ~CvHaarClassifierCascade () { CvHaarClassifierCascade * dummy = self; cvReleaseHaarClassifierCascade (& dummy); } }
59 %extend CvPOSITObject { ~CvPOSITObject () { CvPOSITObject * dummy = self; cvReleasePOSITObject (& dummy); } }
61 // string operators for some OpenCV types
65 const char * __str__(){
67 snprintf(str, 256, "[%f, %f, %f, %f]", self->val[0], self->val[1], self->val[2], self->val[3]);
70 const char * __repr__(){
72 snprintf(str, 256, "cvScalar(%f, %f, %f, %f)", self->val[0], self->val[1], self->val[2], self->val[3]);
75 const double __getitem__ (int index) {
77 PyErr_SetString (PyExc_IndexError, "indice must be lower than 4");
81 PyErr_SetString (PyExc_IndexError, "indice must be bigger or egal to -4");
85 /* negative index means from the end in python */
88 return self->val [index];
90 void __setitem__ (int index, double value) {
92 PyErr_SetString (PyExc_IndexError, "indice must be lower than 4");
96 PyErr_SetString (PyExc_IndexError, "indice must be bigger or egal to -4");
100 /* negative index means from the end in python */
103 self->val [index] = value;
109 const char * __str__(){
111 snprintf(str, 64, "[%f %f]", self->x, self->y);
114 const char * __repr__(){
116 snprintf(str, 64, "cvPoint2D32f(%f,%f)", self->x, self->y);
123 const char * __str__(){
125 snprintf(str, 64, "[%d %d]", self->x, self->y);
128 const char * __repr__(){
130 snprintf(str, 64, "cvPoint(%d,%d)", self->x, self->y);
135 // Set up CvMat to emulate IplImage fields
137 int CvMat_cols_get(CvMat * m){
140 int CvMat_rows_get(CvMat *m){
143 int CvMat_width_get(CvMat * m){
146 int CvMat_height_get(CvMat *m){
149 int CvMat_depth_get(CvMat * m){
150 return cvCvToIplDepth(m->type);
152 int CvMat_nChannels_get(CvMat * m){
153 return CV_MAT_CN(m->type);
155 int CvMat_origin_get(CvMat * m){
158 int CvMat_dataOrder_get(CvMat * m){
161 int CvMat_imageSize_get(CvMat * m){
162 return m->step*m->rows;
164 int CvMat_widthStep_get(CvMat * m){
178 // swig doesn't like the embedded union in CvMat, so re-add these