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>
50 %extend IplImage { ~IplImage () { IplImage * dummy = self; cvReleaseImage (& dummy); } }
51 %extend CvMat { ~CvMat () { CvMat * dummy = self; cvReleaseMat (& dummy); } }
52 %extend CvMatND { ~CvMatND () { CvMatND * dummy = self; cvReleaseMatND (& dummy); } }
53 %extend CvSparseMat { ~CvSparseMat () { CvSparseMat * dummy = self; cvReleaseSparseMat (& dummy); } }
54 %extend CvMemStorage { ~CvMemStorage () { CvMemStorage * dummy = self; cvReleaseMemStorage (& dummy); } }
55 %extend CvGraphScanner { ~CvGraphScanner () { CvGraphScanner * dummy = self; cvReleaseGraphScanner (& dummy); } }
56 %extend CvFileStorage { ~CvFileStorage () { CvFileStorage * dummy = self; cvReleaseFileStorage (& dummy); } }
57 %extend IplConvKernel { ~IplConvKernel () { IplConvKernel * dummy = self; cvReleaseStructuringElement (& dummy); } }
58 %extend CvKalman { ~CvKalman () { CvKalman * dummy = self; cvReleaseKalman (& dummy); } }
59 %extend CvConDensation { ~CvConDensation () { CvConDensation * dummy = self; cvReleaseConDensation (& dummy); } }
60 %extend CvHistogram { ~CvHistogram () { CvHistogram * dummy = self; cvReleaseHist (& dummy); } }
61 %extend CvHaarClassifierCascade { ~CvHaarClassifierCascade () { CvHaarClassifierCascade * dummy = self; cvReleaseHaarClassifierCascade (& dummy); } }
62 %extend CvPOSITObject { ~CvPOSITObject () { CvPOSITObject * dummy = self; cvReleasePOSITObject (& dummy); } }
63 %extend CvFeatureTree { ~CvFeatureTree () { CvFeatureTree * dummy = self; cvReleaseFeatureTree (& dummy); } }
64 %extend CvLSH { ~CvLSH () { CvLSH * dummy = self; cvReleaseLSH (& dummy); } }
66 // string operators for some OpenCV types
70 const char * __str__(){
72 snprintf(str, 256, "[%f, %f, %f, %f]", self->val[0], self->val[1], self->val[2], self->val[3]);
75 const char * __repr__(){
77 snprintf(str, 256, "cvScalar(%f, %f, %f, %f)", self->val[0], self->val[1], self->val[2], self->val[3]);
80 const double __getitem__ (int index) {
82 #ifdef defined(SWIGPYTHON)
83 PyErr_SetString (PyExc_IndexError, "indice must be lower than 4");
84 #elif defined(SWIGOCTAVE)
85 error("indice must be lower than 4");
90 #ifdef defined(SWIGPYTHON)
91 PyErr_SetString (PyExc_IndexError, "indice must be bigger or egal to -4");
92 #elif defined(SWIGOCTAVE)
93 error("indice must be bigger or egal to -4");
98 /* negative index means from the end in python */
101 return self->val [index];
103 void __setitem__ (int index, double value) {
105 #ifdef defined(SWIGPYTHON)
106 PyErr_SetString (PyExc_IndexError, "indice must be lower than 4");
107 #elif defined(SWIGOCTAVE)
108 error("indice must be lower than 4");
113 #ifdef defined(SWIGPYTHON)
114 PyErr_SetString (PyExc_IndexError, "indice must be bigger or egal to -4");
115 #elif defined(SWIGOCTAVE)
116 error("indice must be bigger or egal to -4");
121 /* negative index means from the end in python */
124 self->val [index] = value;
130 const char * __str__(){
132 snprintf(str, 64, "[%f %f]", self->x, self->y);
135 const char * __repr__(){
137 snprintf(str, 64, "cvPoint2D32f(%f,%f)", self->x, self->y);
144 const char * __str__(){
146 snprintf(str, 64, "[%d %d]", self->x, self->y);
149 const char * __repr__(){
151 snprintf(str, 64, "cvPoint(%d,%d)", self->x, self->y);
156 // Set up CvMat to emulate IplImage fields
158 int CvMat_cols_get(CvMat * m){
161 void CvMat_cols_set(CvMat * m, int cols){
164 int CvMat_rows_get(CvMat *m){
167 void CvMat_rows_set(CvMat *m, int rows){
170 int CvMat_width_get(CvMat * m){
173 void CvMat_width_set(CvMat * m, int width){
176 int CvMat_height_get(CvMat *m){
179 void CvMat_height_set(CvMat * m, int height){
182 int CvMat_depth_get(CvMat * m){
183 return cvIplDepth(m->type);
185 void CvMat_depth_set(CvMat *m, int depth){
186 cvError(CV_StsNotImplemented, "CvMat_depth_set", "Not Implemented", __FILE__, __LINE__);
188 int CvMat_nChannels_get(CvMat * m){
189 return CV_MAT_CN(m->type);
191 void CvMat_nChannels_set(CvMat *m, int nChannels){
192 int depth = CV_MAT_DEPTH(m->type);
193 m->type = CV_MAKETYPE(depth, nChannels);
195 int CvMat_origin_get(CvMat * m){
196 /* Always 0 - top-left origin */
199 void CvMat_origin_set(CvMat * m, int origin){
200 cvError(CV_StsNotImplemented, "CvMat_origin_get", "IplImage is replaced by CvMat in Python, so its fields are read-only", __FILE__, __LINE__);
202 int CvMat_dataOrder_get(CvMat * m){
203 cvError(CV_StsNotImplemented, "CvMat_dataOrder_get", "Not Implemented", __FILE__, __LINE__);
206 void CvMat_dataOrder_set(CvMat * m, int dataOrder){
207 cvError(CV_StsNotImplemented, "CvMat_dataOrder_get", "IplImage is replaced by CvMat in Python, so its fields are read-only", __FILE__, __LINE__);
209 int CvMat_imageSize_get(CvMat * m){
210 int step = m->step ? m->step : CV_ELEM_SIZE(m->type) * m->cols;
213 void CvMat_imageSize_set(CvMat * m, int imageSize){
214 cvError(CV_StsNotImplemented, "CvMat_imageSize_set", "IplImage is not implemented in Python, so origin is read-only", __FILE__, __LINE__);
216 int CvMat_widthStep_get(CvMat * m){
219 void CvMat_widthStep_set(CvMat *m, int widthStep){
234 // swig doesn't like the embedded union in CvMat, so re-add these