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
45 // 2008-05-15, Xavier Delacour <xavier.delacour@gmail.com>
48 %extend IplImage { ~IplImage () { IplImage * dummy = self; cvReleaseImage (& dummy); } }
49 %extend CvMat { ~CvMat () { CvMat * dummy = self; cvReleaseMat (& dummy); } }
50 %extend CvMatND { ~CvMatND () { CvMatND * dummy = self; cvReleaseMatND (& dummy); } }
51 %extend CvSparseMat { ~CvSparseMat () { CvSparseMat * dummy = self; cvReleaseSparseMat (& dummy); } }
52 %extend CvMemStorage { ~CvMemStorage () { CvMemStorage * dummy = self; cvReleaseMemStorage (& dummy); } }
53 %extend CvGraphScanner { ~CvGraphScanner () { CvGraphScanner * dummy = self; cvReleaseGraphScanner (& dummy); } }
54 %extend CvFileStorage { ~CvFileStorage () { CvFileStorage * dummy = self; cvReleaseFileStorage (& dummy); } }
55 %extend IplConvKernel { ~IplConvKernel () { IplConvKernel * dummy = self; cvReleaseStructuringElement (& dummy); } }
56 %extend CvKalman { ~CvKalman () { CvKalman * dummy = self; cvReleaseKalman (& dummy); } }
57 %extend CvConDensation { ~CvConDensation () { CvConDensation * dummy = self; cvReleaseConDensation (& dummy); } }
58 %extend CvHistogram { ~CvHistogram () { CvHistogram * dummy = self; cvReleaseHist (& dummy); } }
59 %extend CvHaarClassifierCascade { ~CvHaarClassifierCascade () { CvHaarClassifierCascade * dummy = self; cvReleaseHaarClassifierCascade (& dummy); } }
60 %extend CvPOSITObject { ~CvPOSITObject () { CvPOSITObject * dummy = self; cvReleasePOSITObject (& dummy); } }
61 %extend CvFeatureTree { ~CvFeatureTree () { CvFeatureTree * dummy = self; cvReleaseFeatureTree (& dummy); } }
63 // string operators for some OpenCV types
67 const char * __str__(){
69 snprintf(str, 256, "[%f, %f, %f, %f]", self->val[0], self->val[1], self->val[2], self->val[3]);
72 const char * __repr__(){
74 snprintf(str, 256, "cvScalar(%f, %f, %f, %f)", self->val[0], self->val[1], self->val[2], self->val[3]);
77 const double __getitem__ (int index) {
79 #ifdef defined(SWIGPYTHON)
80 PyErr_SetString (PyExc_IndexError, "indice must be lower than 4");
81 #elif defined(SWIGOCTAVE)
82 error("indice must be lower than 4");
87 #ifdef defined(SWIGPYTHON)
88 PyErr_SetString (PyExc_IndexError, "indice must be bigger or egal to -4");
89 #elif defined(SWIGOCTAVE)
90 error("indice must be bigger or egal to -4");
95 /* negative index means from the end in python */
98 return self->val [index];
100 void __setitem__ (int index, double value) {
102 #ifdef defined(SWIGPYTHON)
103 PyErr_SetString (PyExc_IndexError, "indice must be lower than 4");
104 #elif defined(SWIGOCTAVE)
105 error("indice must be lower than 4");
110 #ifdef defined(SWIGPYTHON)
111 PyErr_SetString (PyExc_IndexError, "indice must be bigger or egal to -4");
112 #elif defined(SWIGOCTAVE)
113 error("indice must be bigger or egal to -4");
118 /* negative index means from the end in python */
121 self->val [index] = value;
127 const char * __str__(){
129 snprintf(str, 64, "[%f %f]", self->x, self->y);
132 const char * __repr__(){
134 snprintf(str, 64, "cvPoint2D32f(%f,%f)", self->x, self->y);
141 const char * __str__(){
143 snprintf(str, 64, "[%d %d]", self->x, self->y);
146 const char * __repr__(){
148 snprintf(str, 64, "cvPoint(%d,%d)", self->x, self->y);
153 // Set up CvMat to emulate IplImage fields
155 int CvMat_cols_get(CvMat * m){
158 int CvMat_rows_get(CvMat *m){
161 int CvMat_width_get(CvMat * m){
164 int CvMat_height_get(CvMat *m){
167 int CvMat_depth_get(CvMat * m){
168 return cvCvToIplDepth(m->type);
170 int CvMat_nChannels_get(CvMat * m){
171 return CV_MAT_CN(m->type);
173 int CvMat_origin_get(CvMat * m){
176 int CvMat_dataOrder_get(CvMat * m){
179 int CvMat_imageSize_get(CvMat * m){
180 int step = m->step ? m->step :
181 step = CV_ELEM_SIZE(m->type) * m->cols;
184 int CvMat_widthStep_get(CvMat * m){
198 // swig doesn't like the embedded union in CvMat, so re-add these