removed obsolete swig-based python & octave wrappers
This commit is contained in:
parent
1c347f4801
commit
8be541eed2
@ -1,14 +0,0 @@
|
|||||||
if(SWIG_FOUND)
|
|
||||||
add_subdirectory(swig)
|
|
||||||
endif()
|
|
||||||
if(MSVC OR MINGW)
|
|
||||||
if(NOT CMAKE_CL_64)
|
|
||||||
add_subdirectory(ffopencv)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
if(PYTHONLIBS_FOUND AND BUILD_NEW_PYTHON_SUPPORT)
|
|
||||||
add_subdirectory(python)
|
|
||||||
endif()
|
|
||||||
#if(IPP_FOUND AND BUILD_CUSTOM_IPP_LIB)
|
|
||||||
# add_subdirectory(ippopencv)
|
|
||||||
#endif()
|
|
@ -1,6 +0,0 @@
|
|||||||
if(PYTHONLIBS_FOUND AND BUILD_SWIG_PYTHON_SUPPORT)
|
|
||||||
add_subdirectory(python)
|
|
||||||
endif()
|
|
||||||
if(OCTAVE_FOUND AND BUILD_OCTAVE_SUPPORT)
|
|
||||||
add_subdirectory(octave)
|
|
||||||
endif()
|
|
@ -1,13 +0,0 @@
|
|||||||
The OpenCV Python wrapper is automatically generated using a tool called SWIG (www.swig.org)
|
|
||||||
using filtered header files from OpenCV and the swig interface definition files (*.i).
|
|
||||||
|
|
||||||
If you are interested in simply using the Python interface, SWIG is not required and the generated
|
|
||||||
wrapper files can be used as is.
|
|
||||||
|
|
||||||
If you want to modify the python wrapper, or write bindings for another language supported by SWIG
|
|
||||||
(say Ruby or C#), you will need SWIG 1.2.24 or greater. The filtered headers are found in the
|
|
||||||
'filtered' subdirectory and are automatically regenerated at build-time if the originals have changed.
|
|
||||||
The 'general' subdirectory contains SWIG interface definition files that are not specific to Python, and
|
|
||||||
can hopefully utilized for other language wrappers. The files in the 'python' subdirectory are Python specific.
|
|
||||||
When adding new functionality, please try to use the SWIG abstractions rather than the Python API whenever
|
|
||||||
possible.
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,120 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
|
|
||||||
// 2004-03-16, Gabriel Schreiber <schreiber@ient.rwth-aachen.de>
|
|
||||||
// Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
// Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
|
|
||||||
|
|
||||||
%module(package="opencv") cv
|
|
||||||
|
|
||||||
|
|
||||||
%{
|
|
||||||
#include "cxtypes.h"
|
|
||||||
#include "cxcore.h"
|
|
||||||
#include "cvtypes.h"
|
|
||||||
#include "cv.h"
|
|
||||||
%}
|
|
||||||
|
|
||||||
// The preprocessor "gcc -E" may generate compiler specific storage specifiers that confuse SWIG
|
|
||||||
// We just define them away
|
|
||||||
#define __attribute__(arg)
|
|
||||||
#define __inline inline
|
|
||||||
#define __const const
|
|
||||||
|
|
||||||
// SWIG needs this to be parsed before cv.h
|
|
||||||
%ignore CV_SET_IMAGE_IO_FUNCTIONS;
|
|
||||||
%include "./cvmacros.i"
|
|
||||||
|
|
||||||
// A couple of typemaps helps wrapping OpenCV functions in a sensible way
|
|
||||||
%include "./memory.i"
|
|
||||||
%include "./typemaps.i"
|
|
||||||
%include "./doublepointers.i"
|
|
||||||
|
|
||||||
// hide COI and ROI functions
|
|
||||||
%ignore cvSetImageCOI;
|
|
||||||
%ignore cvSetImageROI;
|
|
||||||
%ignore cvGetImageROI;
|
|
||||||
%ignore cvGetImageCOI;
|
|
||||||
|
|
||||||
// mask some functions that return IplImage *
|
|
||||||
%ignore cvInitImageHeader;
|
|
||||||
%ignore cvGetImage;
|
|
||||||
%ignore cvCreateImageHeader;
|
|
||||||
|
|
||||||
// adapt others to return CvMat * instead
|
|
||||||
%ignore cvCreateImage;
|
|
||||||
%rename (cvCreateImage) cvCreateImageMat;
|
|
||||||
%ignore cvCloneImage;
|
|
||||||
%rename (cvCloneImage) cvCloneImageMat;
|
|
||||||
%inline %{
|
|
||||||
CvMat * cvCreateImageMat( CvSize size, int depth, int channels ){
|
|
||||||
static const signed char icvDepthToType[]=
|
|
||||||
{
|
|
||||||
-1, -1, CV_8U, CV_8S, CV_16U, CV_16S, -1, -1,
|
|
||||||
CV_32F, CV_32S, -1, -1, -1, -1, -1, -1, CV_64F, -1
|
|
||||||
};
|
|
||||||
|
|
||||||
depth = icvDepthToType[((depth & 255) >> 2) + (depth < 0)];
|
|
||||||
return cvCreateMat( size.height, size.width, CV_MAKE_TYPE(depth, channels));
|
|
||||||
}
|
|
||||||
#define cvCloneImageMat( mat ) cvCloneMat( mat )
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
|
|
||||||
CvModuleInfo *CvModule::first=0;
|
|
||||||
CvModuleInfo *CvModule::last=0;
|
|
||||||
CvTypeInfo *CvType::first=0;
|
|
||||||
CvTypeInfo *CvType::last=0;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
%}
|
|
||||||
CvMat * cvCloneImageMat( CvMat * mat );
|
|
||||||
|
|
||||||
|
|
||||||
// Now include the filtered OpenCV constants and prototypes (includes cxcore as well)
|
|
||||||
%include "../filtered/constants.h"
|
|
||||||
%include "../filtered/cv.h"
|
|
||||||
|
|
||||||
%include "./extensions.i"
|
|
||||||
%include "./cvarr_operators.i"
|
|
@ -1,419 +0,0 @@
|
|||||||
/** This file was automatically generated using util/cvarr_operators.py script */
|
|
||||||
%extend CvMat {
|
|
||||||
%newobject operator &;
|
|
||||||
CvMat * operator & (CvArr * src){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, self->type);
|
|
||||||
cvAnd(self, src, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator &= (CvArr * src){
|
|
||||||
cvAnd(self, src, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator +;
|
|
||||||
CvMat * operator + (CvArr * src){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, self->type);
|
|
||||||
cvAdd(self, src, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator += (CvArr * src){
|
|
||||||
cvAdd(self, src, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator *;
|
|
||||||
CvMat * operator * (CvArr * src){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, self->type);
|
|
||||||
cvMul(self, src, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator *= (CvArr * src){
|
|
||||||
cvMul(self, src, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator -;
|
|
||||||
CvMat * operator - (CvArr * src){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, self->type);
|
|
||||||
cvSub(self, src, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator -= (CvArr * src){
|
|
||||||
cvSub(self, src, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator /;
|
|
||||||
CvMat * operator / (CvArr * src){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, self->type);
|
|
||||||
cvDiv(self, src, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator /= (CvArr * src){
|
|
||||||
cvDiv(self, src, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator |;
|
|
||||||
CvMat * operator | (CvArr * src){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, self->type);
|
|
||||||
cvOr(self, src, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator |= (CvArr * src){
|
|
||||||
cvOr(self, src, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator ^;
|
|
||||||
CvMat * operator ^ (CvArr * src){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, self->type);
|
|
||||||
cvXor(self, src, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator ^= (CvArr * src){
|
|
||||||
cvXor(self, src, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator +;
|
|
||||||
CvMat * operator + (CvScalar val){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, self->type);
|
|
||||||
cvAddS(self, val, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator += (CvScalar val){
|
|
||||||
cvAddS(self, val, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator ^;
|
|
||||||
CvMat * operator ^ (CvScalar val){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, self->type);
|
|
||||||
cvXorS(self, val, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator ^= (CvScalar val){
|
|
||||||
cvXorS(self, val, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator -;
|
|
||||||
CvMat * operator - (CvScalar val){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, self->type);
|
|
||||||
cvSubS(self, val, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator -= (CvScalar val){
|
|
||||||
cvSubS(self, val, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator |;
|
|
||||||
CvMat * operator | (CvScalar val){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, self->type);
|
|
||||||
cvOrS(self, val, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator |= (CvScalar val){
|
|
||||||
cvOrS(self, val, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator &;
|
|
||||||
CvMat * operator & (CvScalar val){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, self->type);
|
|
||||||
cvAndS(self, val, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator &= (CvScalar val){
|
|
||||||
cvAndS(self, val, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator >=;
|
|
||||||
CvMat * operator >= (CvArr * src){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, CV_8U);
|
|
||||||
cvCmp(self, src, res, CV_CMP_GE);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator >= (double val){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, CV_8U);
|
|
||||||
cvCmpS(self, val, res, CV_CMP_GE);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
%newobject operator ==;
|
|
||||||
CvMat * operator == (CvArr * src){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, CV_8U);
|
|
||||||
cvCmp(self, src, res, CV_CMP_EQ);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator == (double val){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, CV_8U);
|
|
||||||
cvCmpS(self, val, res, CV_CMP_EQ);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
%newobject operator <=;
|
|
||||||
CvMat * operator <= (CvArr * src){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, CV_8U);
|
|
||||||
cvCmp(self, src, res, CV_CMP_LE);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator <= (double val){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, CV_8U);
|
|
||||||
cvCmpS(self, val, res, CV_CMP_LE);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
%newobject operator !=;
|
|
||||||
CvMat * operator != (CvArr * src){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, CV_8U);
|
|
||||||
cvCmp(self, src, res, CV_CMP_NE);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator != (double val){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, CV_8U);
|
|
||||||
cvCmpS(self, val, res, CV_CMP_NE);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
%newobject operator <;
|
|
||||||
CvMat * operator < (CvArr * src){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, CV_8U);
|
|
||||||
cvCmp(self, src, res, CV_CMP_LT);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator < (double val){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, CV_8U);
|
|
||||||
cvCmpS(self, val, res, CV_CMP_LT);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
%newobject operator >;
|
|
||||||
CvMat * operator > (CvArr * src){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, CV_8U);
|
|
||||||
cvCmp(self, src, res, CV_CMP_GT);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator > (double val){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, CV_8U);
|
|
||||||
cvCmpS(self, val, res, CV_CMP_GT);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
%newobject operator *;
|
|
||||||
CvMat * operator * (double val){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, self->type);
|
|
||||||
cvScale(self, res, val);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator *= (double val){
|
|
||||||
cvScale(self, self, val);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator /;
|
|
||||||
CvMat * operator / (double val){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, self->type);
|
|
||||||
cvScale(self, res, 1.0/val);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
CvMat * operator /= (double val){
|
|
||||||
cvScale(self, self, 1.0/val);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
} /* extend CvMat */
|
|
||||||
|
|
||||||
%extend IplImage {
|
|
||||||
%newobject operator &;
|
|
||||||
IplImage * operator & (CvArr * src){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), self->depth, self->nChannels);
|
|
||||||
cvAnd(self, src, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator &= (CvArr * src){
|
|
||||||
cvAnd(self, src, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator +;
|
|
||||||
IplImage * operator + (CvArr * src){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), self->depth, self->nChannels);
|
|
||||||
cvAdd(self, src, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator += (CvArr * src){
|
|
||||||
cvAdd(self, src, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator *;
|
|
||||||
IplImage * operator * (CvArr * src){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), self->depth, self->nChannels);
|
|
||||||
cvMul(self, src, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator *= (CvArr * src){
|
|
||||||
cvMul(self, src, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator -;
|
|
||||||
IplImage * operator - (CvArr * src){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), self->depth, self->nChannels);
|
|
||||||
cvSub(self, src, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator -= (CvArr * src){
|
|
||||||
cvSub(self, src, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator /;
|
|
||||||
IplImage * operator / (CvArr * src){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), self->depth, self->nChannels);
|
|
||||||
cvDiv(self, src, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator /= (CvArr * src){
|
|
||||||
cvDiv(self, src, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator |;
|
|
||||||
IplImage * operator | (CvArr * src){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), self->depth, self->nChannels);
|
|
||||||
cvOr(self, src, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator |= (CvArr * src){
|
|
||||||
cvOr(self, src, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator ^;
|
|
||||||
IplImage * operator ^ (CvArr * src){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), self->depth, self->nChannels);
|
|
||||||
cvXor(self, src, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator ^= (CvArr * src){
|
|
||||||
cvXor(self, src, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator +;
|
|
||||||
IplImage * operator + (CvScalar val){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), self->depth, self->nChannels);
|
|
||||||
cvAddS(self, val, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator += (CvScalar val){
|
|
||||||
cvAddS(self, val, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator ^;
|
|
||||||
IplImage * operator ^ (CvScalar val){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), self->depth, self->nChannels);
|
|
||||||
cvXorS(self, val, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator ^= (CvScalar val){
|
|
||||||
cvXorS(self, val, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator -;
|
|
||||||
IplImage * operator - (CvScalar val){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), self->depth, self->nChannels);
|
|
||||||
cvSubS(self, val, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator -= (CvScalar val){
|
|
||||||
cvSubS(self, val, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator |;
|
|
||||||
IplImage * operator | (CvScalar val){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), self->depth, self->nChannels);
|
|
||||||
cvOrS(self, val, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator |= (CvScalar val){
|
|
||||||
cvOrS(self, val, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator &;
|
|
||||||
IplImage * operator & (CvScalar val){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), self->depth, self->nChannels);
|
|
||||||
cvAndS(self, val, res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator &= (CvScalar val){
|
|
||||||
cvAndS(self, val, self);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator >=;
|
|
||||||
IplImage * operator >= (CvArr * src){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), IPL_DEPTH_8U, 1);
|
|
||||||
cvCmp(self, src, res, CV_CMP_GE);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator >= (double val){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), IPL_DEPTH_8U, 1);
|
|
||||||
cvCmpS(self, val, res, CV_CMP_GE);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
%newobject operator ==;
|
|
||||||
IplImage * operator == (CvArr * src){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), IPL_DEPTH_8U, 1);
|
|
||||||
cvCmp(self, src, res, CV_CMP_EQ);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator == (double val){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), IPL_DEPTH_8U, 1);
|
|
||||||
cvCmpS(self, val, res, CV_CMP_EQ);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
%newobject operator <=;
|
|
||||||
IplImage * operator <= (CvArr * src){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), IPL_DEPTH_8U, 1);
|
|
||||||
cvCmp(self, src, res, CV_CMP_LE);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator <= (double val){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), IPL_DEPTH_8U, 1);
|
|
||||||
cvCmpS(self, val, res, CV_CMP_LE);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
%newobject operator !=;
|
|
||||||
IplImage * operator != (CvArr * src){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), IPL_DEPTH_8U, 1);
|
|
||||||
cvCmp(self, src, res, CV_CMP_NE);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator != (double val){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), IPL_DEPTH_8U, 1);
|
|
||||||
cvCmpS(self, val, res, CV_CMP_NE);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
%newobject operator <;
|
|
||||||
IplImage * operator < (CvArr * src){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), IPL_DEPTH_8U, 1);
|
|
||||||
cvCmp(self, src, res, CV_CMP_LT);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator < (double val){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), IPL_DEPTH_8U, 1);
|
|
||||||
cvCmpS(self, val, res, CV_CMP_LT);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
%newobject operator >;
|
|
||||||
IplImage * operator > (CvArr * src){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), IPL_DEPTH_8U, 1);
|
|
||||||
cvCmp(self, src, res, CV_CMP_GT);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator > (double val){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), IPL_DEPTH_8U, 1);
|
|
||||||
cvCmpS(self, val, res, CV_CMP_GT);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
%newobject operator *;
|
|
||||||
IplImage * operator * (double val){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), self->depth, self->nChannels);
|
|
||||||
cvScale(self, res, val);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator *= (double val){
|
|
||||||
cvScale(self, self, val);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
%newobject operator /;
|
|
||||||
IplImage * operator / (double val){
|
|
||||||
IplImage * res = cvCreateImage(cvGetSize(self), self->depth, self->nChannels);
|
|
||||||
cvScale(self, res, 1.0/val);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
IplImage * operator /= (double val){
|
|
||||||
cvScale(self, self, 1.0/val);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
} /* extend IplImage */
|
|
||||||
|
|
@ -1,127 +0,0 @@
|
|||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// This file is automatically generated from the extract_macros.py script found in the 'utils'
|
|
||||||
// subdirectory of the OpenCV distribution. If the generated function prototypes are missing or
|
|
||||||
// incorrect, it is likely that a name->type mapping will have to be added to the script
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////M*/
|
|
||||||
|
|
||||||
// This file was generated from the following header files:
|
|
||||||
// ../../../include/opencv/cxtypes.h
|
|
||||||
// ../../../include/opencv/cxcore.h
|
|
||||||
// ../../../include/opencv/cvtypes.h
|
|
||||||
// ../../../include/opencv/cv.h
|
|
||||||
void cvFree(void ** ptr);
|
|
||||||
void CV_READ_CHAIN_POINT(CvPoint _pt, CvChainPtReader reader);
|
|
||||||
void * CV_MAT_ELEM_PTR(CvMat mat,int row,int col);
|
|
||||||
void * CV_MAT_ELEM_PTR_FAST(CvMat mat,int row,int col,int pix_size);
|
|
||||||
void * CV_NODE_VAL(CvSparseMat* mat,CvSparseNode * node);
|
|
||||||
|
|
||||||
int * CV_NODE_IDX(CvSparseMat* mat,CvSparseNode * node);
|
|
||||||
CvQuadEdge2D* CV_SUBDIV2D_NEXT_EDGE(CvSubdiv2DEdge edge);
|
|
||||||
void CV_SWAP(int a,int b,int t);
|
|
||||||
int CV_IMIN(int a,int b);
|
|
||||||
int CV_IMAX(int a,int b);
|
|
||||||
int CV_IABS(int a);
|
|
||||||
void CV_CMP(int a,int b);
|
|
||||||
void CV_SIGN(int a);
|
|
||||||
void cvInvSqrt(double value);
|
|
||||||
void cvSqrt(double value);
|
|
||||||
int CV_IS_IMAGE_HDR(CvArr * img);
|
|
||||||
int CV_IS_IMAGE(CvArr * img);
|
|
||||||
int CV_MAT_DEPTH(int flags);
|
|
||||||
int CV_MAKETYPE(int depth,int cn);
|
|
||||||
int CV_8UC(int n);
|
|
||||||
int CV_8SC(int n);
|
|
||||||
int CV_16UC(int n);
|
|
||||||
int CV_16SC(int n);
|
|
||||||
int CV_32SC(int n);
|
|
||||||
int CV_32FC(int n);
|
|
||||||
int CV_64FC(int n);
|
|
||||||
int CV_MAT_CN(int flags);
|
|
||||||
int CV_MAT_TYPE(int flags);
|
|
||||||
int CV_IS_MAT_CONT(int flags);
|
|
||||||
int CV_IS_TEMP_MAT(int flags);
|
|
||||||
int CV_IS_MAT_HDR(CvMat* mat);
|
|
||||||
int CV_IS_MAT(CvMat* mat);
|
|
||||||
int CV_IS_MASK_ARR(CvMat* mat);
|
|
||||||
int CV_ARE_TYPES_EQ(CvMat* mat1,CvMat* mat2);
|
|
||||||
int CV_ARE_CNS_EQ(CvMat* mat1,CvMat* mat2);
|
|
||||||
int CV_ARE_DEPTHS_EQ(CvMat* mat1,CvMat* mat2);
|
|
||||||
int CV_ARE_SIZES_EQ(CvMat* mat1,CvMat* mat2);
|
|
||||||
int CV_IS_MAT_CONST(CvMat* mat);
|
|
||||||
int CV_ELEM_SIZE1(int type);
|
|
||||||
int CV_ELEM_SIZE(int type);
|
|
||||||
int CV_IS_MATND_HDR(CvMat* mat);
|
|
||||||
int CV_IS_MATND(CvMat* mat);
|
|
||||||
int CV_IS_SPARSE_MAT_HDR(CvMat* mat);
|
|
||||||
int CV_IS_SPARSE_MAT(CvMat* mat);
|
|
||||||
int CV_IS_HIST(CvHistogram * hist);
|
|
||||||
int CV_IS_UNIFORM_HIST(CvHistogram * hist);
|
|
||||||
int CV_IS_SPARSE_HIST(CvHistogram * hist);
|
|
||||||
int CV_HIST_HAS_RANGES(CvHistogram * hist);
|
|
||||||
int CV_IS_STORAGE(CvMemStorage * storage);
|
|
||||||
int CV_IS_SET_ELEM(void * ptr);
|
|
||||||
int CV_IS_SEQ(CvSeq* seq);
|
|
||||||
int CV_IS_SET(CvSet * set);
|
|
||||||
int CV_SEQ_ELTYPE(CvSeq* seq);
|
|
||||||
int CV_SEQ_KIND(CvSeq* seq);
|
|
||||||
int CV_IS_SEQ_INDEX(CvSeq* seq);
|
|
||||||
int CV_IS_SEQ_CURVE(CvSeq* seq);
|
|
||||||
int CV_IS_SEQ_CLOSED(CvSeq* seq);
|
|
||||||
int CV_IS_SEQ_CONVEX(CvSeq* seq);
|
|
||||||
int CV_IS_SEQ_HOLE(CvSeq* seq);
|
|
||||||
int CV_IS_SEQ_SIMPLE(CvSeq* seq);
|
|
||||||
int CV_IS_SEQ_POINT_SET(CvSeq* seq);
|
|
||||||
int CV_IS_SEQ_POINT_SUBSET(CvSeq* seq);
|
|
||||||
int CV_IS_SEQ_POLYLINE(CvSeq* seq);
|
|
||||||
int CV_IS_SEQ_POLYGON(CvSeq* seq);
|
|
||||||
int CV_IS_SEQ_CHAIN(CvSeq* seq);
|
|
||||||
int CV_IS_SEQ_CONTOUR(CvSeq* seq);
|
|
||||||
int CV_IS_SEQ_CHAIN_CONTOUR(CvSeq* seq);
|
|
||||||
int CV_IS_SEQ_POLYGON_TREE(CvSeq* seq);
|
|
||||||
int CV_IS_GRAPH(CvSeq* seq);
|
|
||||||
int CV_IS_GRAPH_ORIENTED(CvSeq* seq);
|
|
||||||
int CV_IS_SUBDIV2D(CvSeq* seq);
|
|
||||||
void CV_WRITE_SEQ_ELEM_VAR(void * elem_ptr,CvSeqWriter writer);
|
|
||||||
void CV_WRITE_SEQ_ELEM(CvPoint elem,CvSeqWriter writer);
|
|
||||||
void CV_NEXT_SEQ_ELEM(int elem_size,CvSeqReader reader);
|
|
||||||
void CV_PREV_SEQ_ELEM(int elem_size,CvSeqReader reader);
|
|
||||||
void CV_READ_SEQ_ELEM(CvPoint elem,CvSeqReader reader);
|
|
||||||
void CV_REV_READ_SEQ_ELEM(CvPoint elem,CvSeqReader reader);
|
|
||||||
CvPoint CV_CURRENT_POINT(CvSeqReader reader);
|
|
||||||
CvPoint CV_PREV_POINT(CvSeqReader reader);
|
|
||||||
void CV_READ_EDGE(CvPoint pt1,CvPoint pt2,CvSeqReader reader);
|
|
||||||
CvGraphEdge * CV_NEXT_GRAPH_EDGE(CvGraphEdge * edge,CvGraphVtx * vertex);
|
|
||||||
int CV_NODE_TYPE(int flags);
|
|
||||||
int CV_NODE_IS_INT(int flags);
|
|
||||||
int CV_NODE_IS_REAL(int flags);
|
|
||||||
int CV_NODE_IS_STRING(int flags);
|
|
||||||
int CV_NODE_IS_SEQ(int flags);
|
|
||||||
int CV_NODE_IS_MAP(int flags);
|
|
||||||
int CV_NODE_IS_COLLECTION(int flags);
|
|
||||||
int CV_NODE_IS_FLOW(int flags);
|
|
||||||
int CV_NODE_IS_EMPTY(int flags);
|
|
||||||
int CV_NODE_IS_USER(int flags);
|
|
||||||
int CV_NODE_HAS_NAME(int flags);
|
|
||||||
int CV_NODE_SEQ_IS_SIMPLE(CvSeq* seq);
|
|
||||||
void cvReshapeND(CvArr * arr,CvMat * header,int new_cn,int new_dims,int * new_sizes);
|
|
||||||
void cvConvert(CvArr * src,CvArr * dst);
|
|
||||||
void cvAXPY(CvArr * A,double real_scalar,CvArr * B,CvArr * C);
|
|
||||||
void cvAbs(CvArr * src,CvArr * dst);
|
|
||||||
void cvMatMulAdd(CvArr * src1,CvArr * src2,CvArr * src3,CvArr * dst);
|
|
||||||
void cvMatMul(CvArr * src1,CvArr * src2,CvArr * dst);
|
|
||||||
void cvGetGraphVtx(CvGraph * graph,int idx);
|
|
||||||
int cvGraphVtxIdx(CvGraph * graph,CvGraphVtx * vtx);
|
|
||||||
int cvGraphEdgeIdx(CvGraph * graph,CvGraphEdge * edge);
|
|
||||||
int cvGraphGetVtxCount(CvGraph * graph);
|
|
||||||
int cvGraphGetEdgeCount(CvGraph * graph);
|
|
||||||
int CV_IS_GRAPH_VERTEX_VISITED(CvGraphVtx * vtx);
|
|
||||||
int CV_IS_GRAPH_EDGE_VISITED(CvGraphEdge * edge);
|
|
||||||
CvScalar CV_RGB(double r,double g,int b);
|
|
||||||
void CV_NEXT_LINE_POINT(CvLineIterator line_iterator);
|
|
||||||
void CV_SET_IMAGE_IO_FUNCTIONS();
|
|
||||||
void CV_INIT_3X3_DELTAS(double * deltas,int step,int nch);
|
|
||||||
int CV_IS_HAAR_CLASSIFIER(void * haar);
|
|
||||||
double cvContourPerimeter(CvSeq * contour);
|
|
||||||
void cvCalcBackProject(IplImage * image,CvArr * dst,CvHistogram * hist);
|
|
||||||
void cvCalcBackProjectPatch(IplImage * image,CvArr * dst,CvSize range,CvHistogram * hist,int method,double factor);
|
|
@ -1,168 +0,0 @@
|
|||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// This file was automatically generated from the extract_doublepointers.py script found in the
|
|
||||||
// 'utils' subdirectory of the OpenCV distribution. Run it on the .cpp file generated by swig to
|
|
||||||
// generate the double pointer typemaps
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////M*/
|
|
||||||
|
|
||||||
%typemap(in) CvGraphEdge ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) CvGraphVtx ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) CvHistogram ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) CvMatND ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) CvPoint ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) CvSeq ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) CvSeqBlock ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) CvSetElem ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) CvSubdiv2DPoint ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) CvTypedSeqTCvConnectedComp_t ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) CvTypedSeqTCvPoint2D32f_t ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) CvTypedSeqTCvPoint_t ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) CvTypedSeqTCvQuadEdge2D_t ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) CvTypedSeqTCvRect_t ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) CvTypedSeqTCvSeq_p_t ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) CvTypedSeqTCvTupleTCvPoint_2_t_t ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) CvTypedSeqTCvTupleTfloat_2_t_t ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) _CvContourScanner ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) _IplImage ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) char ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) float ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) unsigned_char ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
||||||
%typemap(in) void ** (void * vptr, $*1_ltype buffer) {
|
|
||||||
if ((SWIG_ConvertPtr($input, &vptr, $*1_descriptor, 1)) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
buffer = ($*1_ltype) vptr;
|
|
||||||
$1=&buffer;
|
|
||||||
}
|
|
@ -1,236 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
|
|
||||||
// 2004-03-23, Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
// Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
// 2008-05-15, Xavier Delacour <xavier.delacour@gmail.com>
|
|
||||||
|
|
||||||
|
|
||||||
struct CvLSH {};
|
|
||||||
|
|
||||||
%extend IplImage { ~IplImage () { IplImage * dummy = self; cvReleaseImage (& dummy); } }
|
|
||||||
%extend CvMat { ~CvMat () { CvMat * dummy = self; cvReleaseMat (& dummy); } }
|
|
||||||
%extend CvMatND { ~CvMatND () { CvMatND * dummy = self; cvReleaseMatND (& dummy); } }
|
|
||||||
%extend CvSparseMat { ~CvSparseMat () { CvSparseMat * dummy = self; cvReleaseSparseMat (& dummy); } }
|
|
||||||
%extend CvMemStorage { ~CvMemStorage () { CvMemStorage * dummy = self; cvReleaseMemStorage (& dummy); } }
|
|
||||||
%extend CvGraphScanner { ~CvGraphScanner () { CvGraphScanner * dummy = self; cvReleaseGraphScanner (& dummy); } }
|
|
||||||
%extend CvFileStorage { ~CvFileStorage () { CvFileStorage * dummy = self; cvReleaseFileStorage (& dummy); } }
|
|
||||||
%extend IplConvKernel { ~IplConvKernel () { IplConvKernel * dummy = self; cvReleaseStructuringElement (& dummy); } }
|
|
||||||
%extend CvKalman { ~CvKalman () { CvKalman * dummy = self; cvReleaseKalman (& dummy); } }
|
|
||||||
%extend CvHistogram { ~CvHistogram () { CvHistogram * dummy = self; cvReleaseHist (& dummy); } }
|
|
||||||
%extend CvHaarClassifierCascade { ~CvHaarClassifierCascade () { CvHaarClassifierCascade * dummy = self; cvReleaseHaarClassifierCascade (& dummy); } }
|
|
||||||
%extend CvPOSITObject { ~CvPOSITObject () { CvPOSITObject * dummy = self; cvReleasePOSITObject (& dummy); } }
|
|
||||||
%extend CvFeatureTree { ~CvFeatureTree () { CvFeatureTree * dummy = self; cvReleaseFeatureTree (& dummy); } }
|
|
||||||
%extend CvLSH { ~CvLSH () { CvLSH * dummy = self; cvReleaseLSH (& dummy); } }
|
|
||||||
|
|
||||||
// string operators for some OpenCV types
|
|
||||||
|
|
||||||
%extend CvScalar
|
|
||||||
{
|
|
||||||
const char * __str__(){
|
|
||||||
static char str[256];
|
|
||||||
snprintf(str, 256, "[%f, %f, %f, %f]", self->val[0], self->val[1], self->val[2], self->val[3]);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
const char * __repr__(){
|
|
||||||
static char str[256];
|
|
||||||
snprintf(str, 256, "cvScalar(%f, %f, %f, %f)", self->val[0], self->val[1], self->val[2], self->val[3]);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
const double __getitem__ (int index) {
|
|
||||||
if (index >= 4) {
|
|
||||||
#ifdef defined(SWIGPYTHON)
|
|
||||||
PyErr_SetString (PyExc_IndexError, "indice must be lower than 4");
|
|
||||||
#elif defined(SWIGOCTAVE)
|
|
||||||
error("indice must be lower than 4");
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (index < -4) {
|
|
||||||
#ifdef defined(SWIGPYTHON)
|
|
||||||
PyErr_SetString (PyExc_IndexError, "indice must be bigger or egal to -4");
|
|
||||||
#elif defined(SWIGOCTAVE)
|
|
||||||
error("indice must be bigger or egal to -4");
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (index < 0) {
|
|
||||||
/* negative index means from the end in python */
|
|
||||||
index = 4 - index;
|
|
||||||
}
|
|
||||||
return self->val [index];
|
|
||||||
}
|
|
||||||
void __setitem__ (int index, double value) {
|
|
||||||
if (index >= 4) {
|
|
||||||
#ifdef defined(SWIGPYTHON)
|
|
||||||
PyErr_SetString (PyExc_IndexError, "indice must be lower than 4");
|
|
||||||
#elif defined(SWIGOCTAVE)
|
|
||||||
error("indice must be lower than 4");
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (index < -4) {
|
|
||||||
#ifdef defined(SWIGPYTHON)
|
|
||||||
PyErr_SetString (PyExc_IndexError, "indice must be bigger or egal to -4");
|
|
||||||
#elif defined(SWIGOCTAVE)
|
|
||||||
error("indice must be bigger or egal to -4");
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (index < 0) {
|
|
||||||
/* negative index means from the end in python */
|
|
||||||
index = 4 - index;
|
|
||||||
}
|
|
||||||
self->val [index] = value;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
%extend CvPoint2D32f
|
|
||||||
{
|
|
||||||
const char * __str__(){
|
|
||||||
static char str[64];
|
|
||||||
snprintf(str, 64, "[%f %f]", self->x, self->y);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
const char * __repr__(){
|
|
||||||
static char str[64];
|
|
||||||
snprintf(str, 64, "cvPoint2D32f(%f,%f)", self->x, self->y);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
%extend CvPoint
|
|
||||||
{
|
|
||||||
const char * __str__(){
|
|
||||||
static char str[64];
|
|
||||||
snprintf(str, 64, "[%d %d]", self->x, self->y);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
const char * __repr__(){
|
|
||||||
static char str[64];
|
|
||||||
snprintf(str, 64, "cvPoint(%d,%d)", self->x, self->y);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Set up CvMat to emulate IplImage fields
|
|
||||||
%{
|
|
||||||
int CvMat_cols_get(CvMat * m){
|
|
||||||
return m->cols;
|
|
||||||
}
|
|
||||||
void CvMat_cols_set(CvMat * m, int cols){
|
|
||||||
m->cols = cols;
|
|
||||||
}
|
|
||||||
int CvMat_rows_get(CvMat *m){
|
|
||||||
return m->rows;
|
|
||||||
}
|
|
||||||
void CvMat_rows_set(CvMat *m, int rows){
|
|
||||||
m->rows = rows;
|
|
||||||
}
|
|
||||||
int CvMat_width_get(CvMat * m){
|
|
||||||
return m->cols;
|
|
||||||
}
|
|
||||||
void CvMat_width_set(CvMat * m, int width){
|
|
||||||
m->cols = width;
|
|
||||||
}
|
|
||||||
int CvMat_height_get(CvMat *m){
|
|
||||||
return m->rows;
|
|
||||||
}
|
|
||||||
void CvMat_height_set(CvMat * m, int height){
|
|
||||||
m->rows = height;
|
|
||||||
}
|
|
||||||
int CvMat_depth_get(CvMat * m){
|
|
||||||
return cvIplDepth(m->type);
|
|
||||||
}
|
|
||||||
void CvMat_depth_set(CvMat *m, int depth){
|
|
||||||
cvError(CV_StsNotImplemented, "CvMat_depth_set", "Not Implemented", __FILE__, __LINE__);
|
|
||||||
}
|
|
||||||
int CvMat_nChannels_get(CvMat * m){
|
|
||||||
return CV_MAT_CN(m->type);
|
|
||||||
}
|
|
||||||
void CvMat_nChannels_set(CvMat *m, int nChannels){
|
|
||||||
int depth = CV_MAT_DEPTH(m->type);
|
|
||||||
m->type = CV_MAKETYPE(depth, nChannels);
|
|
||||||
}
|
|
||||||
int CvMat_origin_get(CvMat * m){
|
|
||||||
/* Always 0 - top-left origin */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
void CvMat_origin_set(CvMat * m, int origin){
|
|
||||||
cvError(CV_StsNotImplemented, "CvMat_origin_get", "IplImage is replaced by CvMat in Python, so its fields are read-only", __FILE__, __LINE__);
|
|
||||||
}
|
|
||||||
int CvMat_dataOrder_get(CvMat * m){
|
|
||||||
cvError(CV_StsNotImplemented, "CvMat_dataOrder_get", "Not Implemented", __FILE__, __LINE__);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
void CvMat_dataOrder_set(CvMat * m, int dataOrder){
|
|
||||||
cvError(CV_StsNotImplemented, "CvMat_dataOrder_get", "IplImage is replaced by CvMat in Python, so its fields are read-only", __FILE__, __LINE__);
|
|
||||||
}
|
|
||||||
int CvMat_imageSize_get(CvMat * m){
|
|
||||||
int step = m->step ? m->step : CV_ELEM_SIZE(m->type) * m->cols;
|
|
||||||
return step*m->rows;
|
|
||||||
}
|
|
||||||
void CvMat_imageSize_set(CvMat * m, int imageSize){
|
|
||||||
cvError(CV_StsNotImplemented, "CvMat_imageSize_set", "IplImage is not implemented in Python, so origin is read-only", __FILE__, __LINE__);
|
|
||||||
}
|
|
||||||
int CvMat_widthStep_get(CvMat * m){
|
|
||||||
return m->step;
|
|
||||||
}
|
|
||||||
void CvMat_widthStep_set(CvMat *m, int widthStep){
|
|
||||||
m->step = widthStep;
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
|
|
||||||
%extend CvMat
|
|
||||||
{
|
|
||||||
int depth;
|
|
||||||
int nChannels;
|
|
||||||
int dataOrder;
|
|
||||||
int origin;
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
int imageSize;
|
|
||||||
int widthStep;
|
|
||||||
// swig doesn't like the embedded union in CvMat, so re-add these
|
|
||||||
int rows;
|
|
||||||
int cols;
|
|
||||||
};
|
|
@ -1,91 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
|
|
||||||
// 2004-03-16, Gabriel Schreiber <schreiber@ient.rwth-aachen.de>
|
|
||||||
// Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
// Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
|
|
||||||
|
|
||||||
%module(package="opencv") highgui
|
|
||||||
|
|
||||||
%{
|
|
||||||
#include "highgui.h"
|
|
||||||
%}
|
|
||||||
|
|
||||||
%import "./cv.i"
|
|
||||||
|
|
||||||
%include "./memory.i"
|
|
||||||
%include "./typemaps.i"
|
|
||||||
|
|
||||||
%newobject cvLoadImage;
|
|
||||||
%newobject cvLoadImageM;
|
|
||||||
%newobject cvLoadImageMat;
|
|
||||||
|
|
||||||
%nodefault CvCapture;
|
|
||||||
%newobject cvCaptureFromFile;
|
|
||||||
%newobject cvCaptureFromCAM;
|
|
||||||
|
|
||||||
%nodefault CvVideoWriter;
|
|
||||||
%newobject cvCreateVideoWriter;
|
|
||||||
|
|
||||||
/** modify the following to return CvMat instead of IplImage */
|
|
||||||
%ignore cvLoadImage;
|
|
||||||
%rename (cvLoadImage) cvLoadImageMat;
|
|
||||||
%inline %{
|
|
||||||
CvMat * cvLoadImageMat(const char* filename, int iscolor=CV_LOAD_IMAGE_COLOR ){
|
|
||||||
return cvLoadImageM(filename, iscolor);
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
|
|
||||||
%typemap_out_CvMat(cvRetrieveFrame, ( CvCapture* capture ), (capture));
|
|
||||||
%typemap_out_CvMat(cvQueryFrame, ( CvCapture * capture ), (capture));
|
|
||||||
|
|
||||||
%include "highgui.h"
|
|
||||||
|
|
||||||
struct CvCapture {
|
|
||||||
};
|
|
||||||
struct CvVideoWriter {
|
|
||||||
};
|
|
||||||
%extend CvCapture { ~CvCapture () { CvCapture * dummy = self; cvReleaseCapture (& dummy); } }
|
|
||||||
%extend CvVideoWriter { ~CvVideoWriter () { CvVideoWriter * dummy = self; cvReleaseVideoWriter (& dummy); } }
|
|
||||||
|
|
||||||
|
|
@ -1,170 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
|
|
||||||
// 2004-03-16, Gabriel Schreiber <schreiber@ient.rwth-aachen.de>
|
|
||||||
// Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
// Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
// 2008-05-15, Xavier Delacour <xavier.delacour@gmail.com>
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************************\
|
|
||||||
* Array allocation, deallocation, initialization and access to elements *
|
|
||||||
\****************************************************************************************/
|
|
||||||
|
|
||||||
%nodefault _IplImage;
|
|
||||||
%newobject cvCreateImage;
|
|
||||||
%newobject cvCreateImageMat;
|
|
||||||
%newobject cvCreateImageHeader;
|
|
||||||
%newobject cvCloneImage;
|
|
||||||
%newobject cvCloneImageMat;
|
|
||||||
|
|
||||||
%nodefault CvMat;
|
|
||||||
%newobject cvCreateMat;
|
|
||||||
%newobject cvCreateMatHeader;
|
|
||||||
%newobject cvCloneMat;
|
|
||||||
%newobject cvGetSubRect;
|
|
||||||
%newobject cvGetRow;
|
|
||||||
%newobject cvGetRows;
|
|
||||||
%newobject cvGetCol;
|
|
||||||
%newobject cvGetCols;
|
|
||||||
%newobject cvGetDiag;
|
|
||||||
|
|
||||||
%nodefault CvMatND;
|
|
||||||
%newobject cvCreateMatND;
|
|
||||||
%newobject cvCreateMatHeaderND;
|
|
||||||
%newobject cvCloneMatND;
|
|
||||||
|
|
||||||
%nodefault CvSparseMat;
|
|
||||||
%newobject cvCreateSparseMat;
|
|
||||||
%newobject cvCloneSparseMat;
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************************\
|
|
||||||
* Dynamic data structures *
|
|
||||||
\****************************************************************************************/
|
|
||||||
|
|
||||||
%nodefault CvMemStorage;
|
|
||||||
%newobject cvCreateMemStorage;
|
|
||||||
%newobject cvCreateChildMemStorage;
|
|
||||||
|
|
||||||
%nodefault CvGraphScanner;
|
|
||||||
%newobject cvCreateGraphScanner;
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************************\
|
|
||||||
* Data Persistence *
|
|
||||||
\****************************************************************************************/
|
|
||||||
|
|
||||||
%nodefault CvFileStorage;
|
|
||||||
%newobject cvOpenFileStorage;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// cv.h
|
|
||||||
|
|
||||||
/****************************************************************************************\
|
|
||||||
* Image Processing *
|
|
||||||
\****************************************************************************************/
|
|
||||||
|
|
||||||
%nodefault _IplConvKernel;
|
|
||||||
%newobject cvCreateStructuringElement;
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************************\
|
|
||||||
* Structural Analysis *
|
|
||||||
\****************************************************************************************/
|
|
||||||
|
|
||||||
%newobject cvFitEllipse2;
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************************\
|
|
||||||
* Tracking *
|
|
||||||
\****************************************************************************************/
|
|
||||||
|
|
||||||
%nodefault CvKalman;
|
|
||||||
%newobject cvCreateKalman;
|
|
||||||
|
|
||||||
/****************************************************************************************\
|
|
||||||
* Histogram functions *
|
|
||||||
\****************************************************************************************/
|
|
||||||
|
|
||||||
%nodefault CvHistogram;
|
|
||||||
%newobject cvCreateHist;
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************************\
|
|
||||||
* Haar-like Object Detection functions *
|
|
||||||
\****************************************************************************************/
|
|
||||||
|
|
||||||
%nodefault CvHaarClassifierCascade;
|
|
||||||
%newobject cvLoadHaarClassifierCascade;
|
|
||||||
|
|
||||||
%nodefault CvPOSITObject;
|
|
||||||
%newobject cvCreatePOSITObject;
|
|
||||||
|
|
||||||
%nodefault CvFeatureTree;
|
|
||||||
%newobject cvCreateFeatureTree;
|
|
||||||
|
|
||||||
%nodefault CvLSH;
|
|
||||||
%newobject cvCreateLSH;
|
|
||||||
%newobject cvCreateMemoryLSH;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// This hides all members of the IplImage which OpenCV doesn't use.
|
|
||||||
%ignore _IplImage::nSize;
|
|
||||||
%ignore _IplImage::alphaChannel;
|
|
||||||
%ignore _IplImage::colorModel;
|
|
||||||
%ignore _IplImage::channelSeq;
|
|
||||||
%ignore _IplImage::maskROI;
|
|
||||||
%ignore _IplImage::imageId;
|
|
||||||
%ignore _IplImage::tileInfo;
|
|
||||||
%ignore _IplImage::BorderMode;
|
|
||||||
%ignore _IplImage::BorderConst;
|
|
||||||
%ignore _IplImage::imageDataOrigin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* imageData is hidden because the accessors produced by SWIG are not
|
|
||||||
* working correct. Use imageData_set and imageData_get instead
|
|
||||||
* (they are defined in "imagedata.i")
|
|
||||||
*/
|
|
||||||
%ignore _IplImage::imageData;
|
|
@ -1,7 +0,0 @@
|
|||||||
/* wrappers to be able to use cv.sizeof_XXX instead of size () */
|
|
||||||
|
|
||||||
%include "cmalloc.i"
|
|
||||||
|
|
||||||
%sizeof (CvContour)
|
|
||||||
%sizeof (CvPoint)
|
|
||||||
%sizeof (CvSeq)
|
|
@ -1,118 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
|
|
||||||
// 2004-03-16, Gabriel Schreiber <schreiber@ient.rwth-aachen.de>
|
|
||||||
// Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
// Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* We set our own error handling function using cvRedirectError.
|
|
||||||
* (See also error.h)
|
|
||||||
* This function throws an error (OpenCV itself never throws) which
|
|
||||||
* we catch here. The error handling function (SendErrorToPython)
|
|
||||||
* sets the Python error.
|
|
||||||
* We need to return 0 here instead of an PyObject to tell Python
|
|
||||||
* that an error has occured.
|
|
||||||
*/
|
|
||||||
%exception
|
|
||||||
{
|
|
||||||
try { $action }
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* include exception.i, so we can generate exceptions when we found errors */
|
|
||||||
%include "exception.i"
|
|
||||||
|
|
||||||
%include "sizeof.i"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* IplImage has no reference counting of underlying data, which creates problems with double
|
|
||||||
* frees after accessing subarrays in python -- instead, replace IplImage with CvMat, which
|
|
||||||
* should be functionally equivalent, but has reference counting.
|
|
||||||
* The potential shortcomings of this method are
|
|
||||||
* 1. no ROI
|
|
||||||
* 2. IplImage fields missing or named something else.
|
|
||||||
*/
|
|
||||||
%typemap(in) IplImage * (IplImage header){
|
|
||||||
void * vptr;
|
|
||||||
int res = SWIG_ConvertPtr($input, (&vptr), $descriptor( CvMat * ), 0);
|
|
||||||
if ( res == -1 ){
|
|
||||||
SWIG_exception( SWIG_TypeError, "%%typemap(in) IplImage * : could not convert to CvMat");
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
$1 = cvGetImage((CvMat *)vptr, &header);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** For IplImage * return type, there are cases in which the memory should be freed and
|
|
||||||
* some not. To avoid leaks and segfaults, deprecate this return type and handle cases
|
|
||||||
* individually
|
|
||||||
*/
|
|
||||||
%typemap(out) IplImage * {
|
|
||||||
SWIG_exception( SWIG_TypeError, "IplImage * return type is deprecated. Please file a bug report at www.sourceforge.net/opencvlibrary if you see this error message.");
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** macro to convert IplImage return type to CvMat. Note that this is only covers the case
|
|
||||||
* where the returned IplImage need not be freed. If the IplImage header needs to be freed,
|
|
||||||
* then CvMat must take ownership of underlying data. Instead, just handle these limited cases
|
|
||||||
* with CvMat equivalent.
|
|
||||||
*/
|
|
||||||
%define %typemap_out_CvMat(func, decl, call)
|
|
||||||
%rename (func##__Deprecated) func;
|
|
||||||
%rename (func) func##__CvMat;
|
|
||||||
%inline %{
|
|
||||||
CvMat * func##__CvMat##decl{
|
|
||||||
IplImage * im = func##call;
|
|
||||||
if(im){
|
|
||||||
CvMat * mat = (CvMat *)cvAlloc(sizeof(CvMat));
|
|
||||||
mat = cvGetMat(im, mat);
|
|
||||||
return mat;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
%enddef
|
|
@ -1 +0,0 @@
|
|||||||
|
|
@ -1,36 +0,0 @@
|
|||||||
IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
|
|
||||||
By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
If you do not agree to this license, do not download, install,
|
|
||||||
copy or use the software.
|
|
||||||
|
|
||||||
|
|
||||||
Intel License Agreement
|
|
||||||
For Open Source Computer Vision Library
|
|
||||||
|
|
||||||
Copyright (C) 2000, 2001, Intel Corporation, all rights reserved.
|
|
||||||
Third party copyrights are property of their respective owners.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistribution's of source code must retain the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
* The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
derived from this software without specific prior written permission.
|
|
||||||
|
|
||||||
This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
any express or implied warranties, including, but not limited to, the implied
|
|
||||||
warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
(including, but not limited to, procurement of substitute goods or services;
|
|
||||||
loss of use, data, or profits; or business interruption) however caused
|
|
||||||
and on any theory of liability, whether in contract, strict liability,
|
|
||||||
or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
the use of this software, even if advised of the possibility of such damage.
|
|
@ -1,12 +0,0 @@
|
|||||||
Name: opencv
|
|
||||||
Version: 1.0
|
|
||||||
Date: 2008-03-15
|
|
||||||
Author: Various Authors
|
|
||||||
Maintainer: Xavier Delacour
|
|
||||||
Title: OpenCV (Open Computer Vision Library) bindings
|
|
||||||
Description: Bindings for OpenCV, a collection of over 500 functions implementing computer vision, image processing and general-purpose numeric algorithms. The library is compatible with IPL and utilizes Intel Integrated Performance Primitives for better performance. More info at http://sourceforge.net/projects/opencvlibrary.
|
|
||||||
Depends: octave (>= 2.9.12)
|
|
||||||
Autoload: yes
|
|
||||||
SystemRequirements: swig, libcv-dev, libcvaux-dev, libhighgui-dev
|
|
||||||
License: BSD
|
|
||||||
Url: http://octave.sf.net
|
|
@ -1 +0,0 @@
|
|||||||
see the online documentation
|
|
@ -1,178 +0,0 @@
|
|||||||
cv;
|
|
||||||
ml;
|
|
||||||
highgui;
|
|
||||||
|
|
||||||
IPL_ALIGN_DWORD=IPL_ALIGN_4BYTES;
|
|
||||||
IPL_ALIGN_QWORD=IPL_ALIGN_8BYTES;
|
|
||||||
CV_GRAPH=CV_SEQ_KIND_GRAPH;
|
|
||||||
CV_HIST_TREE=CV_HIST_SPARSE;
|
|
||||||
CV_TERMCRIT_NUMBER=CV_TERMCRIT_ITER;
|
|
||||||
CV_SEQ_ELTYPE_PTR=CV_USRTYPE1;
|
|
||||||
CV_SEQ_CONTOUR=CV_SEQ_POLYGON;
|
|
||||||
CV_STORAGE_WRITE_TEXT=CV_STORAGE_WRITE;
|
|
||||||
CV_STORAGE_WRITE_BINARY=CV_STORAGE_WRITE;
|
|
||||||
CV_NODE_INTEGER=CV_NODE_INT;
|
|
||||||
CV_NODE_FLOAT=CV_NODE_REAL;
|
|
||||||
CV_NODE_STRING=CV_NODE_STR;
|
|
||||||
CV_DXT_INVERSE_SCALE=CV_DXT_INV_SCALE;
|
|
||||||
CV_RGB2RGBA=CV_BGR2BGRA;
|
|
||||||
CV_FONT_VECTOR0=CV_FONT_HERSHEY_SIMPLEX;
|
|
||||||
CV_RGBA2RGB=CV_BGRA2BGR;
|
|
||||||
CV_RGB2BGRA=CV_BGR2RGBA;
|
|
||||||
CV_BGRA2RGB=CV_RGBA2BGR;
|
|
||||||
CV_RGB2BGR=CV_BGR2RGB;
|
|
||||||
CV_RGBA2BGRA=CV_BGRA2RGBA;
|
|
||||||
CV_GRAY2RGB=CV_GRAY2BGR;
|
|
||||||
CV_GRAY2RGBA=CV_GRAY2BGRA;
|
|
||||||
CV_BayerBG2RGB=CV_BayerRG2BGR;
|
|
||||||
CV_BayerGB2RGB=CV_BayerGR2BGR;
|
|
||||||
CV_BayerRG2RGB=CV_BayerBG2BGR;
|
|
||||||
CV_BayerGR2RGB=CV_BayerGB2BGR;
|
|
||||||
|
|
||||||
CV_MAKE_TYPE=@CV_MAKETYPE;
|
|
||||||
CV_IS_CONT_MAT=@CV_IS_MAT_CONT;
|
|
||||||
cvGetSubArr=@cvGetSubRect;
|
|
||||||
cvZero=@cvSetZero;
|
|
||||||
cvCvtScale=@cvConvertScale;
|
|
||||||
cvScale=@cvConvertScale;
|
|
||||||
cvCvtScaleAbs=@cvConvertScaleAbs;
|
|
||||||
cvCheckArray=@cvCheckArr;
|
|
||||||
cvMatMulAddEx=@cvGEMM;
|
|
||||||
cvMatMulAddS=@cvTransform;
|
|
||||||
cvT=@cvTranspose;
|
|
||||||
cvMirror=@cvFlip;
|
|
||||||
cvInv=@cvInvert;
|
|
||||||
cvMahalonobis=@cvMahalanobis;
|
|
||||||
cvFFT=@cvDFT;
|
|
||||||
cvGraphFindEdge=@cvFindGraphEdge;
|
|
||||||
cvGraphFindEdgeByPtr=@cvFindGraphEdgeByPtr;
|
|
||||||
cvDrawRect=@cvRectangle;
|
|
||||||
cvDrawLine=@cvLine;
|
|
||||||
cvDrawCircle=@cvCircle;
|
|
||||||
cvDrawEllipse=@cvEllipse;
|
|
||||||
cvDrawPolyLine=@cvPolyLine;
|
|
||||||
cvCalcHist=@cvCalcArrHist;
|
|
||||||
|
|
||||||
## use subsasgn/assign, combine with above
|
|
||||||
## or expose octave_swig_type install_global etc
|
|
||||||
cv.CV_MAKE_TYPE=@CV_MAKETYPE;
|
|
||||||
cv.CV_IS_CONT_MAT=@CV_IS_MAT_CONT;
|
|
||||||
cv.cvGetSubArr=@cvGetSubRect;
|
|
||||||
cv.cvZero=@cvSetZero;
|
|
||||||
cv.cvCvtScale=@cvConvertScale;
|
|
||||||
cv.cvScale=@cvConvertScale;
|
|
||||||
cv.cvCvtScaleAbs=@cvConvertScaleAbs;
|
|
||||||
cv.cvCheckArray=@cvCheckArr;
|
|
||||||
cv.cvMatMulAddEx=@cvGEMM;
|
|
||||||
cv.cvMatMulAddS=@cvTransform;
|
|
||||||
cv.cvT=@cvTranspose;
|
|
||||||
cv.cvMirror=@cvFlip;
|
|
||||||
cv.cvInv=@cvInvert;
|
|
||||||
cv.cvMahalonobis=@cvMahalanobis;
|
|
||||||
cv.cvFFT=@cvDFT;
|
|
||||||
cv.cvGraphFindEdge=@cvFindGraphEdge;
|
|
||||||
cv.cvGraphFindEdgeByPtr=@cvFindGraphEdgeByPtr;
|
|
||||||
cv.cvDrawRect=@cvRectangle;
|
|
||||||
cv.cvDrawLine=@cvLine;
|
|
||||||
cv.cvDrawCircle=@cvCircle;
|
|
||||||
cv.cvDrawEllipse=@cvEllipse;
|
|
||||||
cv.cvDrawPolyLine=@cvPolyLine;
|
|
||||||
cv.cvCalcHist=@cvCalcArrHist;
|
|
||||||
|
|
||||||
## add %octavecode support, or use subsref
|
|
||||||
|
|
||||||
function [count,seq] = cvFindContours(varargin)
|
|
||||||
global cv;
|
|
||||||
[count, seq] = cv.cvFindContoursUntyped( varargin{:} );
|
|
||||||
if (swig_this(seq))
|
|
||||||
seq = cv.CvSeq_CvPoint.cast(seq);
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
cv.cvFindContours=@cvFindContours;
|
|
||||||
|
|
||||||
function [count,seq] = cvHoughCircles(varargin)
|
|
||||||
global cv;
|
|
||||||
[count, seq] = cv.cvHoughCirclesUntyped( varargin{:} );
|
|
||||||
if (swig_this(seq))
|
|
||||||
seq = cv.CvSeq_float_3.cast(seq);
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
cv.cvHoughCircles=@cvHoughCircles;
|
|
||||||
|
|
||||||
function [count,seq] = cvPyrSegmentation(varargin)
|
|
||||||
global cv;
|
|
||||||
[count, seq] = cv.cvPyrSegmentationUntyped( varargin{:} );
|
|
||||||
if (swig_this(seq))
|
|
||||||
seq = cv.CvSeq_CvConnectedComp.cast(seq);
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
cv.cvPyrSegmentation=@cvPyrSegmentation;
|
|
||||||
|
|
||||||
function [count,seq] = cvApproxChains(varargin)
|
|
||||||
global cv;
|
|
||||||
[count, seq] = cv.cvApproxChainsUntyped( varargin{:} );
|
|
||||||
if (swig_this(seq))
|
|
||||||
seq = cv.CvSeq_CvPoint.cast(seq);
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
cv.cvApproxChains=@cvApproxChains;
|
|
||||||
|
|
||||||
function [count,seq] = cvContourFromContourTree(varargin)
|
|
||||||
global cv;
|
|
||||||
[count, seq] = cv.cvContourFromContourTreeUntyped( varargin{:} );
|
|
||||||
if (swig_this(seq))
|
|
||||||
seq = cv.CvSeq_CvPoint.cast(seq);
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
cv.cvContourFromContourTree=@cvContourFromContourTree;
|
|
||||||
|
|
||||||
function [count,seq] = cvConvexityDefects(varargin)
|
|
||||||
global cv;
|
|
||||||
[count, seq] = cv.cvConvexityDefectsUntyped( varargin{:} );
|
|
||||||
if (swig_this(seq))
|
|
||||||
seq = cv.CvSeq_CvConvexityDefect.cast(seq);
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
cv.cvConvexityDefects=@cvConvexityDefects;
|
|
||||||
|
|
||||||
function seq = cvHoughLines2(varargin)
|
|
||||||
global cv;
|
|
||||||
seq = cv.cvHoughLinesUntyped( varargin{:} );
|
|
||||||
if (swig_this(seq))
|
|
||||||
seq = cv.CvSeq_CvPoint.cast(seq);
|
|
||||||
t = CV_SEQ_ELTYPE(seq)
|
|
||||||
if (t == cv.CV_32SC4)
|
|
||||||
seq = cv.CvSeq_CvPoint_2.cast(seq)
|
|
||||||
else
|
|
||||||
seq = cv.CvSeq_float_2.cast(seq)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
cv.cvHoughLines2=@cvHoughLines2;
|
|
||||||
|
|
||||||
|
|
||||||
function c = CvSeq_map(self)
|
|
||||||
c = cell(1, self.total);
|
|
||||||
for i = 1:self.total, c{i} = self{i}; end;
|
|
||||||
endfunction
|
|
||||||
cv.CvSeq_map=@CvSeq_map;
|
|
||||||
|
|
||||||
function c = CvSeq_hrange(self)
|
|
||||||
c = {};
|
|
||||||
i = 0;
|
|
||||||
if swig_this(self)
|
|
||||||
s = self;
|
|
||||||
while swig_this(s.h_next), s = s.cast(s.h_next); c{++i} = s; end;
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
cv.CvSeq_hrange=@CvSeq_hrange;
|
|
||||||
|
|
||||||
function c = CvSeq_vrange(self)
|
|
||||||
c = {};
|
|
||||||
i = 0;
|
|
||||||
if swig_this(self)
|
|
||||||
s = self;
|
|
||||||
while swig_this(s.v_next), s = s.cast(s.v_next); c{++i} = s; end;
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
cv.CvSeq_vrange=@CvSeq_vrange;
|
|
@ -1,452 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
// 2008-04-07, Xavier Delacour <xavier.delacour@gmail.com>
|
|
||||||
|
|
||||||
|
|
||||||
// The trouble here is that Octave arrays are in Fortran order, while OpenCV
|
|
||||||
// arrays are in C order. Neither Octave nor OpenCV seem to provide n-dim
|
|
||||||
// transpose, so we do that here.
|
|
||||||
|
|
||||||
// For images, we also scale the result to lie within [0-1].
|
|
||||||
|
|
||||||
|
|
||||||
// * add support for sparse matrices
|
|
||||||
|
|
||||||
// * add support for complex matrices
|
|
||||||
|
|
||||||
// * add support for roi and coi, or complain if either is set
|
|
||||||
|
|
||||||
// * test case for channel==1
|
|
||||||
// * test case for channel=={2,3,4}
|
|
||||||
// * test case for 2 dim, 1 dim, n dim cases
|
|
||||||
|
|
||||||
%{
|
|
||||||
|
|
||||||
class ndim_iterator {
|
|
||||||
int nd;
|
|
||||||
int dims[CV_MAX_DIM];
|
|
||||||
int step[CV_MAX_DIM];
|
|
||||||
int curr[CV_MAX_DIM];
|
|
||||||
uchar* _data;
|
|
||||||
int _type;
|
|
||||||
bool done;
|
|
||||||
public:
|
|
||||||
ndim_iterator() {}
|
|
||||||
ndim_iterator(CvMat* m) {
|
|
||||||
int c = CV_MAT_CN(m->type);
|
|
||||||
int elem_size = CV_ELEM_SIZE1(m->type);
|
|
||||||
nd = c == 1 ? 2 : 3;
|
|
||||||
dims[0] = m->rows;
|
|
||||||
dims[1] = m->cols;
|
|
||||||
dims[2] = c;
|
|
||||||
step[0] = m->step;
|
|
||||||
step[1] = c * elem_size;
|
|
||||||
step[2] = elem_size;
|
|
||||||
curr[0] = curr[1] = curr[2] = 0;
|
|
||||||
_data = m->data.ptr;
|
|
||||||
_type = m->type;
|
|
||||||
done = false;
|
|
||||||
}
|
|
||||||
ndim_iterator(CvMatND* m) {
|
|
||||||
int c = CV_MAT_CN(m->type);
|
|
||||||
int elem_size = CV_ELEM_SIZE1(m->type);
|
|
||||||
nd = m->dims + (c == 1 ? 0 : 1);
|
|
||||||
for (int j = 0; j < m->dims; ++j) {
|
|
||||||
dims[j] = m->dim[j].size;
|
|
||||||
step[j] = m->dim[j].step;
|
|
||||||
curr[j] = 0;
|
|
||||||
}
|
|
||||||
if (c > 1) {
|
|
||||||
dims[m->dims] = c;
|
|
||||||
step[m->dims] = elem_size;
|
|
||||||
curr[m->dims] = 0;
|
|
||||||
}
|
|
||||||
_data = m->data.ptr;
|
|
||||||
_type = m->type;
|
|
||||||
done = false;
|
|
||||||
}
|
|
||||||
ndim_iterator(IplImage* img) {
|
|
||||||
nd = img->nChannels == 1 ? 2 : 3;
|
|
||||||
dims[0] = img->height;
|
|
||||||
dims[1] = img->width;
|
|
||||||
dims[2] = img->nChannels;
|
|
||||||
|
|
||||||
switch (img->depth) {
|
|
||||||
case IPL_DEPTH_8U: _type = CV_8U; break;
|
|
||||||
case IPL_DEPTH_8S: _type = CV_8S; break;
|
|
||||||
case IPL_DEPTH_16U: _type = CV_16U; break;
|
|
||||||
case IPL_DEPTH_16S: _type = CV_16S; break;
|
|
||||||
case IPL_DEPTH_32S: _type = CV_32S; break;
|
|
||||||
case IPL_DEPTH_32F: _type = CV_32F; break;
|
|
||||||
case IPL_DEPTH_1U: _type = CV_64F; break;
|
|
||||||
default:
|
|
||||||
error("unsupported image depth");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int elem_size = CV_ELEM_SIZE1(_type);
|
|
||||||
step[0] = img->widthStep;
|
|
||||||
step[1] = img->nChannels * elem_size;
|
|
||||||
step[2] = elem_size;
|
|
||||||
curr[0] = curr[1] = curr[2] = 0;
|
|
||||||
_data = (uchar*)img->imageData;
|
|
||||||
done = false;
|
|
||||||
}
|
|
||||||
ndim_iterator(NDArray& nda) {
|
|
||||||
dim_vector d(nda.dims());
|
|
||||||
nd = d.length();
|
|
||||||
int last_step = sizeof(double);
|
|
||||||
for (int j = 0; j < d.length(); ++j) {
|
|
||||||
dims[j] = d(j);
|
|
||||||
step[j] = last_step;
|
|
||||||
last_step *= dims[j];
|
|
||||||
curr[j] = 0;
|
|
||||||
}
|
|
||||||
_data = (uchar*)const_cast<double*>(nda.data());
|
|
||||||
_type = CV_64F;
|
|
||||||
done = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
operator bool () const {
|
|
||||||
return !done;
|
|
||||||
}
|
|
||||||
uchar* data() {
|
|
||||||
return _data;
|
|
||||||
}
|
|
||||||
int type() const {
|
|
||||||
return _type;
|
|
||||||
}
|
|
||||||
ndim_iterator& operator++ () {
|
|
||||||
int curr_dim = 0;
|
|
||||||
for (;;) {
|
|
||||||
_data += step[curr_dim];
|
|
||||||
if (++curr[curr_dim] < dims[curr_dim])
|
|
||||||
break;
|
|
||||||
curr[curr_dim] = 0;
|
|
||||||
_data -= step[curr_dim] * dims[curr_dim];
|
|
||||||
++curr_dim;
|
|
||||||
if (curr_dim == nd) {
|
|
||||||
done = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
void transpose_copy_typed(ndim_iterator src_it, ndim_iterator dst_it,
|
|
||||||
double scale) {
|
|
||||||
assert(sizeof(T1) == CV_ELEM_SIZE1(src_it.type()));
|
|
||||||
assert(sizeof(T2) == CV_ELEM_SIZE1(dst_it.type()));
|
|
||||||
if (scale == 1) {
|
|
||||||
while (src_it) {
|
|
||||||
*(T2*)dst_it.data() = (T2)*(T1*)src_it.data();
|
|
||||||
++src_it;
|
|
||||||
++dst_it;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
while (src_it) {
|
|
||||||
*(T2*)dst_it.data() = (T2)(scale * (*(T1*)src_it.data()));
|
|
||||||
++src_it;
|
|
||||||
++dst_it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T1>
|
|
||||||
void transpose_copy2(ndim_iterator src_it, ndim_iterator dst_it,
|
|
||||||
double scale) {
|
|
||||||
switch (CV_MAT_DEPTH(dst_it.type())) {
|
|
||||||
case CV_8U: transpose_copy_typed<T1,unsigned char>(src_it,dst_it,scale); break;
|
|
||||||
case CV_8S: transpose_copy_typed<T1,signed char>(src_it,dst_it,scale); break;
|
|
||||||
case CV_16U: transpose_copy_typed<T1,unsigned short>(src_it,dst_it,scale); break;
|
|
||||||
case CV_16S: transpose_copy_typed<T1,signed short>(src_it,dst_it,scale); break;
|
|
||||||
case CV_32S: transpose_copy_typed<T1,signed int>(src_it,dst_it,scale); break;
|
|
||||||
case CV_32F: transpose_copy_typed<T1,float>(src_it,dst_it,scale); break;
|
|
||||||
case CV_64F: transpose_copy_typed<T1,double>(src_it,dst_it,scale); break;
|
|
||||||
default:
|
|
||||||
error("unsupported dest array type (supported types are CV_8U, CV_8S, "
|
|
||||||
"CV_16U, CV_16S, CV_32S, CV_32F, CV_64F)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void transpose_copy(ndim_iterator src_it, ndim_iterator dst_it,
|
|
||||||
double scale = 1) {
|
|
||||||
switch (CV_MAT_DEPTH(src_it.type())) {
|
|
||||||
case CV_8U: transpose_copy2<unsigned char>(src_it,dst_it,scale); break;
|
|
||||||
case CV_8S: transpose_copy2<signed char>(src_it,dst_it,scale); break;
|
|
||||||
case CV_16U: transpose_copy2<unsigned short>(src_it,dst_it,scale); break;
|
|
||||||
case CV_16S: transpose_copy2<signed short>(src_it,dst_it,scale); break;
|
|
||||||
case CV_32S: transpose_copy2<signed int>(src_it,dst_it,scale); break;
|
|
||||||
case CV_32F: transpose_copy2<float>(src_it,dst_it,scale); break;
|
|
||||||
case CV_64F: transpose_copy2<double>(src_it,dst_it,scale); break;
|
|
||||||
default:
|
|
||||||
error("unsupported source array type (supported types are CV_8U, CV_8S, "
|
|
||||||
"CV_16U, CV_16S, CV_32S, CV_32F, CV_64F)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
octave_value cv2mat(CvArr* arr) {
|
|
||||||
dim_vector d;
|
|
||||||
NDArray nda;
|
|
||||||
|
|
||||||
if (CV_IS_MAT(arr)) {
|
|
||||||
// m x n x c
|
|
||||||
CvMat* m = (CvMat*)arr;
|
|
||||||
|
|
||||||
int c = CV_MAT_CN(m->type);
|
|
||||||
if (c == 1) {
|
|
||||||
d.resize(2);
|
|
||||||
d(0) = m->rows;
|
|
||||||
d(1) = m->cols;
|
|
||||||
} else {
|
|
||||||
d.resize(3);
|
|
||||||
d(0) = m->rows;
|
|
||||||
d(1) = m->cols;
|
|
||||||
d(2) = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
nda = NDArray(d);
|
|
||||||
transpose_copy(m, nda);
|
|
||||||
}
|
|
||||||
else if (CV_IS_MATND(arr)) {
|
|
||||||
// m1 x m2 x ... x mn x c
|
|
||||||
CvMatND* m = (CvMatND*)arr;
|
|
||||||
|
|
||||||
int c = CV_MAT_CN(m->type);
|
|
||||||
if (c == 1) {
|
|
||||||
d.resize(m->dims);
|
|
||||||
for (int j = 0; j < m->dims; ++j)
|
|
||||||
d(j) = m->dim[j].size;
|
|
||||||
} else {
|
|
||||||
d.resize(m->dims + 1);
|
|
||||||
for (int j = 0; j < m->dims; ++j)
|
|
||||||
d(j) = m->dim[j].size;
|
|
||||||
d(m->dims) = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
nda = NDArray(d);
|
|
||||||
transpose_copy(m, nda);
|
|
||||||
}
|
|
||||||
else if (CV_IS_IMAGE(arr)) {
|
|
||||||
// m x n x c
|
|
||||||
IplImage* img = (IplImage*)arr;
|
|
||||||
|
|
||||||
if (img->nChannels == 1) {
|
|
||||||
d.resize(2);
|
|
||||||
d(0) = img->height;
|
|
||||||
d(1) = img->width;
|
|
||||||
} else {
|
|
||||||
d.resize(3);
|
|
||||||
d(0) = img->height;
|
|
||||||
d(1) = img->width;
|
|
||||||
d(2) = img->nChannels;
|
|
||||||
}
|
|
||||||
|
|
||||||
nda = NDArray(d);
|
|
||||||
transpose_copy(img, nda);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
error("unsupported array type (supported types are CvMat, CvMatND, IplImage)");
|
|
||||||
return octave_value();
|
|
||||||
}
|
|
||||||
|
|
||||||
return nda;
|
|
||||||
}
|
|
||||||
|
|
||||||
octave_value mat2cv(const octave_value& ov, int type) {
|
|
||||||
NDArray nda(ov.array_value());
|
|
||||||
if (error_state)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
dim_vector d = ov.dims();
|
|
||||||
assert(d.length() > 0);
|
|
||||||
|
|
||||||
int nd = d.length();
|
|
||||||
int last_dim = d(d.length() - 1);
|
|
||||||
int c = CV_MAT_CN(type);
|
|
||||||
if (c != 1 && c != last_dim) {
|
|
||||||
error("last dimension and channel must agree, or channel must equal one");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (c > 1)
|
|
||||||
--nd;
|
|
||||||
|
|
||||||
if (nd == 2) {
|
|
||||||
CvMat *m = cvCreateMat(d(0), d(1), type);
|
|
||||||
transpose_copy(nda, m);
|
|
||||||
return SWIG_NewPointerObj(m, SWIGTYPE_p_CvMat, SWIG_POINTER_OWN);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int tmp[CV_MAX_DIM];
|
|
||||||
for (int j = 0; j < nd; ++j)
|
|
||||||
tmp[j] = d(j);
|
|
||||||
CvMatND *m = cvCreateMatND(nd, tmp, type);
|
|
||||||
transpose_copy(nda, m);
|
|
||||||
return SWIG_NewPointerObj(m, SWIGTYPE_p_CvMatND, SWIG_POINTER_OWN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
octave_value cv2im(CvArr* arr) {
|
|
||||||
if (!CV_IS_IMAGE(arr) && !CV_IS_MAT(arr)) {
|
|
||||||
error("input is not an OpenCV image or 2D matrix");
|
|
||||||
return octave_value();
|
|
||||||
}
|
|
||||||
|
|
||||||
dim_vector d;
|
|
||||||
NDArray nda;
|
|
||||||
|
|
||||||
if (CV_IS_MAT(arr)) {
|
|
||||||
// m x n x c
|
|
||||||
CvMat* m = (CvMat*)arr;
|
|
||||||
|
|
||||||
int c = CV_MAT_CN(m->type);
|
|
||||||
if (c == 1) {
|
|
||||||
d.resize(2);
|
|
||||||
d(0) = m->rows;
|
|
||||||
d(1) = m->cols;
|
|
||||||
} else {
|
|
||||||
d.resize(3);
|
|
||||||
d(0) = m->rows;
|
|
||||||
d(1) = m->cols;
|
|
||||||
d(2) = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
nda = NDArray(d);
|
|
||||||
transpose_copy(m, nda, 1/256.0);
|
|
||||||
}
|
|
||||||
else if (CV_IS_IMAGE(arr)) {
|
|
||||||
// m x n x c
|
|
||||||
IplImage* img = (IplImage*)arr;
|
|
||||||
|
|
||||||
if (img->nChannels == 1) {
|
|
||||||
d.resize(2);
|
|
||||||
d(0) = img->height;
|
|
||||||
d(1) = img->width;
|
|
||||||
} else {
|
|
||||||
d.resize(3);
|
|
||||||
d(0) = img->height;
|
|
||||||
d(1) = img->width;
|
|
||||||
d(2) = img->nChannels;
|
|
||||||
}
|
|
||||||
|
|
||||||
nda = NDArray(d);
|
|
||||||
transpose_copy(img, nda, 1/256.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return nda;
|
|
||||||
}
|
|
||||||
|
|
||||||
CvMat* im2cv(const octave_value& ov, int depth) {
|
|
||||||
NDArray nda(ov.array_value());
|
|
||||||
if (error_state)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
dim_vector d = ov.dims();
|
|
||||||
assert(d.length() > 0);
|
|
||||||
|
|
||||||
if (d.length() != 2 && d.length() != 3 &&
|
|
||||||
!(d.length() == 3 && d(2) <= 4)) {
|
|
||||||
error("input must be m x n or m x n x c matrix, where 1<=c<=4");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int channels = d.length() == 2 ? 1 : d(2);
|
|
||||||
int type = CV_MAKETYPE(depth, channels);
|
|
||||||
|
|
||||||
CvMat *m = cvCreateMat(d(0), d(1), type);
|
|
||||||
transpose_copy(nda, m, 256);
|
|
||||||
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
%}
|
|
||||||
|
|
||||||
%newobject im2cv;
|
|
||||||
|
|
||||||
%feature("autodoc", 0) cv2mat;
|
|
||||||
%feature("autodoc", 0) mat2cv;
|
|
||||||
%feature("autodoc", 0) cv2im;
|
|
||||||
%feature("autodoc", 0) im2cv;
|
|
||||||
|
|
||||||
%docstring cv2mat {
|
|
||||||
@deftypefn {Loadable Function} @var{m1} = cv2mat (@var{m2})
|
|
||||||
Convert the CvMat, CvMatND, or IplImage @var{m2} into an Octave real matrix @var{m1}.
|
|
||||||
The dimensions @var{m1} are those of @var{m2}, plus an addition dimension
|
|
||||||
if @var{m2} has more than one channel.
|
|
||||||
@end deftypefn
|
|
||||||
}
|
|
||||||
|
|
||||||
%docstring mat2cv {
|
|
||||||
@deftypefn {Loadable Function} @var{m1} = mat2cv (@var{m2}, @var{type})
|
|
||||||
Convert the Octave array @var{m2} into either a CvMat or a CvMatND of type
|
|
||||||
@var{type}.
|
|
||||||
@var{type} is one of CV_8UC(n), CV_8SC(n), CV_16UC(n), CV_16SC(n), CV_32SC(n),
|
|
||||||
CV_32FC(n), CV_64FC(n), where n indicates channel and is between 1 and 4.
|
|
||||||
If the dimension of @var{m2} is equal to 2 (not counting channels),
|
|
||||||
a CvMat is returned. Otherwise, a CvMatND is returned.
|
|
||||||
@end deftypefn
|
|
||||||
}
|
|
||||||
|
|
||||||
%docstring cv2im {
|
|
||||||
@deftypefn {Loadable Function} @var{im} = cv2im (@var{I})
|
|
||||||
Convert the OpenCV image or 2D matrix @var{I} into an Octave image @var{im}.
|
|
||||||
@var{im} is a real matrix of dimension height x width or
|
|
||||||
height x width x channels, with values within the interval [0,1]).
|
|
||||||
@end deftypefn
|
|
||||||
}
|
|
||||||
|
|
||||||
%docstring im2cv {
|
|
||||||
@deftypefn {Loadable Function} @var{I} = im2cv (@var{im}, @var{depth})
|
|
||||||
Convert the Octave image @var{im} into the OpenCV image @var{I} of depth
|
|
||||||
@var{depth}.
|
|
||||||
@var{im} is a real matrix of dimension height x width or
|
|
||||||
height x width x channels, with values within the interval [0,1].
|
|
||||||
@var{depth} must be one of CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F.
|
|
||||||
@end deftypefn
|
|
||||||
}
|
|
||||||
|
|
||||||
octave_value cv2mat(CvArr* arr);
|
|
||||||
octave_value mat2cv(const octave_value& ov, int type);
|
|
||||||
octave_value cv2im(CvArr* arr);
|
|
||||||
CvMat* im2cv(const octave_value& ov, int depth);
|
|
@ -1,87 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
// 2004-03-16, Gabriel Schreiber <schreiber@ient.rwth-aachen.de>
|
|
||||||
// Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
// Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
// 2008-04-03, Xavier Delacour <xavier.delacour@gmail.com>
|
|
||||||
|
|
||||||
|
|
||||||
// todo remove these..
|
|
||||||
#pragma SWIG nowarn=312,362,303,365,366,367,368,370,371,372,451,454,503
|
|
||||||
|
|
||||||
|
|
||||||
%{
|
|
||||||
#include "octhelpers.h"
|
|
||||||
#include "octcvseq.hpp"
|
|
||||||
#include "octerror.h"
|
|
||||||
%}
|
|
||||||
|
|
||||||
|
|
||||||
// direct SWIG to generate octave docstrings
|
|
||||||
%feature("autodoc", 1);
|
|
||||||
|
|
||||||
// include octave-specific files
|
|
||||||
%include "./octtypemaps.i"
|
|
||||||
%include "./cvshadow.i"
|
|
||||||
|
|
||||||
// parse OpenCV headers
|
|
||||||
%include "../general/cv.i"
|
|
||||||
|
|
||||||
// Accessors for the CvMat and IplImage data structure are defined here
|
|
||||||
%include "./cvarr.i"
|
|
||||||
|
|
||||||
// Octave sequence compatibility for CvSeq
|
|
||||||
%include "./cvseq.i"
|
|
||||||
|
|
||||||
|
|
||||||
%include "./imagedata.i"
|
|
||||||
|
|
||||||
// include some wrappers to manipulate CvSeq types
|
|
||||||
%include "./octcvseq.hpp"
|
|
||||||
|
|
||||||
// aliases from #defines
|
|
||||||
%include "./cvaliases.i"
|
|
||||||
|
|
||||||
%insert(init) %{
|
|
||||||
cvRedirectError(function_ptr_generator(), void_ptr_generator(), void_ptrptr_generator());
|
|
||||||
%}
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
%module cv
|
|
||||||
%pythoncode %{
|
|
||||||
IPL_ALIGN_DWORD=IPL_ALIGN_4BYTES
|
|
||||||
IPL_ALIGN_QWORD=IPL_ALIGN_8BYTES
|
|
||||||
CV_MAKE_TYPE=CV_MAKETYPE
|
|
||||||
CV_IS_CONT_MAT=CV_IS_MAT_CONT
|
|
||||||
CV_HIST_TREE=CV_HIST_SPARSE
|
|
||||||
CV_TERMCRIT_NUMBER=CV_TERMCRIT_ITER
|
|
||||||
CV_SEQ_ELTYPE_PTR=CV_USRTYPE1
|
|
||||||
CV_GRAPH=CV_SEQ_KIND_GRAPH
|
|
||||||
CV_SEQ_CONTOUR=CV_SEQ_POLYGON
|
|
||||||
CV_STORAGE_WRITE_TEXT=CV_STORAGE_WRITE
|
|
||||||
CV_STORAGE_WRITE_BINARY=CV_STORAGE_WRITE
|
|
||||||
CV_NODE_INTEGER=CV_NODE_INT
|
|
||||||
CV_NODE_FLOAT=CV_NODE_REAL
|
|
||||||
CV_NODE_STRING=CV_NODE_STR
|
|
||||||
cvGetSubArr=cvGetSubRect
|
|
||||||
cvZero=cvSetZero
|
|
||||||
cvCvtScale=cvConvertScale
|
|
||||||
cvScale=cvConvertScale
|
|
||||||
cvCvtScaleAbs=cvConvertScaleAbs
|
|
||||||
cvCheckArray=cvCheckArr
|
|
||||||
cvMatMulAddEx=cvGEMM
|
|
||||||
cvMatMulAddS=cvTransform
|
|
||||||
cvT=cvTranspose
|
|
||||||
cvMirror=cvFlip
|
|
||||||
cvInv=cvInvert
|
|
||||||
cvMahalonobis=cvMahalanobis
|
|
||||||
CV_DXT_INVERSE_SCALE=CV_DXT_INV_SCALE
|
|
||||||
cvFFT=cvDFT
|
|
||||||
cvGraphFindEdge=cvFindGraphEdge
|
|
||||||
cvGraphFindEdgeByPtr=cvFindGraphEdgeByPtr
|
|
||||||
cvDrawRect=cvRectangle
|
|
||||||
cvDrawLine=cvLine
|
|
||||||
cvDrawCircle=cvCircle
|
|
||||||
cvDrawEllipse=cvEllipse
|
|
||||||
cvDrawPolyLine=cvPolyLine
|
|
||||||
CV_FONT_VECTOR0=CV_FONT_HERSHEY_SIMPLEX
|
|
||||||
CV_RGB2RGBA=CV_BGR2BGRA
|
|
||||||
CV_RGBA2RGB=CV_BGRA2BGR
|
|
||||||
CV_RGB2BGRA=CV_BGR2RGBA
|
|
||||||
CV_BGRA2RGB=CV_RGBA2BGR
|
|
||||||
CV_RGB2BGR=CV_BGR2RGB
|
|
||||||
CV_RGBA2BGRA=CV_BGRA2RGBA
|
|
||||||
CV_GRAY2RGB=CV_GRAY2BGR
|
|
||||||
CV_GRAY2RGBA=CV_GRAY2BGRA
|
|
||||||
CV_BayerBG2RGB=CV_BayerRG2BGR
|
|
||||||
CV_BayerGB2RGB=CV_BayerGR2BGR
|
|
||||||
CV_BayerRG2RGB=CV_BayerBG2BGR
|
|
||||||
CV_BayerGR2RGB=CV_BayerGB2BGR
|
|
||||||
%}
|
|
||||||
*/
|
|
@ -1,461 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
// 2006-02-17 Roman Stanchak <rstancha@cse.wustl.edu>
|
|
||||||
// 2006-07-19 Moved most operators to general/cvarr_operators.i for use with other languages
|
|
||||||
|
|
||||||
/*M//////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Macros for extending CvMat and IplImage -- primarily for operator overloading
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////M*/
|
|
||||||
|
|
||||||
// Macro to define octave function of form B = A.f(c)
|
|
||||||
// where A is a CvArr type, c and B are arbitrary types
|
|
||||||
%define %wrap_cvGeneric_CvArr(cname, rettype, octfunc, argtype, cvfunc, newobjcall)
|
|
||||||
%newobject cname::octfunc(argtype arg);
|
|
||||||
%extend cname {
|
|
||||||
rettype octfunc(argtype arg){
|
|
||||||
rettype retarg = newobjcall;
|
|
||||||
cvfunc;
|
|
||||||
return retarg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// Macro to define octave function of the form B = A.f(c)
|
|
||||||
// where A and B are both CvArr of same size and type
|
|
||||||
%define %wrap_cvArr_binaryop(octfunc, argtype, cvfunc)
|
|
||||||
%wrap_cvGeneric_CvArr(CvMat, CvMat *, octfunc, argtype, cvfunc,
|
|
||||||
cvCreateMat(self->rows, self->cols, self->type));
|
|
||||||
%wrap_cvGeneric_CvArr(IplImage, IplImage *, octfunc, argtype, cvfunc,
|
|
||||||
cvCreateImage(cvGetSize(self), self->depth, self->nChannels));
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// Macro to define octave function of the form A = A.f(c)
|
|
||||||
// where f modifies A inplace
|
|
||||||
// use for +=, etc
|
|
||||||
%define %wrap_cvGeneric_InPlace(cname, rettype, octfunc, argtype, cvfunc)
|
|
||||||
%wrap_cvGeneric_CvArr(cname, rettype, octfunc, argtype, cvfunc, self);
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
/*M//////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Macros to map operators to specific OpenCV functions
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////M*/
|
|
||||||
|
|
||||||
// map any OpenCV function of form cvFunc(src1, src2, dst)
|
|
||||||
%define %wrap_cvArith(octfunc, cvfunc)
|
|
||||||
%wrap_cvArr_binaryop(octfunc, CvArr *, cvfunc(self, arg, retarg));
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// map any OpenCV function of form cvFunc(src1, value, dst)
|
|
||||||
%define %wrap_cvArithS(octfunc, cvfuncS)
|
|
||||||
%wrap_cvArr_binaryop(octfunc, CvScalar, cvfuncS(self, arg, retarg));
|
|
||||||
%wrap_cvArr_binaryop(octfunc, double, cvfuncS(self, cvScalar(arg), retarg));
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// same as wrap_cvArith
|
|
||||||
%define %wrap_cvLogic(octfunc, cvfunc)
|
|
||||||
%wrap_cvArr_binaryop(octfunc, CvArr *, cvfunc(self, arg, retarg))
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// same as wrap_cvArithS
|
|
||||||
%define %wrap_cvLogicS(octfunc, cvfuncS)
|
|
||||||
%wrap_cvArr_binaryop(octfunc, CvScalar, cvfuncS(self, arg, retarg));
|
|
||||||
%wrap_cvArr_binaryop(octfunc, double, cvfuncS(self, cvScalar(arg), retarg));
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// Macro to map logical operations to cvCmp
|
|
||||||
%define %wrap_cvCmp(octfunc, cmp_op)
|
|
||||||
%wrap_cvGeneric_CvArr(CvMat, CvArr *, octfunc, CvMat *,
|
|
||||||
cvCmp(self, arg, retarg, cmp_op),
|
|
||||||
cvCreateMat(self->rows, self->cols, CV_8U));
|
|
||||||
%wrap_cvGeneric_CvArr(IplImage, CvArr *, octfunc, IplImage *,
|
|
||||||
cvCmp(self, arg, retarg, cmp_op),
|
|
||||||
cvCreateImage(cvGetSize(self), 8, 1));
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
%define %wrap_cvCmpS(octfunc, cmp_op)
|
|
||||||
%wrap_cvGeneric_CvArr(CvMat, CvArr *, octfunc, double,
|
|
||||||
cvCmpS(self, arg, retarg, cmp_op),
|
|
||||||
cvCreateMat(self->rows, self->cols, CV_8U));
|
|
||||||
%wrap_cvGeneric_CvArr(IplImage, CvArr *, octfunc, double,
|
|
||||||
cvCmpS(self, arg, retarg, cmp_op),
|
|
||||||
cvCreateImage(cvGetSize(self), 8, 1));
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// special case for cvScale, /, *
|
|
||||||
%define %wrap_cvScale(octfunc, scale)
|
|
||||||
%wrap_cvGeneric_CvArr(CvMat, CvArr *, octfunc, double,
|
|
||||||
cvScale(self, retarg, scale),
|
|
||||||
cvCreateMat(self->rows, self->cols, self->type));
|
|
||||||
%wrap_cvGeneric_CvArr(IplImage, CvArr *, octfunc, double,
|
|
||||||
cvScale(self, retarg, scale),
|
|
||||||
cvCreateImage(cvGetSize(self), self->depth, self->nChannels));
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
/*M//////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Actual Operator Declarations
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////M*/
|
|
||||||
|
|
||||||
// Arithmetic operators
|
|
||||||
%wrap_cvArith(__radd__, cvAdd);
|
|
||||||
|
|
||||||
// special case for reverse operations
|
|
||||||
%wrap_cvArr_binaryop(__rsub__, CvArr *, cvSub(arg, self, retarg));
|
|
||||||
%wrap_cvArr_binaryop(__rdiv__, CvArr *, cvDiv(arg, self, retarg));
|
|
||||||
%wrap_cvArr_binaryop(__rmul__, CvArr *, cvMatMul(arg, self, retarg));
|
|
||||||
|
|
||||||
%wrap_cvArithS(__radd__, cvAddS);
|
|
||||||
%wrap_cvArithS(__rsub__, cvSubRS);
|
|
||||||
|
|
||||||
|
|
||||||
%wrap_cvScale(__rmul__, arg);
|
|
||||||
%wrap_cvScale(__rdiv__, 1.0/arg);
|
|
||||||
|
|
||||||
%wrap_cvLogicS(__ror__, cvOrS)
|
|
||||||
%wrap_cvLogicS(__rand__, cvAndS)
|
|
||||||
%wrap_cvLogicS(__rxor__, cvXorS)
|
|
||||||
|
|
||||||
%wrap_cvCmpS(__req__, CV_CMP_EQ);
|
|
||||||
%wrap_cvCmpS(__rgt__, CV_CMP_GT);
|
|
||||||
%wrap_cvCmpS(__rge__, CV_CMP_GE);
|
|
||||||
%wrap_cvCmpS(__rlt__, CV_CMP_LT);
|
|
||||||
%wrap_cvCmpS(__rle__, CV_CMP_LE);
|
|
||||||
%wrap_cvCmpS(__rne__, CV_CMP_NE);
|
|
||||||
|
|
||||||
|
|
||||||
// misc operators for octave
|
|
||||||
%wrap_cvArr_binaryop(__pow__, double, cvPow(self, retarg, arg))
|
|
||||||
|
|
||||||
// TODO -- other Octave operators listed in SWIG/Octave docs (www.swig.org)
|
|
||||||
|
|
||||||
// __abs__ -- cvAbs
|
|
||||||
// __nonzero__
|
|
||||||
// __hash__ ??
|
|
||||||
// __repr__ -- full string representation
|
|
||||||
// __str__ -- compact representation
|
|
||||||
// __call__ -- ??
|
|
||||||
// __len__ -- number of rows? or elements?
|
|
||||||
// __iter__ -- ??
|
|
||||||
// __contains__ -- cvCmpS, cvMax ?
|
|
||||||
// __floordiv__ ??
|
|
||||||
// __mul__ -- cvGEMM
|
|
||||||
// __lshift__ -- ??
|
|
||||||
// __rshift__ -- ??
|
|
||||||
// __pow__ -- cvPow
|
|
||||||
|
|
||||||
// Called to implement the unary arithmetic operations (-, +, abs() and ~).
|
|
||||||
//__neg__( self)
|
|
||||||
//__pos__( self)
|
|
||||||
//__abs__( self)
|
|
||||||
//__invert__( self)
|
|
||||||
|
|
||||||
// Called to implement the built-in functions complex(), int(), long(), and float(). Should return a value of the appropriate type. Can I abuse this to return an array of the correct type??? scipy only allows return of length 1 arrays.
|
|
||||||
// __complex__( self )
|
|
||||||
// __int__( self )
|
|
||||||
// __long__( self )
|
|
||||||
// __float__( self )
|
|
||||||
|
|
||||||
/*M//////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Slice access and assignment for CvArr types
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////M*/
|
|
||||||
|
|
||||||
// TODO: CvMatND
|
|
||||||
|
|
||||||
%newobject CvMat::__paren(octave_value object);
|
|
||||||
%newobject _IplImage::__paren(octave_value object);
|
|
||||||
|
|
||||||
// Macro to check bounds of slice and throw error if outside
|
|
||||||
%define CHECK_SLICE_BOUNDS(rect,w,h,retval)
|
|
||||||
//printf("__setitem__ slice(%d:%d, %d:%d) array(%d,%d)", rect.x, rect.y, rect.x+rect.width, rect.y+rect.height, w, h);
|
|
||||||
if(rect.width<=0 || rect.height<=0 ||
|
|
||||||
rect.width>w || rect.height>h ||
|
|
||||||
rect.x<0 || rect.y<0 ||
|
|
||||||
rect.x>= w || rect.y >=h){
|
|
||||||
char errstr[256];
|
|
||||||
// previous function already set error string
|
|
||||||
if(rect.width==0 && rect.height==0 && rect.x==0 && rect.y==0) return retval;
|
|
||||||
sprintf(errstr, "Requested slice [ %d:%d %d:%d ] oversteps array sized [ %d %d ]",
|
|
||||||
rect.x, rect.y, rect.x+rect.width, rect.y+rect.height, w, h);
|
|
||||||
error(errstr);
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
else{}
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// slice access and assignment for CvMat
|
|
||||||
%extend CvMat
|
|
||||||
{
|
|
||||||
char * __str(){
|
|
||||||
static char str[8];
|
|
||||||
cvArrPrint( self );
|
|
||||||
str[0]=0;
|
|
||||||
return str;
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// scalar assignment
|
|
||||||
void __paren_asgn(octave_value object, double val){
|
|
||||||
CvMat tmp;
|
|
||||||
CvRect subrect = OctSlice_to_CvRect( self, object );
|
|
||||||
CHECK_SLICE_BOUNDS( subrect, self->cols, self->rows, );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
cvSet(&tmp, cvScalarAll(val));
|
|
||||||
}
|
|
||||||
void __paren_asgn(octave_value object, CvPoint val){
|
|
||||||
CvMat tmp;
|
|
||||||
CvRect subrect = OctSlice_to_CvRect( self, object );
|
|
||||||
CHECK_SLICE_BOUNDS( subrect, self->cols, self->rows, );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
cvSet(&tmp, cvScalar(val.x, val.y));
|
|
||||||
}
|
|
||||||
void __paren_asgn(octave_value object, CvPoint2D32f val){
|
|
||||||
CvMat tmp;
|
|
||||||
CvRect subrect = OctSlice_to_CvRect( self, object );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
CHECK_SLICE_BOUNDS( subrect, self->cols, self->rows, );
|
|
||||||
cvSet(&tmp, cvScalar(val.x, val.y));
|
|
||||||
}
|
|
||||||
void __paren_asgn(octave_value object, CvScalar val){
|
|
||||||
CvMat tmp;
|
|
||||||
CvRect subrect = OctSlice_to_CvRect( self, object );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
CHECK_SLICE_BOUNDS( subrect, self->cols, self->rows, );
|
|
||||||
cvSet(&tmp, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
// array slice assignment
|
|
||||||
void __paren_asgn(octave_value object, CvArr * arr){
|
|
||||||
CvMat tmp, src_stub, *src;
|
|
||||||
CvRect subrect = OctSlice_to_CvRect( self, object );
|
|
||||||
CHECK_SLICE_BOUNDS( subrect, self->cols, self->rows, );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
|
|
||||||
// Reshape source array to fit destination
|
|
||||||
// This will be used a lot for small arrays b/c
|
|
||||||
// OctObject_to_CvArr tries to compress a 2-D octave
|
|
||||||
// array with 1-4 columns into a multichannel vector
|
|
||||||
src=cvReshape(arr, &src_stub, CV_MAT_CN(tmp.type), tmp.rows);
|
|
||||||
|
|
||||||
cvConvert(src, &tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// slice access
|
|
||||||
octave_value __paren(octave_value object){
|
|
||||||
CvMat * mat;
|
|
||||||
CvRect subrect = OctSlice_to_CvRect( self, object );
|
|
||||||
CHECK_SLICE_BOUNDS( subrect, self->cols, self->rows, octave_value() );
|
|
||||||
if(subrect.width==1 && subrect.height==1){
|
|
||||||
CvScalar * s;
|
|
||||||
int type = cvGetElemType( self );
|
|
||||||
if(CV_MAT_CN(type) > 1){
|
|
||||||
s = new CvScalar;
|
|
||||||
*s = cvGet2D( self, subrect.y, subrect.x );
|
|
||||||
return SWIG_NewPointerObj( s, $descriptor(CvScalar *), 1 );
|
|
||||||
}
|
|
||||||
switch(CV_MAT_DEPTH(type)){
|
|
||||||
case CV_8U:
|
|
||||||
return OctLong_FromUnsignedLong( CV_MAT_ELEM(*self, uchar, subrect.y, subrect.x ) );
|
|
||||||
case CV_8S:
|
|
||||||
return OctLong_FromLong( CV_MAT_ELEM(*self, char, subrect.y, subrect.x ) );
|
|
||||||
case CV_16U:
|
|
||||||
return OctLong_FromUnsignedLong( CV_MAT_ELEM(*self, ushort, subrect.y, subrect.x ) );
|
|
||||||
case CV_16S:
|
|
||||||
return OctLong_FromLong( CV_MAT_ELEM(*self, short, subrect.y, subrect.x ) );
|
|
||||||
case CV_32S:
|
|
||||||
return OctLong_FromLong( CV_MAT_ELEM(*self, int, subrect.y, subrect.x ) );
|
|
||||||
case CV_32F:
|
|
||||||
return OctFloat_FromDouble( CV_MAT_ELEM(*self, float, subrect.y, subrect.x) );
|
|
||||||
case CV_64F:
|
|
||||||
return OctFloat_FromDouble( CV_MAT_ELEM(*self, double, subrect.y, subrect.x) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mat = (CvMat *) cvAlloc(sizeof(CvMat));
|
|
||||||
cvGetSubRect(self, mat, subrect);
|
|
||||||
|
|
||||||
// cvGetSubRect doesn't do this since it assumes mat lives on the stack
|
|
||||||
mat->hdr_refcount = self->hdr_refcount;
|
|
||||||
mat->refcount = self->refcount;
|
|
||||||
cvIncRefData(mat);
|
|
||||||
|
|
||||||
return SWIG_NewPointerObj( mat, $descriptor(CvMat *), 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
%octavecode %{
|
|
||||||
def __iter__(self):
|
|
||||||
"""
|
|
||||||
generator function iterating through rows in matrix or elements in vector
|
|
||||||
"""
|
|
||||||
if self.rows==1:
|
|
||||||
return self.colrange()
|
|
||||||
return self.rowrange()
|
|
||||||
|
|
||||||
def rowrange(self):
|
|
||||||
"""
|
|
||||||
generator function iterating along rows in matrix
|
|
||||||
"""
|
|
||||||
for i in range(self.rows):
|
|
||||||
yield self[i]
|
|
||||||
|
|
||||||
def colrange(self):
|
|
||||||
"""
|
|
||||||
generator function iterating along columns in matrix
|
|
||||||
"""
|
|
||||||
for i in range(self.cols):
|
|
||||||
yield self[:,i]
|
|
||||||
|
|
||||||
# if arg is None, octave still calls our operator overloads
|
|
||||||
# but we want
|
|
||||||
# if mat != None
|
|
||||||
# if mat == None
|
|
||||||
# to do the right thing -- so redefine __ne__ and __eq__
|
|
||||||
|
|
||||||
def __eq__(self, arg):
|
|
||||||
"""
|
|
||||||
__eq__(self, None)
|
|
||||||
__eq__(self, CvArr src)
|
|
||||||
__eq__(self, double val)
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not arg:
|
|
||||||
return False
|
|
||||||
return _cv.CvMat___eq__(self, arg)
|
|
||||||
def __ne__(self, arg):
|
|
||||||
"""
|
|
||||||
__ne__(self, None)
|
|
||||||
__ne__(self, CvArr src)
|
|
||||||
__ne__(self, double val)
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not arg:
|
|
||||||
return True
|
|
||||||
return _cv.CvMat___ne__(self, arg)
|
|
||||||
%}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// slice access and assignment for IplImage
|
|
||||||
%extend _IplImage
|
|
||||||
{
|
|
||||||
char * __str(){
|
|
||||||
static char str[8];
|
|
||||||
cvArrPrint( self );
|
|
||||||
str[0]=0;
|
|
||||||
return str;
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// scalar assignment
|
|
||||||
void __paren_asgn(octave_value object, double val){
|
|
||||||
CvMat tmp;
|
|
||||||
CvRect subrect = OctSlice_to_CvRect( self, object );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
cvSet(&tmp, cvScalarAll(val));
|
|
||||||
}
|
|
||||||
void __paren_asgn(octave_value object, CvPoint val){
|
|
||||||
CvMat tmp;
|
|
||||||
CvRect subrect = OctSlice_to_CvRect( self, object );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
cvSet(&tmp, cvScalar(val.x, val.y));
|
|
||||||
}
|
|
||||||
void __paren_asgn(octave_value object, CvPoint2D32f val){
|
|
||||||
CvMat tmp;
|
|
||||||
CvRect subrect = OctSlice_to_CvRect( self, object );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
cvSet(&tmp, cvScalar(val.x, val.y));
|
|
||||||
}
|
|
||||||
void __paren_asgn(octave_value object, CvScalar val){
|
|
||||||
CvMat tmp;
|
|
||||||
CvRect subrect = OctSlice_to_CvRect( self, object );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
cvSet(&tmp, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
// array slice assignment
|
|
||||||
void __paren_asgn(octave_value object, CvArr * arr){
|
|
||||||
CvMat tmp;
|
|
||||||
CvRect subrect = OctSlice_to_CvRect( self, object );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
cvConvert(arr, &tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// slice access
|
|
||||||
octave_value __paren(octave_value object){
|
|
||||||
CvMat mat;
|
|
||||||
IplImage * im;
|
|
||||||
CvRect subrect = OctSlice_to_CvRect( self, object );
|
|
||||||
|
|
||||||
// return scalar if single element
|
|
||||||
if(subrect.width==1 && subrect.height==1){
|
|
||||||
CvScalar * s;
|
|
||||||
int type = cvGetElemType( self );
|
|
||||||
if(CV_MAT_CN(type) > 1){
|
|
||||||
s = new CvScalar;
|
|
||||||
*s = cvGet2D( self, subrect.y, subrect.x );
|
|
||||||
return SWIG_NewPointerObj( s, $descriptor(CvScalar *), 1 );
|
|
||||||
}
|
|
||||||
switch(CV_MAT_DEPTH(type)){
|
|
||||||
case CV_8U:
|
|
||||||
return OctLong_FromUnsignedLong( CV_IMAGE_ELEM(self, uchar, subrect.y, subrect.x ) );
|
|
||||||
case CV_8S:
|
|
||||||
return OctLong_FromLong( CV_IMAGE_ELEM(self, char, subrect.y, subrect.x ) );
|
|
||||||
case CV_16U:
|
|
||||||
return OctLong_FromUnsignedLong( CV_IMAGE_ELEM(self, ushort, subrect.y, subrect.x ) );
|
|
||||||
case CV_16S:
|
|
||||||
return OctLong_FromLong( CV_IMAGE_ELEM(self, short, subrect.y, subrect.x ) );
|
|
||||||
case CV_32S:
|
|
||||||
return OctLong_FromLong( CV_IMAGE_ELEM(self, int, subrect.y, subrect.x ) );
|
|
||||||
case CV_32F:
|
|
||||||
return OctFloat_FromDouble( CV_IMAGE_ELEM(self, float, subrect.y, subrect.x) );
|
|
||||||
case CV_64F:
|
|
||||||
return OctFloat_FromDouble( CV_IMAGE_ELEM(self, double, subrect.y, subrect.x) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// otherwise return array
|
|
||||||
im = (IplImage *) cvAlloc(sizeof(IplImage));
|
|
||||||
cvGetSubRect(self, &mat, subrect);
|
|
||||||
im = cvGetImage(&mat, im);
|
|
||||||
return SWIG_NewPointerObj( im, $descriptor(_IplImage *), 1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
// 2006-08-02 Roman Stanchak <rstancha@cse.wustl.edu>
|
|
||||||
|
|
||||||
%include "octcvseq.hpp"
|
|
||||||
%template (CvTuple_CvPoint_2) CvTuple<CvPoint,2>;
|
|
||||||
%template (CvTuple_float_2) CvTuple<float,2>;
|
|
||||||
%template (CvTuple_float_3) CvTuple<float,3>;
|
|
||||||
|
|
||||||
%template (CvSeq_CvPoint) CvTypedSeq<CvPoint>;
|
|
||||||
%template (CvSeq_CvPoint2D32f) CvTypedSeq<CvPoint2D32f>;
|
|
||||||
%template (CvSeq_CvRect) CvTypedSeq<CvRect>;
|
|
||||||
%template (CvSeq_CvSeq) CvTypedSeq<CvSeq *>;
|
|
||||||
%template (CvSeq_CvQuadEdge2D) CvTypedSeq<CvQuadEdge2D>;
|
|
||||||
%template (CvSeq_CvConnectedComp) CvTypedSeq<CvConnectedComp>;
|
|
||||||
%template (CvSeq_CvPoint_2) CvTypedSeq< CvTuple<CvPoint,2> >;
|
|
||||||
%template (CvSeq_float_2) CvTypedSeq< CvTuple<float,2> >;
|
|
||||||
%template (CvSeq_float_3) CvTypedSeq< CvTuple<float,3> >;
|
|
||||||
|
|
||||||
// accessor to turn edges into a typed sequence
|
|
||||||
%extend CvSubdiv2D {
|
|
||||||
CvTypedSeq<CvQuadEdge2D> * typed_edges;
|
|
||||||
CvTypedSeq<CvQuadEdge2D> * typed_edges_get(){
|
|
||||||
return (CvTypedSeq<CvQuadEdge2D> *) self->edges;
|
|
||||||
}
|
|
||||||
void typed_edges_set( CvTypedSeq<CvQuadEdge2D> * ){
|
|
||||||
}
|
|
||||||
/* add iterator support to octave...
|
|
||||||
%pythoncode %{
|
|
||||||
def __iter__(self):
|
|
||||||
s = CvSeq_QuadEdge2D.cast(self)
|
|
||||||
for i in range(s.total):
|
|
||||||
yield s[i]
|
|
||||||
%}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
@ -1,85 +0,0 @@
|
|||||||
#include <cxcore.h>
|
|
||||||
#include <cv.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "cvshadow.h"
|
|
||||||
|
|
||||||
CvArr * cvCvtSeqToArray_Shadow( const CvSeq* seq, CvArr * elements, CvSlice slice){
|
|
||||||
CvMat stub, *mat=(CvMat *)elements;
|
|
||||||
if(!CV_IS_MAT(mat)){
|
|
||||||
mat = cvGetMat(elements, &stub);
|
|
||||||
}
|
|
||||||
cvCvtSeqToArray( seq, mat->data.ptr, slice );
|
|
||||||
return elements;
|
|
||||||
}
|
|
||||||
|
|
||||||
double cvArcLength_Shadow( const CvSeq * seq, CvSlice slice, int is_closed){
|
|
||||||
return cvArcLength( seq, slice, is_closed );
|
|
||||||
}
|
|
||||||
double cvArcLength_Shadow( const CvArr * arr, CvSlice slice, int is_closed){
|
|
||||||
return cvArcLength( arr, slice, is_closed );
|
|
||||||
}
|
|
||||||
|
|
||||||
CvTypedSeq<CvRect> * cvHaarDetectObjects_Shadow( const CvArr* image, CvHaarClassifierCascade* cascade,
|
|
||||||
CvMemStorage* storage, double scale_factor, int min_neighbors, int flags,
|
|
||||||
CvSize min_size )
|
|
||||||
{
|
|
||||||
return (CvTypedSeq<CvRect> *) cvHaarDetectObjects( image, cascade, storage, scale_factor,
|
|
||||||
min_neighbors, flags, min_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
CvTypedSeq<CvConnectedComp> * cvSegmentMotion_Shadow( const CvArr* mhi, CvArr* seg_mask, CvMemStorage* storage,
|
|
||||||
double timestamp, double seg_thresh ){
|
|
||||||
return (CvTypedSeq<CvConnectedComp> *) cvSegmentMotion( mhi, seg_mask, storage, timestamp, seg_thresh );
|
|
||||||
}
|
|
||||||
|
|
||||||
CvTypedSeq<CvPoint> * cvApproxPoly_Shadow( const void* src_seq, int header_size, CvMemStorage* storage,
|
|
||||||
int method, double parameter, int parameter2)
|
|
||||||
{
|
|
||||||
return (CvTypedSeq<CvPoint> *) cvApproxPoly( src_seq, header_size, storage, method, parameter, parameter2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Always return a new Mat of indices
|
|
||||||
CvMat * cvConvexHull2_Shadow( const CvArr * points, int orientation, int return_points){
|
|
||||||
CvMat * hull;
|
|
||||||
CvMat * points_mat=(CvMat *) points;
|
|
||||||
CvSeq * points_seq=(CvSeq *) points;
|
|
||||||
int npoints, type;
|
|
||||||
|
|
||||||
CV_FUNCNAME("cvConvexHull2");
|
|
||||||
|
|
||||||
__BEGIN__;
|
|
||||||
|
|
||||||
if(CV_IS_MAT(points_mat)){
|
|
||||||
npoints = MAX(points_mat->rows, points_mat->cols);
|
|
||||||
type = return_points ? points_mat->type : CV_32S;
|
|
||||||
}
|
|
||||||
else if(CV_IS_SEQ(points_seq)){
|
|
||||||
npoints = points_seq->total;
|
|
||||||
type = return_points ? CV_SEQ_ELTYPE(points_seq) : 1;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
CV_ERROR(CV_StsBadArg, "points must be a CvSeq or CvMat");
|
|
||||||
}
|
|
||||||
CV_CALL( hull=cvCreateMat(1,npoints,type) );
|
|
||||||
CV_CALL( cvConvexHull2(points, hull, orientation, return_points) );
|
|
||||||
|
|
||||||
__END__;
|
|
||||||
return hull;
|
|
||||||
}
|
|
||||||
std::vector<CvPoint> cvSnakeImage_Shadow( const CvMat * image, std::vector<CvPoint> points,
|
|
||||||
std::vector<float> alpha, std::vector<float> beta,
|
|
||||||
std::vector<float> gamma,
|
|
||||||
CvSize win, CvTermCriteria criteria, int calc_gradient ){
|
|
||||||
IplImage ipl_stub;
|
|
||||||
CV_FUNCNAME("cvSnakeImage_Shadow");
|
|
||||||
|
|
||||||
__BEGIN__;
|
|
||||||
|
|
||||||
cvSnakeImage( cvGetImage(image, &ipl_stub), &(points[0]), points.size(),
|
|
||||||
&((alpha)[0]), &((beta)[0]), &((gamma)[0]),
|
|
||||||
(alpha.size()>1 && beta.size()>1 && gamma.size()>1 ? CV_ARRAY : CV_VALUE),
|
|
||||||
win, criteria, calc_gradient );
|
|
||||||
|
|
||||||
__END__;
|
|
||||||
return points;
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
#ifndef CV_SHADOW_H
|
|
||||||
#define CV_SHADOW_H
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include "cxtypes.h"
|
|
||||||
#include "cvtypes.h"
|
|
||||||
#include "octcvseq.hpp"
|
|
||||||
|
|
||||||
// modify cvCvtSeqToArray to take CvArr as input instead of raw data
|
|
||||||
CvArr * cvCvtSeqToArray_Shadow( const CvSeq* seq, CvArr * elements, CvSlice slice=CV_WHOLE_SEQ);
|
|
||||||
|
|
||||||
// formally overload ArcLength and cvContourPerimeter
|
|
||||||
double cvArcLength_Shadow( const CvSeq * seq, CvSlice slice=CV_WHOLE_SEQ, int is_closed=-1);
|
|
||||||
double cvArcLength_Shadow( const CvArr * arr, CvSlice slice=CV_WHOLE_SEQ, int is_closed=-1);
|
|
||||||
|
|
||||||
// cvContourPerimeter is a macro, but this still works
|
|
||||||
static double cvContourPerimeter_Shadow(CvSeq * seq){ return cvContourPerimeter( seq ); }
|
|
||||||
static double cvContourPerimeter_Shadow(CvArr * arr){ return cvContourPerimeter( arr ); }
|
|
||||||
|
|
||||||
// Return a typed sequence instead of generic CvSeq
|
|
||||||
CvTypedSeq<CvRect> * cvHaarDetectObjects_Shadow( const CvArr* image, CvHaarClassifierCascade* cascade,
|
|
||||||
CvMemStorage* storage, double scale_factor=1.1, int min_neighbors=3, int flags=0,
|
|
||||||
CvSize min_size=cvSize(0,0) );
|
|
||||||
CvTypedSeq<CvConnectedComp> * cvSegmentMotion_Shadow( const CvArr* mhi, CvArr* seg_mask, CvMemStorage* storage,
|
|
||||||
double timestamp, double seg_thresh );
|
|
||||||
CvTypedSeq<CvPoint> * cvApproxPoly_Shadow( const void* src_seq, int header_size, CvMemStorage* storage,
|
|
||||||
int method, double parameter, int parameter2=0);
|
|
||||||
|
|
||||||
// Always return a new Mat of indices
|
|
||||||
CvMat * cvConvexHull2_Shadow( const CvArr * points, int orientation=CV_CLOCKWISE,
|
|
||||||
int return_points=0);
|
|
||||||
|
|
||||||
std::vector<CvPoint> cvSnakeImage_Shadow( const CvMat * image, std::vector<CvPoint> points,
|
|
||||||
std::vector<float> alpha, std::vector<float> beta, std::vector<float> gamma,
|
|
||||||
CvSize win, CvTermCriteria criteria, int calc_gradient=1 );
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,138 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
/* This file contains custom python shadow class code for certain troublesome functions */
|
|
||||||
|
|
||||||
%{
|
|
||||||
#include "cvshadow.h"
|
|
||||||
%}
|
|
||||||
|
|
||||||
%define %myshadow(function)
|
|
||||||
%ignore function;
|
|
||||||
%rename (function) function##_Shadow;
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
%include "stl.i"
|
|
||||||
|
|
||||||
// %ignore, %rename must come before %include
|
|
||||||
%myshadow(cvCvtSeqToArray);
|
|
||||||
%myshadow(cvArcLength);
|
|
||||||
%myshadow(cvHaarDetectObjects);
|
|
||||||
%myshadow(cvSegmentMotion);
|
|
||||||
%myshadow(cvApproxPoly);
|
|
||||||
%myshadow(cvContourPerimeter);
|
|
||||||
%myshadow(cvConvexHull2);
|
|
||||||
%newobject cvConvexHull2; // shadowed functioned always returns new object
|
|
||||||
|
|
||||||
/* cvSnakeImage shadow uses a vector<CvPoint> and vector<float> */
|
|
||||||
%template(FloatVector) std::vector<float>;
|
|
||||||
%template(CvPointVector) std::vector<CvPoint>;
|
|
||||||
%myshadow(cvSnakeImage);
|
|
||||||
|
|
||||||
// eliminates need for IplImage ** typemap
|
|
||||||
%rename (cvCalcImageHist) cvCalcHist;
|
|
||||||
|
|
||||||
// must come after %ignore, %rename
|
|
||||||
%include "cvshadow.h"
|
|
||||||
|
|
||||||
/* return a typed CvSeq instead of generic for CvSubdiv2D edges -- see cvseq.i */
|
|
||||||
%rename (untyped_edges) CvSubdiv2D::edges;
|
|
||||||
%ignore CvSubdiv2D::edges;
|
|
||||||
%rename (edges) CvSubdiv2D::typed_edges;
|
|
||||||
|
|
||||||
/* Octave doesn't know what to do with these */
|
|
||||||
%rename (asIplImage) operator IplImage*;
|
|
||||||
%rename (asCvMat) operator CvMat*;
|
|
||||||
%ignore operator const IplImage*;
|
|
||||||
%ignore operator const CvMat*;
|
|
||||||
|
|
||||||
/* Define sequence type for functions returning sequences */
|
|
||||||
%define %cast_seq( cvfunc, type )
|
|
||||||
%rename (cvfunc##Untyped) cvfunc;
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
%cast_seq( cvHoughCircles, CvSeq_float_3 );
|
|
||||||
%cast_seq( cvPyrSegmentation, CvSeq_CvConnectedComp );
|
|
||||||
%cast_seq( cvApproxChains, CvSeq_CvPoint);
|
|
||||||
%cast_seq( cvContourFromContourTree, CvSeq_CvPoint );
|
|
||||||
%cast_seq( cvConvexityDefects, CvSeq_CvConvexityDefect );
|
|
||||||
|
|
||||||
/* Special cases ... */
|
|
||||||
%rename(cvFindContoursUntyped) cvFindContours;
|
|
||||||
|
|
||||||
/* cvHoughLines2 returns a different type of sequence depending on its args */
|
|
||||||
%rename (cvHoughLinesUntyped) cvHoughLines2;
|
|
||||||
|
|
||||||
// cvPointSeqFromMat
|
|
||||||
// cvSeqPartition
|
|
||||||
// cvSeqSlice
|
|
||||||
// cvTreeToNodeSeq
|
|
||||||
|
|
||||||
/*
|
|
||||||
// cvRelease* functions don't consider Octave's reference count
|
|
||||||
// so we get a double-free error when the reference count reaches zero.
|
|
||||||
// Instead, make these no-ops.
|
|
||||||
%define %myrelease(function)
|
|
||||||
%ignore function;
|
|
||||||
%rename (function) function##_Shadow;
|
|
||||||
%inline %{
|
|
||||||
void function##_Shadow(PyObject * obj){
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
%myrelease(cvReleaseImage);
|
|
||||||
%myrelease(cvReleaseMat);
|
|
||||||
%myrelease(cvReleaseStructuringElement);
|
|
||||||
%myrelease(cvReleaseKalman);
|
|
||||||
%myrelease(cvReleaseHist);
|
|
||||||
%myrelease(cvReleaseHaarClassifierCascade);
|
|
||||||
%myrelease(cvReleasePOSITObject);
|
|
||||||
%myrelease(cvReleaseImageHeader);
|
|
||||||
%myrelease(cvReleaseMatND);
|
|
||||||
%myrelease(cvReleaseSparseMat);
|
|
||||||
%myrelease(cvReleaseMemStorage);
|
|
||||||
%myrelease(cvReleaseGraphScanner);
|
|
||||||
%myrelease(cvReleaseFileStorage);
|
|
||||||
%myrelease(cvRelease);
|
|
||||||
%myrelease(cvReleaseCapture);
|
|
||||||
%myrelease(cvReleaseVideoWriter);
|
|
||||||
*/
|
|
@ -1,191 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
|
|
||||||
// 2004-03-16, Gabriel Schreiber <schreiber@ient.rwth-aachen.de>
|
|
||||||
// Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
// Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
// 2008-04-09 Xavier Delacour <xavier.delacour@gmail.com>
|
|
||||||
|
|
||||||
// todo remove these..
|
|
||||||
#pragma SWIG nowarn=312,362,303,365,366,367,368,370,371,372,451,454,503
|
|
||||||
|
|
||||||
%{
|
|
||||||
#include <cxtypes.h>
|
|
||||||
#include <cv.h>
|
|
||||||
#include <highgui.h>
|
|
||||||
#include "octhelpers.h"
|
|
||||||
#include "octcvseq.hpp"
|
|
||||||
%}
|
|
||||||
|
|
||||||
// include octave-specific files
|
|
||||||
%include "./octtypemaps.i"
|
|
||||||
%include "exception.i"
|
|
||||||
|
|
||||||
// the wrapping code to enable the use of Octave-based mouse callbacks
|
|
||||||
%{
|
|
||||||
// This encapsulates the octave callback and user_data for mouse callback
|
|
||||||
struct OctCvMouseCBData {
|
|
||||||
octave_value oct_func;
|
|
||||||
octave_value user_data;
|
|
||||||
};
|
|
||||||
// This encapsulates the octave callback and user_data for mouse callback
|
|
||||||
// C helper function which is responsible for calling
|
|
||||||
// the Octave real trackbar callback function
|
|
||||||
static void icvOctOnMouse (int event, int x, int y,
|
|
||||||
int flags, OctCvMouseCBData * param) {
|
|
||||||
octave_value oct_func(param->oct_func);
|
|
||||||
if (!oct_func.is_function() && !oct_func.is_function_handle())
|
|
||||||
return;
|
|
||||||
|
|
||||||
octave_value_list args;
|
|
||||||
args.append(octave_value(event));
|
|
||||||
args.append(octave_value(x));
|
|
||||||
args.append(octave_value(y));
|
|
||||||
args.append(octave_value(flags));
|
|
||||||
args.append(param->user_data);
|
|
||||||
oct_func.subsref ("(", std::list<octave_value_list>(1, args), 0);
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
|
|
||||||
// adapt cvSetMouseCallback to use octave callback
|
|
||||||
%rename (cvSetMouseCallbackOld) cvSetMouseCallback;
|
|
||||||
%rename (cvSetMouseCallback) cvSetMouseCallbackOct;
|
|
||||||
%inline {
|
|
||||||
void cvSetMouseCallbackOct( const char* window_name, octave_value on_mouse, octave_value param = octave_value() ){
|
|
||||||
OctCvMouseCBData * oct_callback = new OctCvMouseCBData;
|
|
||||||
oct_callback->oct_func = on_mouse;
|
|
||||||
oct_callback->user_data = param;
|
|
||||||
cvSetMouseCallback( window_name, (CvMouseCallback) icvOctOnMouse, (void *) oct_callback );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The following code enables trackbar callbacks from octave. Unfortunately, there is no
|
|
||||||
// way to distinguish which trackbar the event originated from, so must hard code a
|
|
||||||
// fixed number of unique c callback functions using the macros below
|
|
||||||
%{
|
|
||||||
// C helper function which is responsible for calling
|
|
||||||
// the Octave real trackbar callback function
|
|
||||||
static void icvOctOnTrackbar( octave_value oct_cb_func, int pos) {
|
|
||||||
if (!oct_cb_func.is_function() && !oct_cb_func.is_function_handle())
|
|
||||||
return;
|
|
||||||
|
|
||||||
octave_value_list args;
|
|
||||||
args.append(octave_value(pos));
|
|
||||||
oct_cb_func.subsref ("(", std::list<octave_value_list>(1, args), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ICV_OCT_MAX_CB 10
|
|
||||||
|
|
||||||
struct OctCvTrackbar {
|
|
||||||
CvTrackbarCallback cv_func;
|
|
||||||
octave_value oct_func;
|
|
||||||
octave_value oct_pos;
|
|
||||||
};
|
|
||||||
|
|
||||||
static int my_trackbar_cb_size=0;
|
|
||||||
extern OctCvTrackbar my_trackbar_cb_funcs[ICV_OCT_MAX_CB];
|
|
||||||
%}
|
|
||||||
|
|
||||||
// Callback table entry
|
|
||||||
%define %ICV_OCT_CB_TAB_ENTRY(idx)
|
|
||||||
{(CvTrackbarCallback) icvOctTrackbarCB##idx, octave_value(), octave_value() }
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// Table of callbacks
|
|
||||||
%define %ICV_OCT_CB_TAB
|
|
||||||
%{
|
|
||||||
OctCvTrackbar my_trackbar_cb_funcs[ICV_OCT_MAX_CB] = {
|
|
||||||
%ICV_OCT_CB_TAB_ENTRY(0),
|
|
||||||
%ICV_OCT_CB_TAB_ENTRY(1),
|
|
||||||
%ICV_OCT_CB_TAB_ENTRY(2),
|
|
||||||
%ICV_OCT_CB_TAB_ENTRY(3),
|
|
||||||
%ICV_OCT_CB_TAB_ENTRY(4),
|
|
||||||
%ICV_OCT_CB_TAB_ENTRY(5),
|
|
||||||
%ICV_OCT_CB_TAB_ENTRY(6),
|
|
||||||
%ICV_OCT_CB_TAB_ENTRY(7),
|
|
||||||
%ICV_OCT_CB_TAB_ENTRY(8),
|
|
||||||
%ICV_OCT_CB_TAB_ENTRY(9)
|
|
||||||
};
|
|
||||||
%}
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// Callback definition
|
|
||||||
%define %ICV_OCT_CB_IMPL(idx)
|
|
||||||
%{
|
|
||||||
static void icvOctTrackbarCB##idx(int pos){
|
|
||||||
icvOctOnTrackbar(my_trackbar_cb_funcs[idx].oct_func, pos);
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
%ICV_OCT_CB_IMPL(0);
|
|
||||||
%ICV_OCT_CB_IMPL(1);
|
|
||||||
%ICV_OCT_CB_IMPL(2);
|
|
||||||
%ICV_OCT_CB_IMPL(3);
|
|
||||||
%ICV_OCT_CB_IMPL(4);
|
|
||||||
%ICV_OCT_CB_IMPL(5);
|
|
||||||
%ICV_OCT_CB_IMPL(6);
|
|
||||||
%ICV_OCT_CB_IMPL(7);
|
|
||||||
%ICV_OCT_CB_IMPL(8);
|
|
||||||
%ICV_OCT_CB_IMPL(9);
|
|
||||||
|
|
||||||
%ICV_OCT_CB_TAB;
|
|
||||||
|
|
||||||
// typemap to memorize the Octave callback when doing cvCreateTrackbar ()
|
|
||||||
%typemap(in) CvTrackbarCallback {
|
|
||||||
if(my_trackbar_cb_size == ICV_OCT_MAX_CB){
|
|
||||||
SWIG_exception(SWIG_IndexError, "Exceeded maximum number of trackbars");
|
|
||||||
}
|
|
||||||
|
|
||||||
my_trackbar_cb_size++;
|
|
||||||
|
|
||||||
// memorize the Octave address of the callback function
|
|
||||||
my_trackbar_cb_funcs[my_trackbar_cb_size-1].oct_func = (octave_value) $input;
|
|
||||||
|
|
||||||
// prepare to call the C function who will register the callback
|
|
||||||
$1 = my_trackbar_cb_funcs[ my_trackbar_cb_size-1 ].cv_func;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
%include "../general/highgui.i"
|
|
||||||
%include "adapters.i"
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -1,152 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
|
|
||||||
// 2004-03-16, Gabriel Schreiber <schreiber@ient.rwth-aachen.de>
|
|
||||||
// Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
// Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
|
|
||||||
// 2006-08-29 Roman Stanchak -- converted to use CvMat rather than IplImage
|
|
||||||
|
|
||||||
|
|
||||||
%{
|
|
||||||
|
|
||||||
/// Accessor to convert a Octave string into the imageData.
|
|
||||||
void CvMat_imageData_set(CvMat * self, octave_value object)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
char* oct_string = OctString_AsString(object);
|
|
||||||
int depth = CV_MAT_DEPTH(self->type);
|
|
||||||
int cn = CV_MAT_CN(self->type);
|
|
||||||
|
|
||||||
if (depth == CV_8U && cn==3){
|
|
||||||
// RGB case
|
|
||||||
// The data is reordered beause OpenCV uses BGR instead of RGB
|
|
||||||
|
|
||||||
for (long line = 0; line < self->rows; ++line)
|
|
||||||
for (long pixel = 0; pixel < self->cols; ++pixel)
|
|
||||||
{
|
|
||||||
// In OpenCV the beginning of the lines are aligned
|
|
||||||
// to 4 Bytes. So use step instead of cols.
|
|
||||||
long position = line*self->step + pixel*3;
|
|
||||||
long sourcepos = line*self->cols*3 + pixel*3;
|
|
||||||
self->data.ptr[position ] = oct_string[sourcepos+2];
|
|
||||||
self->data.ptr[position+1] = oct_string[sourcepos+1];
|
|
||||||
self->data.ptr[position+2] = oct_string[sourcepos ];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (depth == CV_8U && cn==1)
|
|
||||||
{
|
|
||||||
// Grayscale 8bit case
|
|
||||||
|
|
||||||
for (long line = 0; line < self->rows; ++line)
|
|
||||||
{
|
|
||||||
// In OpenCV the beginning of the lines are aligned
|
|
||||||
// to 4 Bytes. So use step instead of cols.
|
|
||||||
memcpy
|
|
||||||
(
|
|
||||||
self->data.ptr + line*self->step,
|
|
||||||
oct_string + line*self->cols,
|
|
||||||
self->step
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( depth == CV_32F )
|
|
||||||
{
|
|
||||||
// float (32bit) case
|
|
||||||
for (long line = 0; line < self->rows; ++line)
|
|
||||||
{
|
|
||||||
// here we don not have to care about alignment as the Floats are
|
|
||||||
// as long as the alignment
|
|
||||||
memcpy
|
|
||||||
(
|
|
||||||
self->data.ptr + line*self->step,
|
|
||||||
oct_string + line*self->cols*sizeof(float),
|
|
||||||
self->step
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( depth == CV_64F )
|
|
||||||
{
|
|
||||||
// double (64bit) case
|
|
||||||
for (long line = 0; line < self->rows; ++line)
|
|
||||||
{
|
|
||||||
// here we don not have to care about alignment as the Floats are
|
|
||||||
// as long as the alignment
|
|
||||||
memcpy
|
|
||||||
(
|
|
||||||
self->data.ptr + line*self->step,
|
|
||||||
oct_string + line*self->cols*sizeof(double),
|
|
||||||
self->step
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// make some noise
|
|
||||||
SendErrorToOctave (SWIG_TypeError,
|
|
||||||
"CvMat_imageData_set",
|
|
||||||
"cannot convert string data to this image format",
|
|
||||||
__FILE__, __LINE__, NULL);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Accessor to convert the imageData into a Octave string.
|
|
||||||
octave_value CvMat_imageData_get(CvMat * self)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
if (!self->data.ptr)
|
|
||||||
{
|
|
||||||
OctErr_SetString(OctExc_TypeError, "Data pointer of CvMat is NULL");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return OctString_FromStringAndSize((const char *)self->data.ptr, self->rows*self->step);
|
|
||||||
*/
|
|
||||||
return octave_value();
|
|
||||||
}
|
|
||||||
|
|
||||||
%}
|
|
||||||
|
|
||||||
// add virtual member variable to CvMat
|
|
||||||
%extend CvMat {
|
|
||||||
octave_value imageData;
|
|
||||||
};
|
|
@ -1,98 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
|
|
||||||
// 2004-03-16, Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
// Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
|
|
||||||
%module(package="opencv") ml
|
|
||||||
|
|
||||||
// todo remove these..
|
|
||||||
#pragma SWIG nowarn=312,362,303,365,366,367,368,370,371,372,451,454,503
|
|
||||||
|
|
||||||
%{
|
|
||||||
#include <ml.h>
|
|
||||||
#include <cxtypes.h>
|
|
||||||
#include <cv.h>
|
|
||||||
#include <highgui.h>
|
|
||||||
#include "octhelpers.h"
|
|
||||||
#include "octcvseq.hpp"
|
|
||||||
%}
|
|
||||||
|
|
||||||
// include octave-specific files
|
|
||||||
%include "./octtypemaps.i"
|
|
||||||
%include "exception.i"
|
|
||||||
|
|
||||||
%import "../general/cv.i"
|
|
||||||
|
|
||||||
%include "../general/memory.i"
|
|
||||||
%include "../general/typemaps.i"
|
|
||||||
|
|
||||||
%newobject cvCreateCNNConvolutionLayer;
|
|
||||||
%newobject cvCreateCNNSubSamplingLayer;
|
|
||||||
%newobject cvCreateCNNFullConnectLayer;
|
|
||||||
%newobject cvCreateCNNetwork;
|
|
||||||
%newobject cvTrainCNNClassifier;
|
|
||||||
|
|
||||||
%newobject cvCreateCrossValidationEstimateModel;
|
|
||||||
|
|
||||||
|
|
||||||
%extend CvEM
|
|
||||||
{
|
|
||||||
octave_value get_covs()
|
|
||||||
{
|
|
||||||
CvMat ** pointers = const_cast<CvMat **> (self->get_covs());
|
|
||||||
int n = self->get_nclusters();
|
|
||||||
|
|
||||||
octave_value result = OctTuple_New(n);
|
|
||||||
for (int i=0; i<n; ++i)
|
|
||||||
{
|
|
||||||
octave_value obj = SWIG_NewPointerObj(pointers[i], $descriptor(CvMat *), 0);
|
|
||||||
OctTuple_SetItem(result, i, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
%ignore CvEM::get_covs;
|
|
||||||
|
|
||||||
%include "ml.h"
|
|
File diff suppressed because it is too large
Load Diff
@ -1,120 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
#ifndef OCT_CV_SEQ_H
|
|
||||||
#define OCT_CV_SEQ_H
|
|
||||||
|
|
||||||
#include "cxcore.h"
|
|
||||||
#include "cvtypes.h"
|
|
||||||
|
|
||||||
|
|
||||||
/** class to make sequence iteration nicer */
|
|
||||||
template<class T>
|
|
||||||
class CvTypedSeqReader : public CvSeqReader {
|
|
||||||
int pos;
|
|
||||||
public:
|
|
||||||
CvTypedSeqReader( const CvSeq * seq ){
|
|
||||||
cvStartReadSeq( seq, this );
|
|
||||||
pos = 0;
|
|
||||||
}
|
|
||||||
T * current(){
|
|
||||||
return (T*) this->ptr;
|
|
||||||
}
|
|
||||||
void next(){
|
|
||||||
CV_NEXT_SEQ_ELEM( this->seq->elem_size, *this );
|
|
||||||
pos++;
|
|
||||||
}
|
|
||||||
bool valid(){
|
|
||||||
return pos<this->seq->total;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
class CvTypedSeq : public CvSeq {
|
|
||||||
public:
|
|
||||||
static CvTypedSeq<T> * cast(CvSeq * seq){
|
|
||||||
return (CvTypedSeq<T> *) seq;
|
|
||||||
}
|
|
||||||
T * __paren (int i){
|
|
||||||
return (T *) cvGetSeqElem(this, i);
|
|
||||||
}
|
|
||||||
void __paren_asgn (int i, T * obj){
|
|
||||||
T * ptr = this->__paren(i);
|
|
||||||
memcpy(ptr, obj, sizeof(T));
|
|
||||||
}
|
|
||||||
|
|
||||||
T * __brace (int i){
|
|
||||||
return __paren(i);
|
|
||||||
}
|
|
||||||
void __brace_asgn (int i, T * obj){
|
|
||||||
__paren_asgn(i, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
void append(T * obj){
|
|
||||||
cvSeqPush( this, obj );
|
|
||||||
}
|
|
||||||
T * pop(){
|
|
||||||
T * obj = new T;
|
|
||||||
cvSeqPop( this, obj );
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T, int size=2>
|
|
||||||
struct CvTuple {
|
|
||||||
T val[2];
|
|
||||||
const T & __paren(int i){
|
|
||||||
return val[i];
|
|
||||||
}
|
|
||||||
void __paren_asgn(int i, T * obj){
|
|
||||||
val[i] = *obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
const T & __brace(int i){
|
|
||||||
return __paren(i);
|
|
||||||
}
|
|
||||||
void __brace_asgn(int i, T * obj){
|
|
||||||
return __paren_asgn(i,obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //OCT_CV_SEQ_H
|
|
@ -1,109 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
|
|
||||||
// 2004-03-17, Gabriel Schreiber <schreiber@ient.rwth-aachen.de>
|
|
||||||
// Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
// Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
// 2008-04-19, Xavier Delacour <xavier.delacour@gmail.com>
|
|
||||||
|
|
||||||
|
|
||||||
#include "octerror.h"
|
|
||||||
#include <sstream>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <octave/oct.h>
|
|
||||||
|
|
||||||
// OpenCV headers
|
|
||||||
#include "cxcore.h"
|
|
||||||
#include "cxerror.h"
|
|
||||||
|
|
||||||
|
|
||||||
//=========================================================================
|
|
||||||
int SendErrorToOctave
|
|
||||||
(
|
|
||||||
int status,
|
|
||||||
const char* func_name,
|
|
||||||
const char* err_msg,
|
|
||||||
const char* file_name,
|
|
||||||
int line,
|
|
||||||
void* /*userdata*/
|
|
||||||
)
|
|
||||||
throw(int)
|
|
||||||
{
|
|
||||||
std::stringstream message;
|
|
||||||
message
|
|
||||||
<< " openCV Error:"
|
|
||||||
<< "\n Status=" << cvErrorStr(status)
|
|
||||||
<< "\n function name=" << (func_name ? func_name : "unknown")
|
|
||||||
<< "\n error message=" << (err_msg ? err_msg : "unknown")
|
|
||||||
<< "\n file_name=" << (file_name ? file_name : "unknown")
|
|
||||||
<< "\n line=" << line
|
|
||||||
<< std::flush;
|
|
||||||
|
|
||||||
// Clear OpenCV's error status for the next call!
|
|
||||||
cvSetErrStatus( CV_StsOk );
|
|
||||||
|
|
||||||
// Set Octave Error.
|
|
||||||
error(message.str().c_str());
|
|
||||||
throw 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//=========================================================================
|
|
||||||
void* void_ptr_generator()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=========================================================================
|
|
||||||
void** void_ptrptr_generator()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=========================================================================
|
|
||||||
CvErrorCallback function_ptr_generator()
|
|
||||||
{
|
|
||||||
return &SendErrorToOctave;
|
|
||||||
}
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
|
|
||||||
// 2004-03-17, Gabriel Schreiber <schreiber@ient.rwth-aachen.de>
|
|
||||||
// Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
// Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
|
|
||||||
|
|
||||||
#include "cxcore.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function will set a Octave error and throw an int.
|
|
||||||
* Exceptions are catched automatically by the SWIG code from "typemaps.i"
|
|
||||||
*/
|
|
||||||
int SendErrorToOctave ( int status,
|
|
||||||
const char * func_name,
|
|
||||||
const char * err_msg,
|
|
||||||
const char * file_name,
|
|
||||||
int line,
|
|
||||||
void * /*userdata*/) throw(int);
|
|
||||||
|
|
||||||
/// Returns the adress of the static method "SendErrorToPython()"
|
|
||||||
CvErrorCallback function_ptr_generator();
|
|
||||||
|
|
||||||
/// Dummy to generate an empty void pointer
|
|
||||||
void * void_ptr_generator();
|
|
||||||
|
|
||||||
/// Dummy to generate an empty void double pointer
|
|
||||||
void ** void_ptrptr_generator();
|
|
@ -1,368 +0,0 @@
|
|||||||
#include "octhelpers.h"
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
int OctSwigObject_Check(octave_value op);
|
|
||||||
|
|
||||||
octave_value OctTuple_FromIntArray(int * arr, int len){
|
|
||||||
octave_value obj = OctTuple_New(len);
|
|
||||||
for(int i=0; i<len; i++){
|
|
||||||
OctTuple_SetItem(obj, i, OctLong_FromLong( arr[i] ) );
|
|
||||||
}
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
octave_value SWIG_SetResult(octave_value result, octave_value obj){
|
|
||||||
result = OctTuple_New(1);
|
|
||||||
OctTuple_SetItem(result, 0, obj);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
octave_value_list* SWIG_AppendResult(octave_value_list* result, octave_value* to_add, int num){
|
|
||||||
for (int j=0;j<num;++j)
|
|
||||||
result->append(to_add[j]);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
std::ostream & cv_arr_write(std::ostream & out, T * data, int rows, int nch, int step){
|
|
||||||
int i,j,k;
|
|
||||||
char * cdata = (char *) data;
|
|
||||||
std::string chdelim1="", chdelim2="";
|
|
||||||
|
|
||||||
// only output channel parens if > 1
|
|
||||||
if(nch>1){
|
|
||||||
chdelim1="(";
|
|
||||||
chdelim2=")";
|
|
||||||
}
|
|
||||||
|
|
||||||
out<<"[\n";
|
|
||||||
for(i=0; i<rows; i++){
|
|
||||||
out<<"[";
|
|
||||||
|
|
||||||
// first element
|
|
||||||
out<<chdelim1;
|
|
||||||
out<<double(((T*)(cdata+i*step))[0]);
|
|
||||||
for(k=1; k<nch; k++){
|
|
||||||
out<<", "<<double(((T*)(cdata+i*step))[k]);
|
|
||||||
}
|
|
||||||
out<<chdelim2;
|
|
||||||
|
|
||||||
// remaining elements
|
|
||||||
for(j=nch*sizeof(T); j<step; j+=(nch*sizeof(T))){
|
|
||||||
out<<", "<<chdelim1;
|
|
||||||
out<<double(((T*)(cdata+i*step+j))[0]);
|
|
||||||
for(k=1; k<nch; k++){
|
|
||||||
out<<", "<<double(((T*)(cdata+i*step+j))[k]);
|
|
||||||
}
|
|
||||||
out<<chdelim2;
|
|
||||||
}
|
|
||||||
out<<"]\n";
|
|
||||||
}
|
|
||||||
out<<"]";
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cvArrPrint(CvArr * arr){
|
|
||||||
CV_FUNCNAME( "cvArrPrint" );
|
|
||||||
|
|
||||||
__BEGIN__;
|
|
||||||
CvMat * mat;
|
|
||||||
CvMat stub;
|
|
||||||
|
|
||||||
mat = cvGetMat(arr, &stub);
|
|
||||||
|
|
||||||
int cn = CV_MAT_CN(mat->type);
|
|
||||||
int depth = CV_MAT_DEPTH(mat->type);
|
|
||||||
int step = MAX(mat->step, cn*mat->cols*CV_ELEM_SIZE(depth));
|
|
||||||
std::ostringstream str;
|
|
||||||
|
|
||||||
switch(depth){
|
|
||||||
case CV_8U:
|
|
||||||
cv_arr_write(str, (uchar *)mat->data.ptr, mat->rows, cn, step);
|
|
||||||
break;
|
|
||||||
case CV_8S:
|
|
||||||
cv_arr_write(str, (char *)mat->data.ptr, mat->rows, cn, step);
|
|
||||||
break;
|
|
||||||
case CV_16U:
|
|
||||||
cv_arr_write(str, (ushort *)mat->data.ptr, mat->rows, cn, step);
|
|
||||||
break;
|
|
||||||
case CV_16S:
|
|
||||||
cv_arr_write(str, (short *)mat->data.ptr, mat->rows, cn, step);
|
|
||||||
break;
|
|
||||||
case CV_32S:
|
|
||||||
cv_arr_write(str, (int *)mat->data.ptr, mat->rows, cn, step);
|
|
||||||
break;
|
|
||||||
case CV_32F:
|
|
||||||
cv_arr_write(str, (float *)mat->data.ptr, mat->rows, cn, step);
|
|
||||||
break;
|
|
||||||
case CV_64F:
|
|
||||||
cv_arr_write(str, (double *)mat->data.ptr, mat->rows, cn, step);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
CV_ERROR( CV_StsError, "Unknown element type");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
std::cout<<str.str()<<std::endl;
|
|
||||||
|
|
||||||
__END__;
|
|
||||||
}
|
|
||||||
|
|
||||||
// deal with negative array indices
|
|
||||||
int OctLong_AsIndex( octave_value idx_object, int len ){
|
|
||||||
int idx = OctLong_AsLong( idx_object );
|
|
||||||
if(idx<0) return len+idx;
|
|
||||||
return idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
CvRect OctSlice_to_CvRect(CvArr * src, octave_value idx_object){
|
|
||||||
CvSize sz = cvGetSize(src);
|
|
||||||
//printf("Size %dx%d\n", sz.height, sz.width);
|
|
||||||
int lower[2], upper[2];
|
|
||||||
Oct_ssize_t len, start, stop, step, slicelength;
|
|
||||||
|
|
||||||
if(OctInt_Check(idx_object) || OctLong_Check(idx_object)){
|
|
||||||
// if array is a row vector, assume index into columns
|
|
||||||
if(sz.height>1){
|
|
||||||
lower[0] = OctLong_AsIndex( idx_object, sz.height );
|
|
||||||
upper[0] = lower[0] + 1;
|
|
||||||
lower[1] = 0;
|
|
||||||
upper[1] = sz.width;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
lower[0] = 0;
|
|
||||||
upper[0] = sz.height;
|
|
||||||
lower[1] = OctLong_AsIndex( idx_object, sz.width );
|
|
||||||
upper[1] = lower[1]+1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1. Slice
|
|
||||||
else if(OctSlice_Check(idx_object)){
|
|
||||||
len = sz.height;
|
|
||||||
if(OctSlice_GetIndicesEx( idx_object, len, &start, &stop, &step, &slicelength )!=0){
|
|
||||||
error("Error in OctSlice_GetIndicesEx: returning NULL");
|
|
||||||
return cvRect(0,0,0,0);
|
|
||||||
}
|
|
||||||
// if array is a row vector, assume index bounds are into columns
|
|
||||||
if(sz.height>1){
|
|
||||||
lower[0] = (int) start; // use c convention of start index = 0
|
|
||||||
upper[0] = (int) stop; // use c convention
|
|
||||||
lower[1] = 0;
|
|
||||||
upper[1] = sz.width;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
lower[1] = (int) start; // use c convention of start index = 0
|
|
||||||
upper[1] = (int) stop; // use c convention
|
|
||||||
lower[0] = 0;
|
|
||||||
upper[0] = sz.height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Tuple
|
|
||||||
else if(OctTuple_Check(idx_object)){
|
|
||||||
//printf("OctTuple{\n");
|
|
||||||
if(OctObject_Length(idx_object)!=2){
|
|
||||||
error("Expected a sequence with 2 elements");
|
|
||||||
return cvRect(0,0,0,0);
|
|
||||||
}
|
|
||||||
for(int i=0; i<2; i++){
|
|
||||||
octave_value o = OctTuple_GetItem(idx_object, i);
|
|
||||||
|
|
||||||
// 2a. Slice -- same as above
|
|
||||||
if(OctSlice_Check(o)){
|
|
||||||
//printf("OctSlice\n");
|
|
||||||
len = (i==0 ? sz.height : sz.width);
|
|
||||||
if(OctSlice_GetIndicesEx(o, len, &start, &stop, &step, &slicelength )!=0){
|
|
||||||
error("Error in OctSlice_GetIndicesEx: returning NULL");
|
|
||||||
return cvRect(0,0,0,0);
|
|
||||||
}
|
|
||||||
//printf("OctSlice_GetIndecesEx(%d, %d, %d, %d, %d)\n", len, start, stop, step, slicelength);
|
|
||||||
lower[i] = start;
|
|
||||||
upper[i] = stop;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2b. Integer
|
|
||||||
else if(OctInt_Check(o) || OctLong_Check(o)){
|
|
||||||
//printf("OctInt\n");
|
|
||||||
lower[i] = OctLong_AsIndex(o, i==0 ? sz.height : sz.width);
|
|
||||||
upper[i] = lower[i]+1;
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
error("Expected a slice or int as sequence item: returning NULL");
|
|
||||||
return cvRect(0,0,0,0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
error("Expected a slice or sequence: returning NULL");
|
|
||||||
return cvRect(0,0,0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return cvRect(lower[1], lower[0], upper[1]-lower[1], upper[0]-lower[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
double OctObject_AsDouble(octave_value obj){
|
|
||||||
if(OctNumber_Check(obj)){
|
|
||||||
if(OctFloat_Check(obj)){
|
|
||||||
return OctFloat_AsDouble(obj);
|
|
||||||
}
|
|
||||||
else if(OctInt_Check(obj) || OctLong_Check(obj)){
|
|
||||||
return (double) OctLong_AsLong(obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
error("Could not convert octave object to Double");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
long OctObject_AsLong(octave_value obj){
|
|
||||||
if(OctNumber_Check(obj)){
|
|
||||||
if(OctFloat_Check(obj)){
|
|
||||||
return (long) OctFloat_AsDouble(obj);
|
|
||||||
}
|
|
||||||
else if(OctInt_Check(obj) || OctLong_Check(obj)){
|
|
||||||
return OctLong_AsLong(obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
error("Could not convert octave object to Long");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// standard python container routines, adapted to octave
|
|
||||||
|
|
||||||
// * should matrix conversions happen here or at typemap layer? or both
|
|
||||||
|
|
||||||
bool OctNumber_Check(const octave_value& ov) {
|
|
||||||
return ov.is_scalar_type();
|
|
||||||
}
|
|
||||||
|
|
||||||
octave_value OctBool_FromLong (long v) {
|
|
||||||
return !!v;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OctInt_Check(const octave_value& ov) {
|
|
||||||
return ov.is_integer_type();
|
|
||||||
}
|
|
||||||
|
|
||||||
long OctInt_AsLong (const octave_value& ov) {
|
|
||||||
return ov.long_value();
|
|
||||||
}
|
|
||||||
|
|
||||||
octave_value OctInt_FromLong (long v) {
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OctLong_Check(const octave_value& ov) {
|
|
||||||
return ov.is_scalar_type();
|
|
||||||
}
|
|
||||||
|
|
||||||
long OctLong_AsLong(const octave_value& ov) {
|
|
||||||
return ov.long_value();
|
|
||||||
}
|
|
||||||
|
|
||||||
octave_value OctLong_FromLong(long v) {
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
octave_value OctLong_FromUnsignedLong(unsigned long v) {
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OctFloat_Check(const octave_value& ov) {
|
|
||||||
return ov.is_scalar_type();
|
|
||||||
}
|
|
||||||
|
|
||||||
octave_value OctFloat_FromDouble(double v) {
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
double OctFloat_AsDouble (const octave_value& ov) {
|
|
||||||
return ov.scalar_value();
|
|
||||||
}
|
|
||||||
|
|
||||||
octave_value OctSequence_New(int n) {
|
|
||||||
return n ? Cell(1,n) : Cell(dim_vector(0,0));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OctSequence_Check(const octave_value& ov) {
|
|
||||||
return ov.is_cell();
|
|
||||||
}
|
|
||||||
|
|
||||||
int OctSequence_Size(const octave_value& ov) {
|
|
||||||
Cell c(ov.cell_value());
|
|
||||||
return ov.cell_value().numel();
|
|
||||||
}
|
|
||||||
|
|
||||||
octave_value OctSequence_GetItem(const octave_value& ov,int i) {
|
|
||||||
Cell c(ov.cell_value());
|
|
||||||
if (i<0||i>=c.numel()) {
|
|
||||||
error("index out of bounds");
|
|
||||||
return octave_value();
|
|
||||||
}
|
|
||||||
return c(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OctSequence_SetItem(octave_value& ov,int i,const octave_value& v) {
|
|
||||||
Cell c(ov.cell_value());
|
|
||||||
if (i<0||i>=c.numel())
|
|
||||||
error("index out of bounds");
|
|
||||||
else {
|
|
||||||
c(i)=v;
|
|
||||||
ov=c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
octave_value OctTuple_New(int n) {
|
|
||||||
return OctSequence_New(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OctTuple_Check(const octave_value& ov) {
|
|
||||||
return OctSequence_Check(ov);
|
|
||||||
}
|
|
||||||
|
|
||||||
int OctTuple_Size(const octave_value& ov) {
|
|
||||||
return OctSequence_Size(ov);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OctTuple_SetItem(octave_value& ov,int i,const octave_value& v) {
|
|
||||||
OctSequence_SetItem(ov,i,v);
|
|
||||||
}
|
|
||||||
|
|
||||||
octave_value OctTuple_GetItem(const octave_value& ov,int i) {
|
|
||||||
return OctSequence_GetItem(ov,i);
|
|
||||||
}
|
|
||||||
|
|
||||||
octave_value OctList_New(int n) {
|
|
||||||
return OctSequence_New(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OctList_Check(const octave_value& ov) {
|
|
||||||
return OctSequence_Check(ov);
|
|
||||||
}
|
|
||||||
|
|
||||||
int OctList_Size(const octave_value& ov) {
|
|
||||||
return OctSequence_Size(ov);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OctList_SetItem(octave_value& ov,int i,const octave_value& v) {
|
|
||||||
OctSequence_SetItem(ov,i,v);
|
|
||||||
}
|
|
||||||
|
|
||||||
octave_value OctList_GetItem(const octave_value& ov,int i) {
|
|
||||||
return OctSequence_GetItem(ov,i);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OctSlice_Check(const octave_value& ov) {
|
|
||||||
return false; // todo have these map to range and magic-colon types
|
|
||||||
}
|
|
||||||
|
|
||||||
int OctObject_Length(const octave_value& ov) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OctSlice_GetIndicesEx(const octave_value& ov, Oct_ssize_t len, Oct_ssize_t* start, Oct_ssize_t* stop, Oct_ssize_t* step, Oct_ssize_t* slicelength ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
@ -1,81 +0,0 @@
|
|||||||
#ifndef OCTHELPERS_H
|
|
||||||
#define OCTHELPERS_H
|
|
||||||
|
|
||||||
#include <octave/oct.h>
|
|
||||||
#include <octave/Cell.h>
|
|
||||||
|
|
||||||
// SWIG sets an include on 'tcl.h' without giving the path, which fails on Ubuntu
|
|
||||||
#if defined HAVE_TCL_H
|
|
||||||
#include <tcl.h>
|
|
||||||
#elif defined HAVE_TCL_TCL_H
|
|
||||||
#include <tcl/tcl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <cxcore.h>
|
|
||||||
#include <cv.h>
|
|
||||||
|
|
||||||
typedef unsigned int Oct_ssize_t;
|
|
||||||
|
|
||||||
// convert octave index object (tuple, integer, or slice) to CvRect for subsequent cvGetSubMat call
|
|
||||||
CvRect OctSlice_to_CvRect(CvArr * src, octave_value idx_object);
|
|
||||||
|
|
||||||
// prints array to stdout
|
|
||||||
// TODO: octave __str returns a string, so this should write to a string
|
|
||||||
//
|
|
||||||
void cvArrPrint( CvArr * mat );
|
|
||||||
|
|
||||||
// Convert an integer array to octave tuple
|
|
||||||
octave_value OctTuple_FromIntArray(int * arr, int len);
|
|
||||||
|
|
||||||
// If result is not NULL or OctNone, release object and replace it with obj
|
|
||||||
octave_value SWIG_SetResult(octave_value result, octave_value obj);
|
|
||||||
|
|
||||||
// helper function to append one or more objects to the swig $result array
|
|
||||||
octave_value_list* SWIG_AppendResult(octave_value_list* result, octave_value* to_add, int num);
|
|
||||||
|
|
||||||
int OctObject_AsDoubleArray(octave_value obj, double * array, int len);
|
|
||||||
int OctObject_AsLongArray(octave_value obj, int * array, int len);
|
|
||||||
int OctObject_AsFloatArray(octave_value obj, float * array, int len);
|
|
||||||
|
|
||||||
// helper function to convert octave scalar or sequence to int, float or double arrays
|
|
||||||
double OctObject_AsDouble(octave_value obj);
|
|
||||||
long OctObject_AsLong(octave_value obj);
|
|
||||||
|
|
||||||
// standard python container routines, adapted to octave
|
|
||||||
bool OctNumber_Check(const octave_value& ov);
|
|
||||||
octave_value OctBool_FromLong (long v);
|
|
||||||
bool OctInt_Check(const octave_value& ov);
|
|
||||||
long OctInt_AsLong (const octave_value& ov);
|
|
||||||
octave_value OctInt_FromLong (long v);
|
|
||||||
bool OctLong_Check(const octave_value& ov);
|
|
||||||
long OctLong_AsLong(const octave_value& ov);
|
|
||||||
octave_value OctLong_FromLong(long v);
|
|
||||||
octave_value OctLong_FromUnsignedLong(unsigned long v);
|
|
||||||
bool OctFloat_Check(const octave_value& ov);
|
|
||||||
octave_value OctFloat_FromDouble(double v);
|
|
||||||
double OctFloat_AsDouble (const octave_value& ov);
|
|
||||||
|
|
||||||
octave_value OctSequence_New(int n);
|
|
||||||
bool OctSequence_Check(const octave_value& ov);
|
|
||||||
int OctSequence_Size(const octave_value& ov);
|
|
||||||
octave_value OctSequence_GetItem(const octave_value& ov,int i);
|
|
||||||
void OctSequence_SetItem(octave_value& ov,int i,const octave_value& v);
|
|
||||||
|
|
||||||
octave_value OctTuple_New(int n);
|
|
||||||
bool OctTuple_Check(const octave_value& ov);
|
|
||||||
int OctTuple_Size(const octave_value& ov);
|
|
||||||
void OctTuple_SetItem(octave_value& c,int i,const octave_value& ov);
|
|
||||||
octave_value OctTuple_GetItem(const octave_value& c,int i);
|
|
||||||
|
|
||||||
octave_value OctList_New(int n);
|
|
||||||
bool OctList_Check(const octave_value& ov);
|
|
||||||
int OctList_Size(const octave_value& ov);
|
|
||||||
void OctList_SetItem(octave_value& ov,int i,const octave_value& ov);
|
|
||||||
octave_value OctList_GetItem(const octave_value& ov,int i);
|
|
||||||
|
|
||||||
bool OctSlice_Check(const octave_value& ov);
|
|
||||||
|
|
||||||
int OctObject_Length(const octave_value& ov);
|
|
||||||
bool OctSlice_GetIndicesEx(const octave_value& ov, Oct_ssize_t len, Oct_ssize_t* start, Oct_ssize_t* stop, Oct_ssize_t* step, Oct_ssize_t* slicelength );
|
|
||||||
|
|
||||||
#endif //OCTHELPERS_H
|
|
@ -1,242 +0,0 @@
|
|||||||
/* These functions need the SWIG_* functions defined in the wrapper */
|
|
||||||
%{
|
|
||||||
|
|
||||||
|
|
||||||
static inline bool OctSwigObject_Check(const octave_value& ov) {
|
|
||||||
return ov.type_id()==octave_swig_ref::static_type_id();
|
|
||||||
}
|
|
||||||
|
|
||||||
static CvArr * OctObject_to_CvArr(octave_value obj, bool * freearg);
|
|
||||||
static CvArr * OctSequence_to_CvArr( octave_value obj );
|
|
||||||
|
|
||||||
// convert a octave sequence/array/list object into a c-array
|
|
||||||
#define OctObject_AsArrayImpl(func, ctype, ptype) \
|
|
||||||
int func(octave_value obj, ctype * array, int len){ \
|
|
||||||
void * mat_vptr=NULL; \
|
|
||||||
void * im_vptr=NULL; \
|
|
||||||
if(OctNumber_Check(obj)){ \
|
|
||||||
memset( array, 0, sizeof(ctype)*len ); \
|
|
||||||
array[0] = OctObject_As##ptype( obj ); \
|
|
||||||
} \
|
|
||||||
else if(OctList_Check(obj) || OctTuple_Check(obj)){ \
|
|
||||||
int seqsize = OctSequence_Size(obj); \
|
|
||||||
for(int i=0; i<len && i<seqsize; i++){ \
|
|
||||||
if(i<seqsize){ \
|
|
||||||
array[i] = OctObject_As##ptype( OctSequence_GetItem(obj, i) ); \
|
|
||||||
} \
|
|
||||||
else{ \
|
|
||||||
array[i] = 0; \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
else if( SWIG_ConvertPtr(obj, &mat_vptr, SWIGTYPE_p_CvMat, 0)!=-1 || \
|
|
||||||
SWIG_ConvertPtr(obj, &im_vptr, SWIGTYPE_p__IplImage, 0)!=-1) \
|
|
||||||
{ \
|
|
||||||
CvMat * mat = (CvMat *) mat_vptr; \
|
|
||||||
CvMat stub; \
|
|
||||||
if(im_vptr) mat = cvGetMat(im_vptr, &stub); \
|
|
||||||
if( mat->rows!=1 && mat->cols!=1 ){ \
|
|
||||||
error("OctObject_As*Array: CvArr must be row or column vector" ); \
|
|
||||||
return -1; \
|
|
||||||
} \
|
|
||||||
if( mat->rows==1 && mat->cols==1 ){ \
|
|
||||||
CvScalar val; \
|
|
||||||
if( len!=CV_MAT_CN(mat->type) ){ \
|
|
||||||
error("OctObject_As*Array: CvArr channels != length" ); \
|
|
||||||
return -1; \
|
|
||||||
} \
|
|
||||||
val = cvGet1D(mat, 0); \
|
|
||||||
for(int i=0; i<len; i++){ \
|
|
||||||
array[i] = (ctype) val.val[i]; \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
else{ \
|
|
||||||
mat = cvReshape(mat, &stub, -1, mat->rows*mat->cols); \
|
|
||||||
if( mat->rows != len ){ \
|
|
||||||
error("OctObject_As*Array: CvArr rows or cols must equal length" ); \
|
|
||||||
return -1; \
|
|
||||||
} \
|
|
||||||
for(int i=0; i<len; i++){ \
|
|
||||||
CvScalar val = cvGet1D(mat, i); \
|
|
||||||
array[i] = (ctype) val.val[0]; \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
else{ \
|
|
||||||
error("OctObject_As*Array: Expected a number, sequence or CvArr" ); \
|
|
||||||
return -1; \
|
|
||||||
} \
|
|
||||||
return 0; \
|
|
||||||
}
|
|
||||||
|
|
||||||
OctObject_AsArrayImpl( OctObject_AsFloatArray, float, Double );
|
|
||||||
OctObject_AsArrayImpl( OctObject_AsDoubleArray, double, Double );
|
|
||||||
OctObject_AsArrayImpl( OctObject_AsLongArray, int, Long );
|
|
||||||
|
|
||||||
static CvPoint OctObject_to_CvPoint(octave_value obj){
|
|
||||||
CvPoint val;
|
|
||||||
CvPoint *ptr;
|
|
||||||
CvPoint2D32f * ptr2D32f;
|
|
||||||
CvScalar * scalar;
|
|
||||||
|
|
||||||
if( SWIG_ConvertPtr(obj, (void**)&ptr, SWIGTYPE_p_CvPoint, 0) != -1) {
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
if( SWIG_ConvertPtr(obj, (void**)&ptr2D32f, SWIGTYPE_p_CvPoint2D32f, 0) != -1) {
|
|
||||||
return cvPointFrom32f( *ptr2D32f );
|
|
||||||
}
|
|
||||||
if( SWIG_ConvertPtr(obj, (void**)&scalar, SWIGTYPE_p_CvScalar, 0) != -1) {
|
|
||||||
return cvPointFrom32f(cvPoint2D32f( scalar->val[0], scalar->val[1] ));
|
|
||||||
}
|
|
||||||
if(OctObject_AsLongArray(obj, (int *) &val, 2) != -1){
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
error("could not convert to CvPoint");
|
|
||||||
return cvPoint(0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static CvPoint2D32f OctObject_to_CvPoint2D32f(octave_value obj){
|
|
||||||
CvPoint2D32f val;
|
|
||||||
CvPoint2D32f *ptr2D32f;
|
|
||||||
CvPoint *ptr;
|
|
||||||
CvScalar * scalar;
|
|
||||||
if( SWIG_ConvertPtr(obj, (void**)&ptr2D32f, SWIGTYPE_p_CvPoint2D32f, 0) != -1) {
|
|
||||||
return *ptr2D32f;
|
|
||||||
}
|
|
||||||
if( SWIG_ConvertPtr(obj, (void**)&ptr, SWIGTYPE_p_CvPoint, 0) != -1) {
|
|
||||||
return cvPointTo32f(*ptr);
|
|
||||||
}
|
|
||||||
if( SWIG_ConvertPtr(obj, (void**)&scalar, SWIGTYPE_p_CvScalar, 0) != -1) {
|
|
||||||
return cvPoint2D32f( scalar->val[0], scalar->val[1] );
|
|
||||||
}
|
|
||||||
if(OctObject_AsFloatArray(obj, (float *) &val, 2) != -1){
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
error("could not convert to CvPoint2D32f");
|
|
||||||
return cvPoint2D32f(0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static CvScalar OctObject_to_CvScalar(octave_value obj){
|
|
||||||
CvScalar val;
|
|
||||||
CvScalar * ptr;
|
|
||||||
CvPoint2D32f *ptr2D32f;
|
|
||||||
CvPoint *pt_ptr;
|
|
||||||
void * vptr;
|
|
||||||
if( SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvScalar, 0 ) != -1)
|
|
||||||
{
|
|
||||||
ptr = (CvScalar *) vptr;
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
if( SWIG_ConvertPtr(obj, (void**)&ptr2D32f, SWIGTYPE_p_CvPoint2D32f, 0) != -1) {
|
|
||||||
return cvScalar(ptr2D32f->x, ptr2D32f->y);
|
|
||||||
}
|
|
||||||
if( SWIG_ConvertPtr(obj, (void**)&pt_ptr, SWIGTYPE_p_CvPoint, 0) != -1) {
|
|
||||||
return cvScalar(pt_ptr->x, pt_ptr->y);
|
|
||||||
}
|
|
||||||
if(OctObject_AsDoubleArray(obj, val.val, 4)!=-1){
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
return cvScalar(-1,-1,-1,-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if octave sequence type, convert to CvMat or CvMatND
|
|
||||||
static CvArr * OctObject_to_CvArr(octave_value obj, bool * freearg){
|
|
||||||
CvArr * cvarr;
|
|
||||||
*freearg = false;
|
|
||||||
|
|
||||||
// check if OpenCV type
|
|
||||||
if ( OctSwigObject_Check(obj) ){
|
|
||||||
SWIG_ConvertPtr(obj, &cvarr, 0, SWIG_POINTER_EXCEPTION);
|
|
||||||
}
|
|
||||||
else if (OctList_Check(obj) || OctTuple_Check(obj)){
|
|
||||||
cvarr = OctSequence_to_CvArr( obj );
|
|
||||||
*freearg = (cvarr != NULL);
|
|
||||||
}
|
|
||||||
else if (OctLong_Check(obj) && OctLong_AsLong(obj)==0){
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
SWIG_ConvertPtr(obj, (void**)&cvarr, 0, SWIG_POINTER_EXCEPTION);
|
|
||||||
}
|
|
||||||
return cvarr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int OctObject_GetElemType(octave_value obj){
|
|
||||||
void *vptr;
|
|
||||||
if(SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvPoint, 0) != -1) return CV_32SC2;
|
|
||||||
if(SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvSize, 0) != -1) return CV_32SC2;
|
|
||||||
if(SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvRect, 0) != -1) return CV_32SC4;
|
|
||||||
if(SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvSize2D32f, 0) != -1) return CV_32FC2;
|
|
||||||
if(SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvPoint2D32f, 0) != -1) return CV_32FC2;
|
|
||||||
if(SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvPoint3D32f, 0) != -1) return CV_32FC3;
|
|
||||||
if(SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvPoint2D64f, 0) != -1) return CV_64FC2;
|
|
||||||
if(SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvPoint3D64f, 0) != -1) return CV_64FC3;
|
|
||||||
if(SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvScalar, 0) != -1) return CV_64FC4;
|
|
||||||
if(OctTuple_Check(obj) || OctList_Check(obj)) return CV_MAKE_TYPE(CV_32F, OctSequence_Size( obj ));
|
|
||||||
if(OctLong_Check(obj)) return CV_32S;
|
|
||||||
return CV_32F;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Would like this to convert Octave lists to CvMat
|
|
||||||
// Also lists of CvPoints, CvScalars, CvMats? etc
|
|
||||||
static CvArr * OctSequence_to_CvArr( octave_value obj ){
|
|
||||||
int dims[CV_MAX_DIM] = {1,1,1};
|
|
||||||
int ndim=0;
|
|
||||||
int cvtype;
|
|
||||||
octave_value item;
|
|
||||||
|
|
||||||
// figure out dimensions
|
|
||||||
for(item = obj;
|
|
||||||
(OctTuple_Check(item) || OctList_Check(item));
|
|
||||||
item = OctSequence_GetItem(item, 0))
|
|
||||||
{
|
|
||||||
dims[ndim] = OctSequence_Size( item );
|
|
||||||
ndim++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ndim==0){
|
|
||||||
error("Cannot convert an empty octave object to a CvArr");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
cvtype = OctObject_GetElemType(item);
|
|
||||||
// collapse last dim into NCH if we found a single channel, but the last dim is <=3
|
|
||||||
if(CV_MAT_CN(cvtype)==1 && dims[ndim-1]>1 && dims[ndim-1]<4){
|
|
||||||
cvtype=CV_MAKE_TYPE(cvtype, dims[ndim-1]);
|
|
||||||
dims[ndim-1]=1;
|
|
||||||
ndim--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(cvtype==-1){
|
|
||||||
error("Could not determine OpenCV element type of Octave sequence");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// CvMat
|
|
||||||
if(ndim<=2){
|
|
||||||
CvMat *m = cvCreateMat(dims[0], dims[1], cvtype);
|
|
||||||
for(int i=0; i<dims[0]; i++){
|
|
||||||
octave_value rowobj = OctSequence_GetItem(obj, i);
|
|
||||||
if( dims[1] > 1 ){
|
|
||||||
// double check size
|
|
||||||
assert((OctTuple_Check(rowobj) || OctList_Check(rowobj)) &&
|
|
||||||
OctSequence_Size(rowobj) == dims[1]);
|
|
||||||
|
|
||||||
for(int j=0; j<dims[1]; j++){
|
|
||||||
octave_value colobj = OctSequence_GetItem(rowobj, j);
|
|
||||||
cvSet2D( m, i, j, OctObject_to_CvScalar( colobj ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
cvSet1D(m, i, OctObject_to_CvScalar( rowobj ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (CvArr *) m;
|
|
||||||
}
|
|
||||||
|
|
||||||
// CvMatND
|
|
||||||
error("Cannot convert Octave Object to CvArr -- ndim > 3");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
%}
|
|
@ -1,896 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
%include "exception.i"
|
|
||||||
%include "./octhelpers.i"
|
|
||||||
|
|
||||||
%typemap(in) (CvArr *) (bool freearg=false){
|
|
||||||
$1 = OctObject_to_CvArr($input, &freearg);
|
|
||||||
}
|
|
||||||
%typemap(freearg) (CvArr *) {
|
|
||||||
if($1!=NULL && freearg$argnum){
|
|
||||||
cvReleaseData( $1 );
|
|
||||||
cvFree(&($1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%typecheck(SWIG_TYPECHECK_POINTER) CvArr * {
|
|
||||||
void *ptr;
|
|
||||||
if(OctList_Check($input) || OctTuple_Check($input)) {
|
|
||||||
$1 = 1;
|
|
||||||
}
|
|
||||||
else if (SWIG_ConvertPtr($input, &ptr, 0, 0) == -1) {
|
|
||||||
$1 = 0;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$1 = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// for cvReshape, cvGetRow, where header is passed, then filled in
|
|
||||||
%typemap(in, numinputs=0) CvMat * OUTPUT (CvMat * header) {
|
|
||||||
header = (CvMat *)cvAlloc(sizeof(CvMat));
|
|
||||||
$1 = header;
|
|
||||||
}
|
|
||||||
%newobject cvReshape;
|
|
||||||
%newobject cvGetRow;
|
|
||||||
%newobject cvGetRows;
|
|
||||||
%newobject cvGetCol;
|
|
||||||
%newobject cvGetCols;
|
|
||||||
%newobject cvGetSubRect;
|
|
||||||
%newobject cvGetDiag;
|
|
||||||
|
|
||||||
%apply CvMat *OUTPUT {CvMat * header};
|
|
||||||
%apply CvMat *OUTPUT {CvMat * submat};
|
|
||||||
|
|
||||||
// In C, these functions assume input will always be around at least as long as header,
|
|
||||||
// presumably because the most common usage is to pass in a reference to a stack object.
|
|
||||||
// i.e
|
|
||||||
// CvMat row;
|
|
||||||
// cvGetRow(A, &row, 0);
|
|
||||||
//
|
|
||||||
// As a result, the header is not refcounted (see the C source for cvGetRow, Reshape, in cxarray.cpp)
|
|
||||||
// However, in octave, the header parameter is implicitly created so it is easier to create
|
|
||||||
// situations where the sub-array outlives the original header. A simple example is:
|
|
||||||
// A = cvReshape(A, -1, A.rows*A.cols)
|
|
||||||
//
|
|
||||||
// since octave doesn't have an assignment operator, the new header simply replaces the original,
|
|
||||||
// the refcount of the original goes to zero, and cvReleaseMat is called on the original, freeing both
|
|
||||||
// the header and data. The new header is left pointing to invalid data. To avoid this, need to add
|
|
||||||
// refcount field to the returned header.
|
|
||||||
%typemap(argout) (const CvArr* arr, CvMat* header) {
|
|
||||||
$2->hdr_refcount = ((CvMat *)$1)->hdr_refcount;
|
|
||||||
$2->refcount = ((CvMat *)$1)->refcount;
|
|
||||||
cvIncRefData($2);
|
|
||||||
}
|
|
||||||
%typemap(argout) (const CvArr* arr, CvMat* submat) {
|
|
||||||
$2->hdr_refcount = ((CvMat *)$1)->hdr_refcount;
|
|
||||||
$2->refcount = ((CvMat *)$1)->refcount;
|
|
||||||
cvIncRefData($2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// map scalar or sequence to CvScalar, CvPoint2D32f, CvPoint
|
|
||||||
%typemap(in) (CvScalar) {
|
|
||||||
$1 = OctObject_to_CvScalar( $input );
|
|
||||||
}
|
|
||||||
%typemap(in) (CvPoint) {
|
|
||||||
$1 = OctObject_to_CvPoint($input);
|
|
||||||
}
|
|
||||||
%typemap(in) (CvPoint2D32f) {
|
|
||||||
$1 = OctObject_to_CvPoint2D32f($input);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// typemap for cvGetDims
|
|
||||||
%typemap(in) (const CvArr * arr, int * sizes = NULL) (void * myarr, int mysizes[CV_MAX_DIM]){
|
|
||||||
SWIG_Octave_ConvertPtr($input, &myarr, 0, SWIG_POINTER_EXCEPTION);
|
|
||||||
$1=(CvArr *)myarr;
|
|
||||||
$2=mysizes;
|
|
||||||
}
|
|
||||||
|
|
||||||
%typemap(argout) (const CvArr * arr, int * sizes = NULL) {
|
|
||||||
int len = OctInt_AsLong( $result );
|
|
||||||
octave_value obj = OctTuple_FromIntArray( $2, len );
|
|
||||||
%append_output(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
// map one list of integer to the two parameters dimension/sizes
|
|
||||||
%typemap(in) (int dims, int* sizes) {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
// get the size of the dimention array
|
|
||||||
$1 = OctList_Size ($input);
|
|
||||||
|
|
||||||
// allocate the needed memory
|
|
||||||
$2 = (int *)malloc ($1 * sizeof (int));
|
|
||||||
|
|
||||||
// extract all the integer values from the list
|
|
||||||
for (i = 0; i < $1; i++) {
|
|
||||||
octave_value item = OctList_GetItem ($input, i);
|
|
||||||
$2 [i] = (int)OctInt_AsLong (item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// map one list of integer to the parameter idx of
|
|
||||||
// cvGetND, cvSetND, cvClearND, cvGetRealND, cvSetRealND and cvClearRealND
|
|
||||||
%typemap(in) (int* idx) {
|
|
||||||
int i;
|
|
||||||
int size;
|
|
||||||
|
|
||||||
// get the size of the dimention array
|
|
||||||
size = OctList_Size ($input);
|
|
||||||
|
|
||||||
// allocate the needed memory
|
|
||||||
$1 = (int *)malloc (size * sizeof (int));
|
|
||||||
|
|
||||||
// extract all the integer values from the list
|
|
||||||
for (i = 0; i < size; i++) {
|
|
||||||
octave_value item = OctList_GetItem ($input, i);
|
|
||||||
$1 [i] = (int)OctInt_AsLong (item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// map a list of list of float to an matrix of floats
|
|
||||||
%typemap(in) float** ranges {
|
|
||||||
int i1;
|
|
||||||
int i2;
|
|
||||||
int size1;
|
|
||||||
int size2 = 0;
|
|
||||||
|
|
||||||
// get the number of lines of the matrix
|
|
||||||
size1 = OctList_Size ($input);
|
|
||||||
|
|
||||||
// allocate the correct number of lines for the destination matrix
|
|
||||||
$1 = (float **)malloc (size1 * sizeof (float *));
|
|
||||||
|
|
||||||
for (i1 = 0; i1 < size1; i1++) {
|
|
||||||
|
|
||||||
// extract all the lines of the matrix
|
|
||||||
octave_value list = OctList_GetItem ($input, i1);
|
|
||||||
|
|
||||||
if (size2 == 0) {
|
|
||||||
// size 2 wasn't computed before
|
|
||||||
size2 = OctList_Size (list);
|
|
||||||
} else if (size2 != OctList_Size (list)) {
|
|
||||||
// the current line as a different size than the previous one
|
|
||||||
// so, generate an exception
|
|
||||||
SWIG_exception (SWIG_ValueError, "Lines must be the same size");
|
|
||||||
}
|
|
||||||
|
|
||||||
// allocate the correct number of rows for the current line
|
|
||||||
$1 [i1] = (float *)malloc (size2 * sizeof (float));
|
|
||||||
|
|
||||||
// extract all the float values of this row
|
|
||||||
for (i2 = 0; i2 < size2; i2++) {
|
|
||||||
octave_value item = OctList_GetItem (list, i2);
|
|
||||||
$1 [i1][i2] = (float)OctFloat_AsDouble (item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// map the output parameter of the cvGetMinMaxHistValue()
|
|
||||||
// so, we can call cvGetMinMaxHistValue() in Octave like:
|
|
||||||
// min_value, max_value = cvGetMinMaxHistValue (hist, None, None)
|
|
||||||
//
|
|
||||||
%apply int *OUTPUT {int *min_idx};
|
|
||||||
%apply int *OUTPUT {int *max_idx};
|
|
||||||
%apply float *OUTPUT {float *min_value};
|
|
||||||
%apply float *OUTPUT {float *max_value};
|
|
||||||
//
|
|
||||||
// map output parameters of cvMinMaxLoc
|
|
||||||
//
|
|
||||||
%apply double *OUTPUT {double* min_val, double* max_val};
|
|
||||||
|
|
||||||
//
|
|
||||||
// the input argument of cvPolyLine "CvPoint** pts" is converted from
|
|
||||||
// a "list of list" (aka. an array) of CvPoint().
|
|
||||||
// The next parameters "int* npts" and "int contours" are computed from
|
|
||||||
// the givne list.
|
|
||||||
//
|
|
||||||
%typemap(in) (CvPoint** pts, int* npts, int contours){
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
int size2 = -1;
|
|
||||||
CvPoint **points = NULL;
|
|
||||||
int *nb_vertex = NULL;
|
|
||||||
|
|
||||||
if(!OctSequence_Check($input)){
|
|
||||||
SWIG_exception(SWIG_TypeError, "Expected a list for argument $argnum\n");
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the number of polylines input array
|
|
||||||
int size1 = OctSequence_Size ($input);
|
|
||||||
$3 = size1;
|
|
||||||
|
|
||||||
if(size1>0){
|
|
||||||
// create the points array
|
|
||||||
points = (CvPoint **)malloc (size1 * sizeof (CvPoint *));
|
|
||||||
|
|
||||||
// point to the created array for passing info to the C function
|
|
||||||
$1 = points;
|
|
||||||
|
|
||||||
// create the array for memorizing the vertex
|
|
||||||
nb_vertex = (int *)malloc (size1 * sizeof (int));
|
|
||||||
$2 = nb_vertex;
|
|
||||||
}
|
|
||||||
for (i = 0; i < size1; i++) {
|
|
||||||
|
|
||||||
// get the current item
|
|
||||||
octave_value line = OctSequence_GetItem ($input, i);
|
|
||||||
|
|
||||||
if(!OctSequence_Check(line)){
|
|
||||||
SWIG_exception(SWIG_TypeError, "Expected a sequence of sequences of integers for argument $argnum\n");
|
|
||||||
// TODO: cleanup here
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the size of the current polyline
|
|
||||||
size2 = OctSequence_Size (line);
|
|
||||||
|
|
||||||
|
|
||||||
if(size2>0){
|
|
||||||
// allocate the necessary memory to store the points
|
|
||||||
points [i] = (CvPoint *)malloc (size2 * sizeof (CvPoint));
|
|
||||||
}
|
|
||||||
|
|
||||||
// memorize the size of the polyline in the vertex list
|
|
||||||
nb_vertex [i] = size2;
|
|
||||||
|
|
||||||
for (j = 0; j < size2; j++) {
|
|
||||||
// get the current item
|
|
||||||
octave_value item = OctSequence_GetItem (line, j);
|
|
||||||
points[i][j] = OctObject_to_CvPoint( item );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Free arguments allocated before the function call
|
|
||||||
%typemap(freearg) (CvPoint **pts, int* npts, int contours){
|
|
||||||
int i;
|
|
||||||
for(i=0;i<$3;i++){
|
|
||||||
free($1[i]);
|
|
||||||
}
|
|
||||||
free($1);
|
|
||||||
free($2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Macro to define typemaps to convert a octave list of CvPoints to a C array of CvPoints
|
|
||||||
%define %typemap_CvPoint_CArr(points_arg, numpoints_arg)
|
|
||||||
|
|
||||||
%typemap(in, numinputs=1) (CvPoint * points_arg, int numpoints_arg){
|
|
||||||
int i;
|
|
||||||
if(!OctSequence_Check($input)){
|
|
||||||
SWIG_exception(SWIG_TypeError, "Expected a list for argument $argnum\n");
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
int size = OctSequence_Size($input);
|
|
||||||
CvPoint * points = (CvPoint *)malloc(size*sizeof(CvPoint));
|
|
||||||
for(i=0; i<size; i++){
|
|
||||||
octave_value item = OctSequence_GetItem($input, i);
|
|
||||||
points[i] = OctObject_to_CvPoint( item );
|
|
||||||
}
|
|
||||||
$1 = points;
|
|
||||||
$2 = size;
|
|
||||||
}
|
|
||||||
%typemap(freearg) (CvPoint *points_arg, int numpoints_arg){
|
|
||||||
free((char *)$1);
|
|
||||||
}
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// apply to cvFillConvexPoly
|
|
||||||
%typemap_CvPoint_CArr(pts, npts)
|
|
||||||
|
|
||||||
//
|
|
||||||
// this is mainly an "output parameter"
|
|
||||||
// So, just allocate the memory as input
|
|
||||||
//
|
|
||||||
%typemap (in, numinputs=0) (CvSeq ** OUTPUT) (CvSeq * seq) {
|
|
||||||
$1 = &seq;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// return the finded contours with all the others parametres
|
|
||||||
//
|
|
||||||
%typemap(argout) (CvSeq ** OUTPUT) {
|
|
||||||
octave_value to_add;
|
|
||||||
|
|
||||||
// extract the pointer we want to add to the returned tuple
|
|
||||||
// sequence is allocated in CvMemStorage, so octave_ownership=0
|
|
||||||
to_add = SWIG_NewPointerObj (*$1, $descriptor(CvSeq*), 0);
|
|
||||||
|
|
||||||
$result = SWIG_AppendResult($result, &to_add, 1);
|
|
||||||
}
|
|
||||||
%apply CvSeq **OUTPUT {CvSeq **first_contour};
|
|
||||||
%apply CvSeq **OUTPUT {CvSeq **comp};
|
|
||||||
|
|
||||||
//
|
|
||||||
// CvArr ** image can be either one CvArr or one array of CvArr
|
|
||||||
// (for example like in cvCalcHist() )
|
|
||||||
// From Octave, the array of CvArr can be a tuple.
|
|
||||||
//
|
|
||||||
%typemap(in) (CvArr ** INPUT) (
|
|
||||||
CvArr * one_image=NULL,
|
|
||||||
bool free_one_arg=false,
|
|
||||||
CvArr ** many_images=NULL,
|
|
||||||
bool *free_many_args=NULL,
|
|
||||||
int nimages=0 ) {
|
|
||||||
// first, check if this is a tuple
|
|
||||||
if (OctTuple_Check ($input)) {
|
|
||||||
// This is a tuple, so we need to test each element and pass
|
|
||||||
// them to the called function
|
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
// get the size of the tuple
|
|
||||||
nimages = OctTuple_Size ($input);
|
|
||||||
|
|
||||||
// allocate the necessary place
|
|
||||||
many_images = (CvArr **)malloc (nimages * sizeof (CvArr *));
|
|
||||||
free_many_args = (bool *)malloc(nimages * sizeof(bool));
|
|
||||||
|
|
||||||
for (i = 0; i < nimages; i++) {
|
|
||||||
|
|
||||||
// convert the current tuple element to a CvArr *, and
|
|
||||||
// store to many_images [i]
|
|
||||||
many_images[i] = OctObject_to_CvArr (OctTuple_GetItem ($input, i),
|
|
||||||
free_many_args+i);
|
|
||||||
|
|
||||||
// check that the current item is a correct type
|
|
||||||
if(!many_images[i]) {
|
|
||||||
// incorrect !
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// what to give to the called function
|
|
||||||
$1 = many_images;
|
|
||||||
|
|
||||||
} else if((one_image = OctObject_to_CvArr( $input, &free_one_arg ))){
|
|
||||||
|
|
||||||
// this is just one CvArr *, so one_image will receive it
|
|
||||||
$1 = &one_image;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// not a CvArr *, not a tuple, this is wrong
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%apply CvArr ** INPUT {CvArr ** img};
|
|
||||||
%apply CvArr ** INPUT {CvArr ** image};
|
|
||||||
%apply CvArr ** INPUT {CvArr ** arr};
|
|
||||||
%apply CvArr ** INPUT {CvArr ** vects};
|
|
||||||
|
|
||||||
%typemap(freearg) (CvArr ** FREEARG) {
|
|
||||||
if(free_one_arg$argnum){
|
|
||||||
cvFree(&(one_image$argnum));
|
|
||||||
}
|
|
||||||
else if(free_many_args$argnum){
|
|
||||||
int i;
|
|
||||||
for (i=0; i<nimages$argnum; i++){
|
|
||||||
if(free_many_args$argnum[i]){
|
|
||||||
cvReleaseData(many_images$argnum[i]);
|
|
||||||
cvFree(many_images$argnum+i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(many_images$argnum);
|
|
||||||
free(free_many_args$argnum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%apply CvArr ** FREEARG {CvArr ** img};
|
|
||||||
%apply CvArr ** FREEARG {CvArr ** image};
|
|
||||||
%apply CvArr ** FREEARG {CvArr ** arr};
|
|
||||||
%apply CvArr ** FREEARG {CvArr ** vects};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Map the CvFont * parameter from the cvInitFont() as an output parameter
|
|
||||||
//
|
|
||||||
%typemap (in, numinputs=1) (CvFont* font, int font_face) {
|
|
||||||
$1 = (CvFont *)malloc (sizeof (CvFont));
|
|
||||||
$2 = (int)OctInt_AsLong ($input);
|
|
||||||
if (SWIG_arg_fail($argnum)) SWIG_fail;
|
|
||||||
}
|
|
||||||
%typemap(argout) (CvFont* font, int font_face) {
|
|
||||||
octave_value to_add;
|
|
||||||
|
|
||||||
// extract the pointer we want to add to the returned tuple
|
|
||||||
to_add = SWIG_NewPointerObj ($1, $descriptor(CvFont *), 0);
|
|
||||||
|
|
||||||
$result = SWIG_AppendResult($result, &to_add, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// these are output parameters for cvGetTextSize
|
|
||||||
//
|
|
||||||
%typemap (in, numinputs=0) (CvSize* text_size, int* baseline) {
|
|
||||||
CvSize *size = (CvSize *)malloc (sizeof (CvSize));
|
|
||||||
int *baseline = (int *)malloc (sizeof (int));
|
|
||||||
$1 = size;
|
|
||||||
$2 = baseline;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// return the finded parameters for cvGetTextSize
|
|
||||||
//
|
|
||||||
%typemap(argout) (CvSize* text_size, int* baseline) {
|
|
||||||
octave_value to_add[2];
|
|
||||||
|
|
||||||
// extract the pointers we want to add to the returned tuple
|
|
||||||
to_add [0] = SWIG_NewPointerObj ($1, $descriptor(CvSize *), 0);
|
|
||||||
to_add [1] = OctInt_FromLong (*$2);
|
|
||||||
|
|
||||||
$result = SWIG_AppendResult($result, to_add, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// curr_features is output parameter for cvCalcOpticalFlowPyrLK
|
|
||||||
//
|
|
||||||
%typemap (in, numinputs=1) (CvPoint2D32f* curr_features, int count)
|
|
||||||
(int tmpCount) {
|
|
||||||
// as input, we only need the size of the wanted features
|
|
||||||
|
|
||||||
// memorize the size of the wanted features
|
|
||||||
tmpCount = (int)OctInt_AsLong ($input);
|
|
||||||
|
|
||||||
// create the array for the C call
|
|
||||||
$1 = (CvPoint2D32f *) malloc(tmpCount * sizeof (CvPoint2D32f));
|
|
||||||
|
|
||||||
// the size of the array for the C call
|
|
||||||
$2 = tmpCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// the features returned by cvCalcOpticalFlowPyrLK
|
|
||||||
//
|
|
||||||
%typemap(argout) (CvPoint2D32f* curr_features, int count) {
|
|
||||||
int i;
|
|
||||||
octave_value to_add;
|
|
||||||
|
|
||||||
// create the list to return
|
|
||||||
to_add = OctList_New (tmpCount$argnum);
|
|
||||||
|
|
||||||
// extract all the points values of the result, and add it to the
|
|
||||||
// final resulting list
|
|
||||||
for (i = 0; i < tmpCount$argnum; i++) {
|
|
||||||
OctList_SetItem (to_add, i,
|
|
||||||
SWIG_NewPointerObj (&($1 [i]),
|
|
||||||
$descriptor(CvPoint2D32f *), 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = SWIG_AppendResult($result, &to_add, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// status is an output parameters for cvCalcOpticalFlowPyrLK
|
|
||||||
//
|
|
||||||
%typemap (in, numinputs=1) (char *status) (int tmpCountStatus){
|
|
||||||
// as input, we still need the size of the status array
|
|
||||||
|
|
||||||
// memorize the size of the status array
|
|
||||||
tmpCountStatus = (int)OctInt_AsLong ($input);
|
|
||||||
|
|
||||||
// create the status array for the C call
|
|
||||||
$1 = (char *)malloc (tmpCountStatus * sizeof (char));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// the status returned by cvCalcOpticalFlowPyrLK
|
|
||||||
//
|
|
||||||
%typemap(argout) (char *status) {
|
|
||||||
int i;
|
|
||||||
octave_value to_add;
|
|
||||||
|
|
||||||
// create the list to return
|
|
||||||
to_add = OctList_New (tmpCountStatus$argnum);
|
|
||||||
|
|
||||||
// extract all the integer values of the result, and add it to the
|
|
||||||
// final resulting list
|
|
||||||
for (i = 0; i < tmpCountStatus$argnum; i++) {
|
|
||||||
OctList_SetItem (to_add, i, OctBool_FromLong ($1 [i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = SWIG_AppendResult($result, &to_add, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// map one list of points to the two parameters dimenssion/sizes
|
|
||||||
// for cvCalcOpticalFlowPyrLK
|
|
||||||
%typemap(in) (CvPoint2D32f* prev_features) {
|
|
||||||
int i;
|
|
||||||
int size;
|
|
||||||
|
|
||||||
// get the size of the input array
|
|
||||||
size = OctList_Size ($input);
|
|
||||||
|
|
||||||
// allocate the needed memory
|
|
||||||
$1 = (CvPoint2D32f *)malloc (size * sizeof (CvPoint2D32f));
|
|
||||||
|
|
||||||
// extract all the points values from the list
|
|
||||||
for (i = 0; i < size; i++) {
|
|
||||||
octave_value item = OctList_GetItem ($input, i);
|
|
||||||
|
|
||||||
void * vptr;
|
|
||||||
SWIG_Octave_ConvertPtr (item, &vptr,
|
|
||||||
$descriptor(CvPoint2D32f*),
|
|
||||||
SWIG_POINTER_EXCEPTION);
|
|
||||||
CvPoint2D32f *p = (CvPoint2D32f *)vptr;
|
|
||||||
$1 [i].x = p->x;
|
|
||||||
$1 [i].y = p->y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// the corners returned by cvGoodFeaturesToTrack
|
|
||||||
//
|
|
||||||
%typemap (in, numinputs=1) (CvPoint2D32f* corners, int* corner_count)
|
|
||||||
(int tmpCount) {
|
|
||||||
// as input, we still need the size of the corners array
|
|
||||||
|
|
||||||
// memorize the size of the status corners
|
|
||||||
tmpCount = (int)OctInt_AsLong ($input);
|
|
||||||
|
|
||||||
// create the corners array for the C call
|
|
||||||
$1 = (CvPoint2D32f *)malloc (tmpCount * sizeof (CvPoint2D32f));
|
|
||||||
|
|
||||||
// the size of the array for the C call
|
|
||||||
$2 = &tmpCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// the corners returned by cvGoodFeaturesToTrack
|
|
||||||
//
|
|
||||||
%typemap(argout) (CvPoint2D32f* corners, int* corner_count) {
|
|
||||||
int i;
|
|
||||||
octave_value to_add;
|
|
||||||
|
|
||||||
// create the list to return
|
|
||||||
to_add = OctList_New (tmpCount$argnum);
|
|
||||||
|
|
||||||
// extract all the integer values of the result, and add it to the
|
|
||||||
// final resulting list
|
|
||||||
for (i = 0; i < tmpCount$argnum; i++) {
|
|
||||||
OctList_SetItem (to_add, i,
|
|
||||||
SWIG_NewPointerObj (&($1 [i]),
|
|
||||||
$descriptor(CvPoint2D32f *), 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = SWIG_AppendResult($result, &to_add, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// map one list of points to the two parameters dimension/sizes
|
|
||||||
// for cvFindCornerSubPix
|
|
||||||
%typemap(in, numinputs=1) (CvPoint2D32f* corners, int count)
|
|
||||||
(int cornersCount, CvPoint2D32f* corners){
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if(!OctList_Check($input)){
|
|
||||||
error("Expected a list");
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the size of the input array
|
|
||||||
cornersCount = OctList_Size ($input);
|
|
||||||
$2 = cornersCount;
|
|
||||||
|
|
||||||
// allocate the needed memory
|
|
||||||
corners = (CvPoint2D32f *)malloc ($2 * sizeof (CvPoint2D32f));
|
|
||||||
$1 = corners;
|
|
||||||
|
|
||||||
// the size of the array for the C call
|
|
||||||
|
|
||||||
// extract all the points values from the list
|
|
||||||
for (i = 0; i < $2; i++) {
|
|
||||||
octave_value item = OctList_GetItem ($input, i);
|
|
||||||
|
|
||||||
void *vptr;
|
|
||||||
SWIG_Octave_ConvertPtr (item, &vptr,
|
|
||||||
$descriptor(CvPoint2D32f*),
|
|
||||||
SWIG_POINTER_EXCEPTION);
|
|
||||||
CvPoint2D32f *p = (CvPoint2D32f *) vptr;;
|
|
||||||
$1 [i].x = p->x;
|
|
||||||
$1 [i].y = p->y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// the corners returned by cvFindCornerSubPix
|
|
||||||
//
|
|
||||||
%typemap(argout) (CvPoint2D32f* corners, int count) {
|
|
||||||
int i;
|
|
||||||
octave_value to_add;
|
|
||||||
|
|
||||||
// create the list to return
|
|
||||||
to_add = OctList_New (cornersCount$argnum);
|
|
||||||
|
|
||||||
// extract all the corner values of the result, and add it to the
|
|
||||||
// final resulting list
|
|
||||||
for (i = 0; i < cornersCount$argnum; i++) {
|
|
||||||
OctList_SetItem (to_add, i,
|
|
||||||
SWIG_NewPointerObj (&(corners$argnum [i]),
|
|
||||||
$descriptor(CvPoint2D32f *), 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = SWIG_AppendResult( $result, &to_add, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// return the corners for cvFindChessboardCorners
|
|
||||||
//
|
|
||||||
%typemap(in, numinputs=1) (CvSize pattern_size, CvPoint2D32f * corners, int * corner_count )
|
|
||||||
(CvSize * pattern_size, CvPoint2D32f * tmp_corners, int tmp_ncorners) {
|
|
||||||
void * vptr;
|
|
||||||
if( SWIG_ConvertPtr($input, &vptr, $descriptor( CvSize * ), SWIG_POINTER_EXCEPTION ) == -1){
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
pattern_size=(CvSize *)vptr;
|
|
||||||
tmp_ncorners = pattern_size->width*pattern_size->height;
|
|
||||||
|
|
||||||
tmp_corners = (CvPoint2D32f *) malloc(sizeof(CvPoint2D32f)*tmp_ncorners);
|
|
||||||
$1 = *pattern_size;
|
|
||||||
$2 = tmp_corners;
|
|
||||||
$3 = &tmp_ncorners;
|
|
||||||
}
|
|
||||||
|
|
||||||
%typemap(argout) (CvSize pattern_size, CvPoint2D32f * corners, int * corner_count){
|
|
||||||
int i;
|
|
||||||
octave_value to_add;
|
|
||||||
|
|
||||||
// create the list to return
|
|
||||||
to_add = OctList_New ( tmp_ncorners$argnum );
|
|
||||||
|
|
||||||
// extract all the corner values of the result, and add it to the
|
|
||||||
// final resulting list
|
|
||||||
for (i = 0; i < tmp_ncorners$argnum; i++) {
|
|
||||||
CvPoint2D32f * pt = new CvPoint2D32f;
|
|
||||||
pt->x = tmp_corners$argnum[i].x;
|
|
||||||
pt->y = tmp_corners$argnum[i].y;
|
|
||||||
|
|
||||||
OctList_SetItem (to_add, i,
|
|
||||||
SWIG_NewPointerObj( pt, $descriptor(CvPoint2D32f *), 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = SWIG_AppendResult( $result, &to_add, 1);
|
|
||||||
free(tmp_corners$argnum);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// return the matrices for cvCameraCalibrate
|
|
||||||
//
|
|
||||||
%typemap(in, numinputs=0) (CvMat * intrinsic_matrix, CvMat * distortion_coeffs)
|
|
||||||
{
|
|
||||||
$1 = cvCreateMat(3,3,CV_32F);
|
|
||||||
$2 = cvCreateMat(4,1,CV_32F);
|
|
||||||
}
|
|
||||||
|
|
||||||
%typemap(argout) (CvMat * intrinsic_matrix, CvMat * distortion_coeffs)
|
|
||||||
{
|
|
||||||
octave_value to_add[2];
|
|
||||||
to_add[0] = SWIG_NewPointerObj($1, $descriptor(CvMat *), 1);
|
|
||||||
to_add[1] = SWIG_NewPointerObj($2, $descriptor(CvMat *), 1);
|
|
||||||
$result = SWIG_AppendResult( $result, to_add, 2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Fix OpenCV inheritance for CvSeq, CvSet, CvGraph
|
|
||||||
// Otherwise, can't call CvSeq functions on CvSet or CvGraph
|
|
||||||
//
|
|
||||||
%typemap(in, numinputs=1) (CvSeq *) (void * ptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
if( SWIG_ConvertPtr($input, &ptr, $descriptor(CvSeq *), 0) == -1 &&
|
|
||||||
SWIG_ConvertPtr($input, &ptr, $descriptor(CvSet *), 0) == -1 &&
|
|
||||||
SWIG_ConvertPtr($input, &ptr, $descriptor(CvGraph *), 0) == -1 &&
|
|
||||||
SWIG_ConvertPtr($input, &ptr, $descriptor(CvSubdiv2D *), 0) == -1 &&
|
|
||||||
SWIG_ConvertPtr($input, &ptr, $descriptor(CvChain *), 0) == -1 &&
|
|
||||||
SWIG_ConvertPtr($input, &ptr, $descriptor(CvContour *), 0) == -1 &&
|
|
||||||
SWIG_ConvertPtr($input, &ptr, $descriptor(CvContourTree *), 0) == -1 )
|
|
||||||
{
|
|
||||||
SWIG_exception (SWIG_TypeError, "could not convert to CvSeq");
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
$1 = (CvSeq *) ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
%typemap(in, numinputs=1) (CvSet *) (void * ptr)
|
|
||||||
{
|
|
||||||
if( SWIG_ConvertPtr($input, &ptr, $descriptor(CvSet *), 0) == -1 &&
|
|
||||||
SWIG_ConvertPtr($input, &ptr, $descriptor(CvGraph *), 0) == -1 &&
|
|
||||||
SWIG_ConvertPtr($input, &ptr, $descriptor(CvSubdiv2D *), 0) == -1)
|
|
||||||
{
|
|
||||||
SWIG_exception (SWIG_TypeError, "could not convert to CvSet");
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
$1 = (CvSet *)ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
%typemap(in, numinputs=1) (CvGraph *) (void * ptr)
|
|
||||||
{
|
|
||||||
if( SWIG_ConvertPtr($input, &ptr, $descriptor(CvGraph *), 0) == -1 &&
|
|
||||||
SWIG_ConvertPtr($input, &ptr, $descriptor(CvSubdiv2D *), 0) == -1)
|
|
||||||
{
|
|
||||||
SWIG_exception (SWIG_TypeError, "could not convert to CvGraph");
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
$1 = (CvGraph *)ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Remap output arguments to multiple return values for cvMinEnclosingCircle
|
|
||||||
//
|
|
||||||
%typemap(in, numinputs=0) (CvPoint2D32f * center, float * radius) (CvPoint2D32f * tmp_center, float tmp_radius)
|
|
||||||
{
|
|
||||||
tmp_center = (CvPoint2D32f *) malloc(sizeof(CvPoint2D32f));
|
|
||||||
$1 = tmp_center;
|
|
||||||
$2 = &tmp_radius;
|
|
||||||
}
|
|
||||||
%typemap(argout) (CvPoint2D32f * center, float * radius)
|
|
||||||
{
|
|
||||||
octave_value to_add[2];
|
|
||||||
to_add[0] = SWIG_NewPointerObj( tmp_center$argnum, $descriptor(CvPoint2D32f *), 1);
|
|
||||||
to_add[1] = OctFloat_FromDouble( tmp_radius$argnum );
|
|
||||||
|
|
||||||
$result = SWIG_AppendResult($result, to_add, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoxPoints
|
|
||||||
%typemap(in, numinputs=0) (CvPoint2D32f pt[4]) (CvPoint2D32f tmp_pts[4])
|
|
||||||
{
|
|
||||||
$1 = tmp_pts;
|
|
||||||
}
|
|
||||||
%typemap(argout) (CvPoint2D32f pt[4])
|
|
||||||
{
|
|
||||||
octave_value to_add = OctList_New(4);
|
|
||||||
int i;
|
|
||||||
for(i=0; i<4; i++){
|
|
||||||
CvPoint2D32f * p = new CvPoint2D32f;
|
|
||||||
*p = tmp_pts$argnum[i];
|
|
||||||
OctList_SetItem(to_add, i, SWIG_NewPointerObj( p, $descriptor(CvPoint2D32f *), 1 ) );
|
|
||||||
}
|
|
||||||
$result = SWIG_AppendResult($result, &to_add, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Macro to wrap a built-in type that is used as an object like CvRNG and CvSubdiv2DEdge
|
|
||||||
%define %wrap_builtin(type)
|
|
||||||
%inline %{
|
|
||||||
// Wrapper class
|
|
||||||
class type##_Wrapper {
|
|
||||||
private:
|
|
||||||
type m_val;
|
|
||||||
public:
|
|
||||||
type##_Wrapper( const type & val ) :
|
|
||||||
m_val(val)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
type * ptr() { return &m_val; }
|
|
||||||
type & ref() { return m_val; }
|
|
||||||
bool operator==(const type##_Wrapper & x){
|
|
||||||
return m_val==x.m_val;
|
|
||||||
}
|
|
||||||
bool operator!=(const type##_Wrapper & x){
|
|
||||||
return m_val!=x.m_val;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
%}
|
|
||||||
%typemap(out) type
|
|
||||||
{
|
|
||||||
type##_Wrapper * wrapper = new type##_Wrapper( $1 );
|
|
||||||
$result = SWIG_NewPointerObj( wrapper, $descriptor( type##_Wrapper * ), 1 );
|
|
||||||
}
|
|
||||||
%typemap(out) type *
|
|
||||||
{
|
|
||||||
type##_Wrapper * wrapper = new type##_Wrapper( *($1) );
|
|
||||||
$result = SWIG_NewPointerObj( wrapper, $descriptor( type##_Wrapper * ), 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
%typemap(in) (type *) (void * vptr, type##_Wrapper * wrapper){
|
|
||||||
if(SWIG_ConvertPtr($input, &vptr, $descriptor(type##_Wrapper *), 0)==-1){
|
|
||||||
SWIG_exception( SWIG_TypeError, "could not convert Octave object to C value");
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
wrapper = (type##_Wrapper *) vptr;
|
|
||||||
$1 = wrapper->ptr();
|
|
||||||
}
|
|
||||||
%typemap(in) (type) (void * vptr, type##_Wrapper * wrapper){
|
|
||||||
if(SWIG_ConvertPtr($input, &vptr, $descriptor(type##_Wrapper *), 0)==-1){
|
|
||||||
SWIG_exception( SWIG_TypeError, "could not convert Octave object to C value");
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
wrapper = (type##_Wrapper *) vptr;
|
|
||||||
$1 = wrapper->ref();
|
|
||||||
}
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// Application of wrapper class to built-in types
|
|
||||||
%wrap_builtin(CvRNG);
|
|
||||||
%wrap_builtin(CvSubdiv2DEdge);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Allow CvQuadEdge2D to be interpreted as CvSubdiv2DEdge
|
|
||||||
//
|
|
||||||
%typemap(in, numinputs=1) (CvSubdiv2DEdge) (CvSubdiv2DEdge_Wrapper * wrapper, CvQuadEdge2D * qedge, void *vptr)
|
|
||||||
{
|
|
||||||
if( SWIG_ConvertPtr($input, &vptr, $descriptor(CvSubdiv2DEdge_Wrapper *), 0) != -1 ){
|
|
||||||
wrapper = (CvSubdiv2DEdge_Wrapper *) vptr;
|
|
||||||
$1 = wrapper->ref();
|
|
||||||
}
|
|
||||||
else if( SWIG_ConvertPtr($input, &vptr, $descriptor(CvQuadEdge2D *), 0) != -1 ){
|
|
||||||
qedge = (CvQuadEdge2D *) vptr;
|
|
||||||
$1 = (CvSubdiv2DEdge)qedge;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
SWIG_exception( SWIG_TypeError, "could not convert to CvSubdiv2DEdge");
|
|
||||||
SWIG_fail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// return the vertex and edge for cvSubdiv2DLocate
|
|
||||||
//
|
|
||||||
%typemap(in, numinputs=0) (CvSubdiv2DEdge * edge, CvSubdiv2DPoint ** vertex)
|
|
||||||
(CvSubdiv2DEdge tmpEdge, CvSubdiv2DPoint * tmpVertex)
|
|
||||||
{
|
|
||||||
$1 = &tmpEdge;
|
|
||||||
$2 = &tmpVertex;
|
|
||||||
}
|
|
||||||
%typemap(argout) (CvSubdiv2DEdge * edge, CvSubdiv2DPoint ** vertex)
|
|
||||||
{
|
|
||||||
octave_value to_add[2];
|
|
||||||
if(result==CV_PTLOC_INSIDE || result==CV_PTLOC_ON_EDGE){
|
|
||||||
CvSubdiv2DEdge_Wrapper * wrapper = new CvSubdiv2DEdge_Wrapper( tmpEdge$argnum );
|
|
||||||
to_add[0] = SWIG_NewPointerObj( wrapper, $descriptor(CvSubdiv2DEdge_Wrapper *), 0);
|
|
||||||
to_add[1] = octave_value();
|
|
||||||
}
|
|
||||||
if(result==CV_PTLOC_VERTEX){
|
|
||||||
to_add[0] = octave_value();
|
|
||||||
to_add[1] = SWIG_NewPointerObj( tmpVertex$argnum, $descriptor(CvSubdiv2DPoint *), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = SWIG_AppendResult($result, to_add, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// int *value in cvCreateTrackbar() is only used for input in the Octave wrapper.
|
|
||||||
// for output, use the pos in the callback
|
|
||||||
// TODO: remove the memory leak introducted by the malloc () (if needed).
|
|
||||||
//
|
|
||||||
%typemap(in, numinputs=1) (int *value)
|
|
||||||
{
|
|
||||||
$1 = (int *)malloc (sizeof (int));
|
|
||||||
*$1 = OctInt_AsLong ($input);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
_cv
|
|
||||||
_ml
|
|
||||||
_highgui
|
|
@ -1 +0,0 @@
|
|||||||
build
|
|
@ -1,118 +0,0 @@
|
|||||||
# ----------------------------------------------------------------------------
|
|
||||||
# CMake file for python support
|
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
project(python_support)
|
|
||||||
|
|
||||||
find_package(SWIG REQUIRED)
|
|
||||||
include(${SWIG_USE_FILE})
|
|
||||||
|
|
||||||
include_directories(${PYTHON_INCLUDE_PATH})
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../filtered)
|
|
||||||
|
|
||||||
if(MSVC)
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# ----------------------------------- cv module ------------------------------
|
|
||||||
|
|
||||||
set_source_files_properties(cv.i PROPERTIES
|
|
||||||
CPLUSPLUS ON
|
|
||||||
SWIG_FLAGS -includeall
|
|
||||||
SWIG_FLAGS -DSKIP_INCLUDES
|
|
||||||
)
|
|
||||||
|
|
||||||
set(opencv_headers
|
|
||||||
${CMAKE_SOURCE_DIR}/include/opencv/cxtypes.h
|
|
||||||
${CMAKE_SOURCE_DIR}/include/opencv/cxcore.h
|
|
||||||
${CMAKE_SOURCE_DIR}/include/opencv/cvtypes.h
|
|
||||||
${CMAKE_SOURCE_DIR}/include/opencv/cv.h
|
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cvaliases_autogen.i
|
|
||||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/utils/extract_aliases.py
|
|
||||||
${opencv_headers} > ${CMAKE_CURRENT_BINARY_DIR}/cvaliases_autogen.i
|
|
||||||
DEPENDS ${opencv_headers}
|
|
||||||
)
|
|
||||||
|
|
||||||
set(SWIG_MODULE_cv_EXTRA_DEPS
|
|
||||||
imagedata.i cvarr.i ${CMAKE_CURRENT_BINARY_DIR}/cvaliases_autogen.i cvaliases.i pyhelpers.i
|
|
||||||
nointpb.i pytypemaps.i cvshadow.i cvseq.i
|
|
||||||
../general/cv.i ../general/memory.i ../general/typemaps.i
|
|
||||||
../general/extensions.i ../general/doublepointers.i
|
|
||||||
../general/sizeof.i ../general/cvmacros.i
|
|
||||||
)
|
|
||||||
|
|
||||||
SWIG_ADD_MODULE(cv python cv.i cvshadow.cpp error.cpp error.h pyhelpers.cpp pyhelpers.h cvshadow.h pycvseq.hpp)
|
|
||||||
SWIG_LINK_LIBRARIES(cv ${PYTHON_LIBRARIES} cxcore cv)
|
|
||||||
|
|
||||||
# ----------------------------------- ml module ------------------------------
|
|
||||||
|
|
||||||
set_source_files_properties(ml.i PROPERTIES
|
|
||||||
CPLUSPLUS ON
|
|
||||||
SWIG_FLAGS -includeall
|
|
||||||
SWIG_FLAGS -DSKIP_INCLUDES
|
|
||||||
)
|
|
||||||
|
|
||||||
set(SWIG_MODULE_ml_EXTRA_DEPS
|
|
||||||
nointpb.i pytypemaps.i
|
|
||||||
../general/memory.i ../general/typemaps.i
|
|
||||||
${CMAKE_SOURCE_DIR}/include/opencv/ml.h
|
|
||||||
)
|
|
||||||
|
|
||||||
SWIG_ADD_MODULE(ml python ml.i pyhelpers.cpp pyhelpers.h)
|
|
||||||
SWIG_LINK_LIBRARIES(ml ${PYTHON_LIBRARIES} cxcore ml)
|
|
||||||
|
|
||||||
# --------------------------------highgui module ------------------------------
|
|
||||||
|
|
||||||
set_source_files_properties(highgui.i PROPERTIES
|
|
||||||
CPLUSPLUS ON
|
|
||||||
SWIG_FLAGS -includeall
|
|
||||||
SWIG_FLAGS -DSKIP_INCLUDES
|
|
||||||
)
|
|
||||||
|
|
||||||
set(SWIG_MODULE_highgui_EXTRA_DEPS
|
|
||||||
nointpb.i pytypemaps.i
|
|
||||||
../general/highgui.i
|
|
||||||
../general/memory.i ../general/typemaps.i
|
|
||||||
${CMAKE_SOURCE_DIR}/include/opencv/highgui.h
|
|
||||||
)
|
|
||||||
|
|
||||||
SWIG_ADD_MODULE(highgui python highgui.i pyhelpers.cpp pyhelpers.h)
|
|
||||||
SWIG_LINK_LIBRARIES(highgui ${PYTHON_LIBRARIES} cxcore cv highgui)
|
|
||||||
|
|
||||||
# ------------------------------ installation ----------------------------------
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
set_target_properties(
|
|
||||||
${SWIG_MODULE_cv_REAL_NAME}
|
|
||||||
${SWIG_MODULE_ml_REAL_NAME}
|
|
||||||
${SWIG_MODULE_highgui_REAL_NAME}
|
|
||||||
PROPERTIES SUFFIX ".pyd")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
get_target_property(LOC_CV ${SWIG_MODULE_cv_REAL_NAME} LOCATION)
|
|
||||||
get_target_property(LOC_ML ${SWIG_MODULE_ml_REAL_NAME} LOCATION)
|
|
||||||
get_target_property(LOC_HIGHGUI ${SWIG_MODULE_highgui_REAL_NAME} LOCATION)
|
|
||||||
|
|
||||||
set(pyopencv_files __init__.py adaptors.py matlab_syntax.py
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/cv.py
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/ml.py
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/highgui.py)
|
|
||||||
|
|
||||||
foreach(m ${LOC_CV} ${LOC_ML} ${LOC_HIGHGUI})
|
|
||||||
string(REPLACE "\$(OutDir)" "\${CMAKE_INSTALL_CONFIG_NAME}" m1 ${m})
|
|
||||||
set(pyopencv_files ${pyopencv_files} ${m1})
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: need to compile *.py files
|
|
||||||
if(WIN32)
|
|
||||||
install(FILES ${pyopencv_files} DESTINATION
|
|
||||||
"Python${PYTHON_VERSION_MAJOR_MINOR}/Lib/site-packages/opencv"
|
|
||||||
COMPONENT main)
|
|
||||||
else()
|
|
||||||
install(FILES ${pyopencv_files} DESTINATION ${PYTHON_PLUGIN_INSTALL_PATH} COMPONENT main)
|
|
||||||
endif()
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
|||||||
#########################################################################################
|
|
||||||
#
|
|
||||||
# IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
#
|
|
||||||
# By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
# If you do not agree to this license, do not download, install,
|
|
||||||
# copy or use the software.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Intel License Agreement
|
|
||||||
# For Open Source Computer Vision Library
|
|
||||||
#
|
|
||||||
# Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
# Third party copyrights are property of their respective owners.
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
# are permitted provided that the following conditions are met:
|
|
||||||
#
|
|
||||||
# * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
# this list of conditions and the following disclaimer.
|
|
||||||
#
|
|
||||||
# * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
# this list of conditions and the following disclaimer in the documentation
|
|
||||||
# and/or other materials provided with the distribution.
|
|
||||||
#
|
|
||||||
# * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
# derived from this software without specific prior written permission.
|
|
||||||
#
|
|
||||||
# This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
# any express or implied warranties, including, but not limited to, the implied
|
|
||||||
# warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
# In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
# indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
# (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
# loss of use, data, or profits; or business interruption) however caused
|
|
||||||
# and on any theory of liability, whether in contract, strict liability,
|
|
||||||
# or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
# the use of this software, even if advised of the possibility of such damage.
|
|
||||||
#
|
|
||||||
#########################################################################################
|
|
||||||
|
|
||||||
# 2004-03-16, Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
# Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
|
|
||||||
"""The Open Computer Vision Library
|
|
||||||
|
|
||||||
OpenCV is the Open Computer Vision library, an open source effort originally started
|
|
||||||
by intel to provide computer vision algorithms for standard PC hardware.
|
|
||||||
|
|
||||||
This wrapper was semi-automatically created from the C/C++ headers and therefore
|
|
||||||
contains no Python documentation. Because all identifiers are identical to their
|
|
||||||
C/C++ counterparts, you can consult the standard manuals that come with OpenCV.
|
|
||||||
|
|
||||||
In detail, this python package contains four sub-modules:
|
|
||||||
|
|
||||||
cv core components (cxcore and cv)
|
|
||||||
ml machine learning
|
|
||||||
highgui simple user interface, video and image I/O
|
|
||||||
adaptors pure python module offering conversion to numpy/scipy matrices
|
|
||||||
and PIL (python imaging library) images
|
|
||||||
matlab_syntax pure python module offering syntax that is similar to Matlab
|
|
||||||
for those who switched
|
|
||||||
|
|
||||||
All methods and data types from cv, ml and adaptors are automatically imported into
|
|
||||||
the opencv namespace. Contents from highgui and matlab_syntax must be explicitly
|
|
||||||
imported - to avoid conflicts with other UI toolkits and the python matlab interface.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# the module consists of these four sub-modules
|
|
||||||
__all__ = ['cv', 'ml', 'highgui', 'adaptors', 'matlab_syntax']
|
|
||||||
|
|
||||||
# always import functionality from cxcore, cv and ml to this namespace
|
|
||||||
# try to import PIL and numpy adaptors
|
|
||||||
from cv import *
|
|
||||||
from ml import *
|
|
||||||
from adaptors import *
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,339 +0,0 @@
|
|||||||
#########################################################################################
|
|
||||||
#
|
|
||||||
# IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
#
|
|
||||||
# By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
# If you do not agree to this license, do not download, install,
|
|
||||||
# copy or use the software.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Intel License Agreement
|
|
||||||
# For Open Source Computer Vision Library
|
|
||||||
#
|
|
||||||
# Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
# Third party copyrights are property of their respective owners.
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
# are permitted provided that the following conditions are met:
|
|
||||||
#
|
|
||||||
# * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
# this list of conditions and the following disclaimer.
|
|
||||||
#
|
|
||||||
# * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
# this list of conditions and the following disclaimer in the documentation
|
|
||||||
# and/or other materials provided with the distribution.
|
|
||||||
#
|
|
||||||
# * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
# derived from this software without specific prior written permission.
|
|
||||||
#
|
|
||||||
# This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
# any express or implied warranties, including, but not limited to, the implied
|
|
||||||
# warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
# In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
# indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
# (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
# loss of use, data, or profits; or business interruption) however caused
|
|
||||||
# and on any theory of liability, whether in contract, strict liability,
|
|
||||||
# or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
# the use of this software, even if advised of the possibility of such damage.
|
|
||||||
#
|
|
||||||
#########################################################################################
|
|
||||||
|
|
||||||
|
|
||||||
# 2004-03-16, Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
# Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
# 2007-02-xx, direct interface to numpy by Vicent Mas <vmas@carabos.com>
|
|
||||||
# Carabos Coop. V.
|
|
||||||
# 2007-10-08, try/catch
|
|
||||||
|
|
||||||
"""Adaptors to interchange data with numpy and/or PIL
|
|
||||||
|
|
||||||
This module provides explicit conversion of OpenCV images/matrices to and from
|
|
||||||
the Python Imaging Library (PIL) and python's newest numeric library (numpy).
|
|
||||||
|
|
||||||
Currently supported image/matrix formats are:
|
|
||||||
- 3 x 8 bit RGB (GBR)
|
|
||||||
- 1 x 8 bit Grayscale
|
|
||||||
- 1 x 32 bit Float
|
|
||||||
|
|
||||||
In numpy, images are represented as multidimensional arrays with
|
|
||||||
a third dimension representing the image channels if more than one
|
|
||||||
channel is present.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import cv
|
|
||||||
|
|
||||||
try:
|
|
||||||
import PIL.Image
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
def Ipl2PIL(input):
|
|
||||||
"""Converts an OpenCV/IPL image to PIL the Python Imaging Library.
|
|
||||||
|
|
||||||
Supported input image formats are
|
|
||||||
IPL_DEPTH_8U x 1 channel
|
|
||||||
IPL_DEPTH_8U x 3 channels
|
|
||||||
IPL_DEPTH_32F x 1 channel
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not isinstance(input, cv.CvMat):
|
|
||||||
raise TypeError, 'must be called with a cv.CvMat!'
|
|
||||||
|
|
||||||
#orientation
|
|
||||||
if input.origin == 0:
|
|
||||||
orientation = 1 # top left
|
|
||||||
elif input.origin == 1:
|
|
||||||
orientation = -1 # bottom left
|
|
||||||
else:
|
|
||||||
raise ValueError, 'origin must be 0 or 1!'
|
|
||||||
|
|
||||||
# mode dictionary:
|
|
||||||
# (channels, depth) : (source mode, dest mode, depth in byte)
|
|
||||||
mode_list = {
|
|
||||||
(1, cv.IPL_DEPTH_8U) : ("L", "L", 1),
|
|
||||||
(3, cv.IPL_DEPTH_8U) : ("BGR", "RGB", 3),
|
|
||||||
(1, cv.IPL_DEPTH_32F) : ("F", "F", 4)
|
|
||||||
}
|
|
||||||
|
|
||||||
key = (input.nChannels, input.depth)
|
|
||||||
if not mode_list.has_key(key):
|
|
||||||
raise ValueError, 'unknown or unsupported input mode'
|
|
||||||
|
|
||||||
modes = mode_list[key]
|
|
||||||
|
|
||||||
return PIL.Image.fromstring(
|
|
||||||
modes[1], # mode
|
|
||||||
(input.width, input.height), # size tuple
|
|
||||||
input.imageData, # data
|
|
||||||
"raw",
|
|
||||||
modes[0], # raw mode
|
|
||||||
input.widthStep, # stride
|
|
||||||
orientation # orientation
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
def PIL2Ipl(input):
|
|
||||||
"""Converts a PIL image to the OpenCV/IPL CvMat data format.
|
|
||||||
|
|
||||||
Supported input image formats are:
|
|
||||||
RGB
|
|
||||||
L
|
|
||||||
F
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not (isinstance(input, PIL.Image.Image)):
|
|
||||||
raise TypeError, 'Must be called with PIL.Image.Image!'
|
|
||||||
|
|
||||||
# mode dictionary:
|
|
||||||
# (pil_mode : (ipl_depth, ipl_channels)
|
|
||||||
mode_list = {
|
|
||||||
"RGB" : (cv.IPL_DEPTH_8U, 3),
|
|
||||||
"L" : (cv.IPL_DEPTH_8U, 1),
|
|
||||||
"F" : (cv.IPL_DEPTH_32F, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
if not mode_list.has_key(input.mode):
|
|
||||||
raise ValueError, 'unknown or unsupported input mode'
|
|
||||||
|
|
||||||
result = cv.cvCreateImage(
|
|
||||||
cv.cvSize(input.size[0], input.size[1]), # size
|
|
||||||
mode_list[input.mode][0], # depth
|
|
||||||
mode_list[input.mode][1] # channels
|
|
||||||
)
|
|
||||||
|
|
||||||
# set imageData
|
|
||||||
result.imageData = input.tostring()
|
|
||||||
return result
|
|
||||||
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
|
||||||
#############################################################################
|
|
||||||
|
|
||||||
try:
|
|
||||||
|
|
||||||
import numpy
|
|
||||||
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
def NumPy2Ipl(input):
|
|
||||||
"""Converts a numpy array to the OpenCV/IPL CvMat data format.
|
|
||||||
|
|
||||||
Supported input array layouts:
|
|
||||||
2 dimensions of numpy.uint8
|
|
||||||
3 dimensions of numpy.uint8
|
|
||||||
2 dimensions of numpy.float32
|
|
||||||
2 dimensions of numpy.float64
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not isinstance(input, numpy.ndarray):
|
|
||||||
raise TypeError, 'Must be called with numpy.ndarray!'
|
|
||||||
|
|
||||||
# Check the number of dimensions of the input array
|
|
||||||
ndim = input.ndim
|
|
||||||
if not ndim in (2, 3):
|
|
||||||
raise ValueError, 'Only 2D-arrays and 3D-arrays are supported!'
|
|
||||||
|
|
||||||
# Get the number of channels
|
|
||||||
if ndim == 2:
|
|
||||||
channels = 1
|
|
||||||
else:
|
|
||||||
channels = input.shape[2]
|
|
||||||
|
|
||||||
# Get the image depth
|
|
||||||
if input.dtype == numpy.uint8:
|
|
||||||
depth = cv.IPL_DEPTH_8U
|
|
||||||
elif input.dtype == numpy.float32:
|
|
||||||
depth = cv.IPL_DEPTH_32F
|
|
||||||
elif input.dtype == numpy.float64:
|
|
||||||
depth = cv.IPL_DEPTH_64F
|
|
||||||
|
|
||||||
# supported modes list: [(channels, dtype), ...]
|
|
||||||
modes_list = [(1, numpy.uint8), (3, numpy.uint8), (1, numpy.float32), (1, numpy.float64)]
|
|
||||||
|
|
||||||
# Check if the input array layout is supported
|
|
||||||
if not (channels, input.dtype) in modes_list:
|
|
||||||
raise ValueError, 'Unknown or unsupported input mode'
|
|
||||||
|
|
||||||
result = cv.cvCreateImage(
|
|
||||||
cv.cvSize(input.shape[1], input.shape[0]), # size
|
|
||||||
depth, # depth
|
|
||||||
channels # channels
|
|
||||||
)
|
|
||||||
|
|
||||||
# set imageData
|
|
||||||
result.imageData = input.tostring()
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
def Ipl2NumPy(input):
|
|
||||||
"""Converts an OpenCV/IPL image to a numpy array.
|
|
||||||
|
|
||||||
Supported input image formats are
|
|
||||||
IPL_DEPTH_8U x 1 channel
|
|
||||||
IPL_DEPTH_8U x 3 channels
|
|
||||||
IPL_DEPTH_32F x 1 channel
|
|
||||||
IPL_DEPTH_32F x 2 channels
|
|
||||||
IPL_DEPTH_32S x 1 channel
|
|
||||||
IPL_DEPTH_64F x 1 channel
|
|
||||||
IPL_DEPTH_64F x 2 channels
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not isinstance(input, cv.CvMat):
|
|
||||||
raise TypeError, 'must be called with a cv.CvMat!'
|
|
||||||
|
|
||||||
# data type dictionary:
|
|
||||||
# (channels, depth) : numpy dtype
|
|
||||||
ipl2dtype = {
|
|
||||||
(1, cv.IPL_DEPTH_8U) : numpy.uint8,
|
|
||||||
(3, cv.IPL_DEPTH_8U) : numpy.uint8,
|
|
||||||
(1, cv.IPL_DEPTH_32F) : numpy.float32,
|
|
||||||
(2, cv.IPL_DEPTH_32F) : numpy.float32,
|
|
||||||
(1, cv.IPL_DEPTH_32S) : numpy.int32,
|
|
||||||
(1, cv.IPL_DEPTH_64F) : numpy.float64,
|
|
||||||
(2, cv.IPL_DEPTH_64F) : numpy.float64
|
|
||||||
}
|
|
||||||
|
|
||||||
key = (input.nChannels, input.depth)
|
|
||||||
if not ipl2dtype.has_key(key):
|
|
||||||
raise ValueError, 'unknown or unsupported input mode'
|
|
||||||
|
|
||||||
# Get the numpy array and reshape it correctly
|
|
||||||
# ATTENTION: flipped dimensions width/height on 2007-11-15
|
|
||||||
if input.nChannels == 1:
|
|
||||||
array_1d = numpy.fromstring(input.imageData, dtype=ipl2dtype[key])
|
|
||||||
return numpy.reshape(array_1d, (input.height, input.width))
|
|
||||||
elif input.nChannels == 2:
|
|
||||||
array_1d = numpy.fromstring(input.imageData, dtype=ipl2dtype[key])
|
|
||||||
return numpy.reshape(array_1d, (input.height, input.width, 2))
|
|
||||||
elif input.nChannels == 3:
|
|
||||||
# Change the order of channels from BGR to RGB
|
|
||||||
rgb = cv.cvCreateImage(cv.cvSize(input.width, input.height), input.depth, 3)
|
|
||||||
cv.cvCvtColor(input, rgb, cv.CV_BGR2RGB)
|
|
||||||
array_1d = numpy.fromstring(rgb.imageData, dtype=ipl2dtype[key])
|
|
||||||
return numpy.reshape(array_1d, (input.height, input.width, 3))
|
|
||||||
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
###########################################################################
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
|
|
||||||
import PIL.Image
|
|
||||||
import numpy
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
def PIL2NumPy(input):
|
|
||||||
"""THIS METHOD IS DEPRECATED
|
|
||||||
|
|
||||||
Converts a PIL image to a numpy array.
|
|
||||||
|
|
||||||
Supported input image formats are:
|
|
||||||
RGB
|
|
||||||
L
|
|
||||||
F
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not (isinstance(input, PIL.Image.Image)):
|
|
||||||
raise TypeError, 'Must be called with PIL.Image.Image!'
|
|
||||||
|
|
||||||
# modes dictionary:
|
|
||||||
# pil_mode : numpy dtype
|
|
||||||
modes_map = {
|
|
||||||
"RGB" : numpy.uint8,
|
|
||||||
"L" : numpy.uint8,
|
|
||||||
"F" : numpy.float32
|
|
||||||
}
|
|
||||||
|
|
||||||
if not modes_map.has_key(input.mode):
|
|
||||||
raise ValueError, 'Unknown or unsupported input mode!. Supported modes are RGB, L and F.'
|
|
||||||
|
|
||||||
result_ro = numpy.asarray(input, dtype=modes_map[input.mode]) # Read-only array
|
|
||||||
return result_ro.copy() # Return a writeable array
|
|
||||||
|
|
||||||
|
|
||||||
###########################################################################
|
|
||||||
def NumPy2PIL(input):
|
|
||||||
"""THIS METHOD IS DEPRECATED
|
|
||||||
|
|
||||||
Converts a numpy array to a PIL image.
|
|
||||||
|
|
||||||
Supported input array layouts:
|
|
||||||
2 dimensions of numpy.uint8
|
|
||||||
3 dimensions of numpy.uint8
|
|
||||||
2 dimensions of numpy.float32
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not isinstance(input, numpy.ndarray):
|
|
||||||
raise TypeError, 'Must be called with numpy.ndarray!'
|
|
||||||
|
|
||||||
# Check the number of dimensions of the input array
|
|
||||||
ndim = input.ndim
|
|
||||||
if not ndim in (2, 3):
|
|
||||||
raise ValueError, 'Only 2D-arrays and 3D-arrays are supported!'
|
|
||||||
|
|
||||||
if ndim == 2:
|
|
||||||
channels = 1
|
|
||||||
else:
|
|
||||||
channels = input.shape[2]
|
|
||||||
|
|
||||||
# supported modes list: [(channels, dtype), ...]
|
|
||||||
modes_list = [(1, numpy.uint8), (3, numpy.uint8), (1, numpy.float32)]
|
|
||||||
|
|
||||||
mode = (channels, input.dtype)
|
|
||||||
if not mode in modes_list:
|
|
||||||
raise ValueError, 'Unknown or unsupported input mode'
|
|
||||||
|
|
||||||
return PIL.Image.fromarray(input)
|
|
||||||
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
@ -1,98 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
// 2004-03-16, Gabriel Schreiber <schreiber@ient.rwth-aachen.de>
|
|
||||||
// Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
// Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
%{
|
|
||||||
#include "pyhelpers.h"
|
|
||||||
#include "pycvseq.hpp"
|
|
||||||
#include "error.h"
|
|
||||||
%}
|
|
||||||
|
|
||||||
|
|
||||||
// direct SWIG to generate python docstrings
|
|
||||||
%feature("autodoc", 1);
|
|
||||||
|
|
||||||
// include python-specific files
|
|
||||||
%include "./nointpb.i"
|
|
||||||
%include "./pytypemaps.i"
|
|
||||||
%include "./cvshadow.i"
|
|
||||||
|
|
||||||
// parse OpenCV headers
|
|
||||||
%include "../general/cv.i"
|
|
||||||
|
|
||||||
// Accessors for the CvMat and IplImage data structure are defined here
|
|
||||||
%include "./cvarr.i"
|
|
||||||
|
|
||||||
// Python sequence compatibility for CvSeq
|
|
||||||
%include "./cvseq.i"
|
|
||||||
|
|
||||||
|
|
||||||
%include "./imagedata.i"
|
|
||||||
|
|
||||||
// We integrate OpenCV error handling into the Python exception mechanism
|
|
||||||
%include "./error.h"
|
|
||||||
|
|
||||||
|
|
||||||
// include some wrappers to manipulate CvSeq types
|
|
||||||
%include "./pycvseq.hpp"
|
|
||||||
|
|
||||||
// aliases from #defines
|
|
||||||
%include "./cvaliases_autogen.i"
|
|
||||||
%include "./cvaliases.i"
|
|
||||||
|
|
||||||
%pythoncode
|
|
||||||
%{
|
|
||||||
|
|
||||||
__doc__ = """
|
|
||||||
OpenCV is the Intel Open CV library, an open source effort to provide
|
|
||||||
computer vision algorithms for standard PC hardware.
|
|
||||||
|
|
||||||
This wrapper was semi-automatically created from the C/C++ headers and therefore
|
|
||||||
contains no Python documentation. Because all identifiers are identical to their
|
|
||||||
C/C++ counterparts, you can consult the standard manuals that come with OpenCV.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# this tells OpenCV not to call exit() on errors but throw a python exception instead
|
|
||||||
cvRedirectError(function_ptr_generator(), void_ptr_generator(), void_ptrptr_generator())
|
|
||||||
|
|
||||||
%}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,61 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
/*M//
|
|
||||||
// This file contains custom python-based aliases for some methods where
|
|
||||||
// an autogenerated wrapper was unusable or missing.
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
// This macro removes the wrapper for the function from_name, and creates
|
|
||||||
// an alias to to_name, so calling from_name() will invoke to_name()
|
|
||||||
%define %myalias(from_name, to_name)
|
|
||||||
%ignore from_name;
|
|
||||||
%pythoncode%{
|
|
||||||
from_name = to_name;
|
|
||||||
%}
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// Map functions using IplImage ** argument to CvArr ** function instead
|
|
||||||
%myalias(cvCalcBackProject, cvCalcArrBackProject);
|
|
||||||
%myalias(cvCalcBackProjectPatch, cvCalcArrBackProjectPatch);
|
|
||||||
%myalias(cvCalcImageHist, cvCalcArrHist);
|
|
||||||
%myalias(cvCalcHist, cvCalcArrHist);
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
|||||||
/** This file was automatically generated using util/extract_aliases.py script */
|
|
||||||
%module cv
|
|
||||||
%pythoncode %{
|
|
||||||
IPL_ALIGN_DWORD=IPL_ALIGN_4BYTES
|
|
||||||
IPL_ALIGN_QWORD=IPL_ALIGN_8BYTES
|
|
||||||
CV_MAKE_TYPE=CV_MAKETYPE
|
|
||||||
CV_IS_CONT_MAT=CV_IS_MAT_CONT
|
|
||||||
CV_HIST_TREE=CV_HIST_SPARSE
|
|
||||||
CV_TERMCRIT_NUMBER=CV_TERMCRIT_ITER
|
|
||||||
CV_SEQ_ELTYPE_PTR=CV_USRTYPE1
|
|
||||||
CV_GRAPH=CV_SEQ_KIND_GRAPH
|
|
||||||
CV_SEQ_CONTOUR=CV_SEQ_POLYGON
|
|
||||||
CV_STORAGE_WRITE_TEXT=CV_STORAGE_WRITE
|
|
||||||
CV_STORAGE_WRITE_BINARY=CV_STORAGE_WRITE
|
|
||||||
CV_NODE_INTEGER=CV_NODE_INT
|
|
||||||
CV_NODE_FLOAT=CV_NODE_REAL
|
|
||||||
CV_NODE_STRING=CV_NODE_STR
|
|
||||||
cvGetSubArr=cvGetSubRect
|
|
||||||
cvZero=cvSetZero
|
|
||||||
cvCvtScale=cvConvertScale
|
|
||||||
cvScale=cvConvertScale
|
|
||||||
cvCvtScaleAbs=cvConvertScaleAbs
|
|
||||||
cvCheckArray=cvCheckArr
|
|
||||||
cvMatMulAddEx=cvGEMM
|
|
||||||
cvMatMulAddS=cvTransform
|
|
||||||
cvT=cvTranspose
|
|
||||||
cvMirror=cvFlip
|
|
||||||
cvInv=cvInvert
|
|
||||||
cvMahalonobis=cvMahalanobis
|
|
||||||
CV_DXT_INVERSE_SCALE=CV_DXT_INV_SCALE
|
|
||||||
cvFFT=cvDFT
|
|
||||||
cvGraphFindEdge=cvFindGraphEdge
|
|
||||||
cvGraphFindEdgeByPtr=cvFindGraphEdgeByPtr
|
|
||||||
cvDrawRect=cvRectangle
|
|
||||||
cvDrawLine=cvLine
|
|
||||||
cvDrawCircle=cvCircle
|
|
||||||
cvDrawEllipse=cvEllipse
|
|
||||||
cvDrawPolyLine=cvPolyLine
|
|
||||||
CV_FONT_VECTOR0=CV_FONT_HERSHEY_SIMPLEX
|
|
||||||
CV_RGB2RGBA=CV_BGR2BGRA
|
|
||||||
CV_RGBA2RGB=CV_BGRA2BGR
|
|
||||||
CV_RGB2BGRA=CV_BGR2RGBA
|
|
||||||
CV_BGRA2RGB=CV_RGBA2BGR
|
|
||||||
CV_RGB2BGR=CV_BGR2RGB
|
|
||||||
CV_RGBA2BGRA=CV_BGRA2RGBA
|
|
||||||
CV_GRAY2RGB=CV_GRAY2BGR
|
|
||||||
CV_GRAY2RGBA=CV_GRAY2BGRA
|
|
||||||
CV_BayerBG2RGB=CV_BayerRG2BGR
|
|
||||||
CV_BayerGB2RGB=CV_BayerGR2BGR
|
|
||||||
CV_BayerRG2RGB=CV_BayerBG2BGR
|
|
||||||
CV_BayerGR2RGB=CV_BayerGB2BGR
|
|
||||||
CV_FM_LMEDS_ONLY=CV_LMEDS
|
|
||||||
CV_FM_RANSAC_ONLY=CV_RANSAC
|
|
||||||
CV_FM_LMEDS=CV_LMEDS
|
|
||||||
CV_FM_RANSAC=CV_RANSAC
|
|
||||||
%}
|
|
@ -1,534 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
// 2006-02-17 Roman Stanchak <rstancha@cse.wustl.edu>
|
|
||||||
// 2006-07-19 Moved most operators to general/cvarr_operators.i for use with other languages
|
|
||||||
// 2009-01-07 Added numpy array interface, Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
|
|
||||||
/*M//////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Macros for extending CvMat and IplImage -- primarily for operator overloading
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////M*/
|
|
||||||
|
|
||||||
// Macro to define python function of form B = A.f(c)
|
|
||||||
// where A is a CvArr type, c and B are arbitrary types
|
|
||||||
%define %wrap_cvGeneric_CvArr(cname, rettype, pyfunc, argtype, cvfunc, newobjcall)
|
|
||||||
%newobject cname::pyfunc(argtype arg);
|
|
||||||
%extend cname {
|
|
||||||
rettype pyfunc(argtype arg){
|
|
||||||
rettype retarg = newobjcall;
|
|
||||||
cvfunc;
|
|
||||||
return retarg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// Macro to define python function of the form B = A.f(c)
|
|
||||||
// where A and B are both CvArr of same size and type
|
|
||||||
%define %wrap_cvArr_binaryop(pyfunc, argtype, cvfunc)
|
|
||||||
%wrap_cvGeneric_CvArr(CvMat, CvMat *, pyfunc, argtype, cvfunc,
|
|
||||||
cvCreateMat(self->rows, self->cols, self->type));
|
|
||||||
%wrap_cvGeneric_CvArr(IplImage, IplImage *, pyfunc, argtype, cvfunc,
|
|
||||||
cvCreateImage(cvGetSize(self), self->depth, self->nChannels));
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// Macro to define python function of the form A = A.f(c)
|
|
||||||
// where f modifies A inplace
|
|
||||||
// use for +=, etc
|
|
||||||
%define %wrap_cvGeneric_InPlace(cname, rettype, pyfunc, argtype, cvfunc)
|
|
||||||
%wrap_cvGeneric_CvArr(cname, rettype, pyfunc, argtype, cvfunc, self);
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
/*M//////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Macros to map operators to specific OpenCV functions
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////M*/
|
|
||||||
|
|
||||||
// map any OpenCV function of form cvFunc(src1, src2, dst)
|
|
||||||
%define %wrap_cvArith(pyfunc, cvfunc)
|
|
||||||
%wrap_cvArr_binaryop(pyfunc, CvArr *, cvfunc(self, arg, retarg));
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// map any OpenCV function of form cvFunc(src1, value, dst)
|
|
||||||
%define %wrap_cvArithS(pyfunc, cvfuncS)
|
|
||||||
%wrap_cvArr_binaryop(pyfunc, CvScalar, cvfuncS(self, arg, retarg));
|
|
||||||
%wrap_cvArr_binaryop(pyfunc, double, cvfuncS(self, cvScalar(arg), retarg));
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// same as wrap_cvArith
|
|
||||||
%define %wrap_cvLogic(pyfunc, cvfunc)
|
|
||||||
%wrap_cvArr_binaryop(pyfunc, CvArr *, cvfunc(self, arg, retarg))
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// same as wrap_cvArithS
|
|
||||||
%define %wrap_cvLogicS(pyfunc, cvfuncS)
|
|
||||||
%wrap_cvArr_binaryop(pyfunc, CvScalar, cvfuncS(self, arg, retarg));
|
|
||||||
%wrap_cvArr_binaryop(pyfunc, double, cvfuncS(self, cvScalar(arg), retarg));
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// Macro to map logical operations to cvCmp
|
|
||||||
%define %wrap_cvCmp(pyfunc, cmp_op)
|
|
||||||
%wrap_cvGeneric_CvArr(CvMat, CvMat *, pyfunc, CvMat *,
|
|
||||||
cvCmp(self, arg, retarg, cmp_op),
|
|
||||||
cvCreateMat(self->rows, self->cols, CV_8U));
|
|
||||||
%wrap_cvGeneric_CvArr(IplImage, IplImage *, pyfunc, IplImage *,
|
|
||||||
cvCmp(self, arg, retarg, cmp_op),
|
|
||||||
cvCreateImage(cvGetSize(self), 8, 1));
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
%define %wrap_cvCmpS(pyfunc, cmp_op)
|
|
||||||
%wrap_cvGeneric_CvArr(CvMat, CvMat *, pyfunc, double,
|
|
||||||
cvCmpS(self, arg, retarg, cmp_op),
|
|
||||||
cvCreateMat(self->rows, self->cols, CV_8U));
|
|
||||||
%wrap_cvGeneric_CvArr(IplImage, IplImage *, pyfunc, double,
|
|
||||||
cvCmpS(self, arg, retarg, cmp_op),
|
|
||||||
cvCreateImage(cvGetSize(self), 8, 1));
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// special case for cvScale, /, *
|
|
||||||
%define %wrap_cvScale(pyfunc, scale)
|
|
||||||
%wrap_cvGeneric_CvArr(CvMat, CvMat *, pyfunc, double,
|
|
||||||
cvScale(self, retarg, scale),
|
|
||||||
cvCreateMat(self->rows, self->cols, self->type));
|
|
||||||
%wrap_cvGeneric_CvArr(IplImage, IplImage *, pyfunc, double,
|
|
||||||
cvScale(self, retarg, scale),
|
|
||||||
cvCreateImage(cvGetSize(self), self->depth, self->nChannels));
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
/*M//////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Actual Operator Declarations
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////M*/
|
|
||||||
|
|
||||||
// Arithmetic operators
|
|
||||||
%wrap_cvArith(__radd__, cvAdd);
|
|
||||||
|
|
||||||
// special case for reverse operations
|
|
||||||
%wrap_cvArr_binaryop(__rsub__, CvArr *, cvSub(arg, self, retarg));
|
|
||||||
%wrap_cvArr_binaryop(__rdiv__, CvArr *, cvDiv(arg, self, retarg));
|
|
||||||
%wrap_cvArr_binaryop(__rmul__, CvArr *, cvMul(arg, self, retarg));
|
|
||||||
|
|
||||||
%wrap_cvArithS(__radd__, cvAddS);
|
|
||||||
%wrap_cvArithS(__rsub__, cvSubRS);
|
|
||||||
|
|
||||||
%wrap_cvScale(__rmul__, arg);
|
|
||||||
|
|
||||||
%wrap_cvLogicS(__ror__, cvOrS)
|
|
||||||
%wrap_cvLogicS(__rand__, cvAndS)
|
|
||||||
%wrap_cvLogicS(__rxor__, cvXorS)
|
|
||||||
|
|
||||||
%wrap_cvCmpS(__req__, CV_CMP_EQ);
|
|
||||||
%wrap_cvCmpS(__rgt__, CV_CMP_GT);
|
|
||||||
%wrap_cvCmpS(__rge__, CV_CMP_GE);
|
|
||||||
%wrap_cvCmpS(__rlt__, CV_CMP_LT);
|
|
||||||
%wrap_cvCmpS(__rle__, CV_CMP_LE);
|
|
||||||
%wrap_cvCmpS(__rne__, CV_CMP_NE);
|
|
||||||
|
|
||||||
// special case for scalar-array division
|
|
||||||
%wrap_cvGeneric_CvArr(CvMat, CvMat *, __rdiv__, double,
|
|
||||||
cvDiv(NULL, self, retarg, arg),
|
|
||||||
cvCreateMat(self->rows, self->cols, self->type));
|
|
||||||
|
|
||||||
// misc operators for python
|
|
||||||
%wrap_cvArr_binaryop(__pow__, double, cvPow(self, retarg, arg))
|
|
||||||
|
|
||||||
// TODO -- other Python operators listed below and at:
|
|
||||||
// http://docs.python.org/ref/numeric-types.html
|
|
||||||
|
|
||||||
// __abs__ -- cvAbs
|
|
||||||
// __nonzero__
|
|
||||||
// __hash__ ??
|
|
||||||
// __repr__ -- full string representation
|
|
||||||
// __str__ -- compact representation
|
|
||||||
// __call__ -- ??
|
|
||||||
// __len__ -- number of rows? or elements?
|
|
||||||
// __iter__ -- ??
|
|
||||||
// __contains__ -- cvCmpS, cvMax ?
|
|
||||||
// __floordiv__ ??
|
|
||||||
// __mul__ -- cvGEMM
|
|
||||||
// __lshift__ -- ??
|
|
||||||
// __rshift__ -- ??
|
|
||||||
// __pow__ -- cvPow
|
|
||||||
|
|
||||||
// Called to implement the unary arithmetic operations (-, +, abs() and ~).
|
|
||||||
//__neg__( self)
|
|
||||||
//__pos__( self)
|
|
||||||
//__abs__( self)
|
|
||||||
//__invert__( self)
|
|
||||||
|
|
||||||
// Called to implement the built-in functions complex(), int(), long(), and float(). Should return a value of the appropriate type. Can I abuse this to return an array of the correct type??? scipy only allows return of length 1 arrays.
|
|
||||||
// __complex__( self )
|
|
||||||
// __int__( self )
|
|
||||||
// __long__( self )
|
|
||||||
// __float__( self )
|
|
||||||
|
|
||||||
/*M//////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Slice access and assignment for CvArr types
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////M*/
|
|
||||||
|
|
||||||
// TODO: CvMatND
|
|
||||||
|
|
||||||
%newobject CvMat::__getitem__(PyObject * object);
|
|
||||||
%newobject _IplImage::__getitem__(PyObject * object);
|
|
||||||
|
|
||||||
%header %{
|
|
||||||
int checkSliceBounds(const CvRect & rect, int w, int h){
|
|
||||||
//printf("__setitem__ slice(%d:%d, %d:%d) array(%d,%d)", rect.x, rect.y, rect.x+rect.width, rect.y+rect.height, w, h);
|
|
||||||
if(rect.width<=0 || rect.height<=0 ||
|
|
||||||
rect.width>w || rect.height>h ||
|
|
||||||
rect.x<0 || rect.y<0 ||
|
|
||||||
rect.x>= w || rect.y >=h){
|
|
||||||
char errstr[256];
|
|
||||||
|
|
||||||
// previous function already set error string
|
|
||||||
if(rect.width==0 && rect.height==0 && rect.x==0 && rect.y==0) return -1;
|
|
||||||
|
|
||||||
sprintf(errstr, "Requested slice [ %d:%d %d:%d ] oversteps array sized [ %d %d ]",
|
|
||||||
rect.x, rect.y, rect.x+rect.width, rect.y+rect.height, w, h);
|
|
||||||
PyErr_SetString(PyExc_IndexError, errstr);
|
|
||||||
//PyErr_SetString(PyExc_ValueError, errstr);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
// Macro to check bounds of slice and throw error if outside
|
|
||||||
%define CHECK_SLICE_BOUNDS(rect,w,h,retval)
|
|
||||||
if(CheckSliceBounds(&rect,w,h)==-1){ return retval; } else{}
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// slice access and assignment for CvMat
|
|
||||||
%extend CvMat
|
|
||||||
{
|
|
||||||
char * __str__(){
|
|
||||||
static char str[8];
|
|
||||||
cvArrPrint( self );
|
|
||||||
str[0]=0;
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// scalar assignment
|
|
||||||
void __setitem__(PyObject * object, double val){
|
|
||||||
CvMat tmp;
|
|
||||||
CvRect subrect = PySlice_to_CvRect( self, object );
|
|
||||||
CHECK_SLICE_BOUNDS( subrect, self->cols, self->rows, );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
cvSet(&tmp, cvScalarAll(val));
|
|
||||||
}
|
|
||||||
void __setitem__(PyObject * object, CvPoint val){
|
|
||||||
CvMat tmp;
|
|
||||||
CvRect subrect = PySlice_to_CvRect( self, object );
|
|
||||||
CHECK_SLICE_BOUNDS( subrect, self->cols, self->rows, );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
cvSet(&tmp, cvScalar(val.x, val.y));
|
|
||||||
}
|
|
||||||
void __setitem__(PyObject * object, CvPoint2D32f val){
|
|
||||||
CvMat tmp;
|
|
||||||
CvRect subrect = PySlice_to_CvRect( self, object );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
CHECK_SLICE_BOUNDS( subrect, self->cols, self->rows, );
|
|
||||||
cvSet(&tmp, cvScalar(val.x, val.y));
|
|
||||||
}
|
|
||||||
void __setitem__(PyObject * object, CvScalar val){
|
|
||||||
CvMat tmp;
|
|
||||||
CvRect subrect = PySlice_to_CvRect( self, object );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
CHECK_SLICE_BOUNDS( subrect, self->cols, self->rows, );
|
|
||||||
cvSet(&tmp, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
// array slice assignment
|
|
||||||
void __setitem__(PyObject * object, CvArr * arr){
|
|
||||||
CvMat tmp, src_stub, *src;
|
|
||||||
CvRect subrect = PySlice_to_CvRect( self, object );
|
|
||||||
CHECK_SLICE_BOUNDS( subrect, self->cols, self->rows, );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
|
|
||||||
// Reshape source array to fit destination
|
|
||||||
// This will be used a lot for small arrays b/c
|
|
||||||
// PyObject_to_CvArr tries to compress a 2-D python
|
|
||||||
// array with 1-4 columns into a multichannel vector
|
|
||||||
src=cvReshape(arr, &src_stub, CV_MAT_CN(tmp.type), tmp.rows);
|
|
||||||
|
|
||||||
cvConvert(src, &tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// slice access
|
|
||||||
PyObject * __getitem__(PyObject * object){
|
|
||||||
CvMat * mat;
|
|
||||||
CvRect subrect = PySlice_to_CvRect( self, object );
|
|
||||||
CHECK_SLICE_BOUNDS( subrect, self->cols, self->rows, NULL );
|
|
||||||
if(subrect.width==1 && subrect.height==1){
|
|
||||||
CvScalar * s;
|
|
||||||
int type = cvGetElemType( self );
|
|
||||||
if(CV_MAT_CN(type) > 1){
|
|
||||||
s = new CvScalar;
|
|
||||||
*s = cvGet2D( self, subrect.y, subrect.x );
|
|
||||||
return SWIG_NewPointerObj( s, $descriptor(CvScalar *), 1 );
|
|
||||||
}
|
|
||||||
switch(CV_MAT_DEPTH(type)){
|
|
||||||
case CV_8U:
|
|
||||||
return PyLong_FromUnsignedLong( CV_MAT_ELEM(*self, uchar, subrect.y, subrect.x ) );
|
|
||||||
case CV_8S:
|
|
||||||
return PyLong_FromLong( CV_MAT_ELEM(*self, char, subrect.y, subrect.x ) );
|
|
||||||
case CV_16U:
|
|
||||||
return PyLong_FromUnsignedLong( CV_MAT_ELEM(*self, ushort, subrect.y, subrect.x ) );
|
|
||||||
case CV_16S:
|
|
||||||
return PyLong_FromLong( CV_MAT_ELEM(*self, short, subrect.y, subrect.x ) );
|
|
||||||
case CV_32S:
|
|
||||||
return PyLong_FromLong( CV_MAT_ELEM(*self, int, subrect.y, subrect.x ) );
|
|
||||||
case CV_32F:
|
|
||||||
return PyFloat_FromDouble( CV_MAT_ELEM(*self, float, subrect.y, subrect.x) );
|
|
||||||
case CV_64F:
|
|
||||||
return PyFloat_FromDouble( CV_MAT_ELEM(*self, double, subrect.y, subrect.x) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mat = (CvMat *) cvAlloc(sizeof(CvMat));
|
|
||||||
cvGetSubRect(self, mat, subrect);
|
|
||||||
|
|
||||||
// cvGetSubRect doesn't do this since it assumes mat lives on the stack
|
|
||||||
mat->hdr_refcount = self->hdr_refcount;
|
|
||||||
mat->refcount = self->refcount;
|
|
||||||
cvIncRefData(mat);
|
|
||||||
|
|
||||||
return SWIG_NewPointerObj( mat, $descriptor(CvMat *), 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
// ~ operator -- swig doesn't generate this from the C++ equivalent
|
|
||||||
CvMat * __invert__(){
|
|
||||||
CvMat * res = cvCreateMat(self->rows, self->cols, self->type);
|
|
||||||
cvNot( self, res );
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
%pythoncode %{
|
|
||||||
def __iter__(self):
|
|
||||||
"""
|
|
||||||
generator function iterating through rows in matrix or elements in vector
|
|
||||||
"""
|
|
||||||
if self.rows==1:
|
|
||||||
return self.colrange()
|
|
||||||
return self.rowrange()
|
|
||||||
|
|
||||||
def rowrange(self):
|
|
||||||
"""
|
|
||||||
generator function iterating along rows in matrix
|
|
||||||
"""
|
|
||||||
for i in range(self.rows):
|
|
||||||
yield self[i]
|
|
||||||
|
|
||||||
def colrange(self):
|
|
||||||
"""
|
|
||||||
generator function iterating along columns in matrix
|
|
||||||
"""
|
|
||||||
for i in range(self.cols):
|
|
||||||
yield self[:,i]
|
|
||||||
|
|
||||||
# if arg is None, python still calls our operator overloads
|
|
||||||
# but we want
|
|
||||||
# if mat != None
|
|
||||||
# if mat == None
|
|
||||||
# to do the right thing -- so redefine __ne__ and __eq__
|
|
||||||
|
|
||||||
def __eq__(self, arg):
|
|
||||||
"""
|
|
||||||
__eq__(self, None)
|
|
||||||
__eq__(self, CvArr src)
|
|
||||||
__eq__(self, double val)
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not arg:
|
|
||||||
return False
|
|
||||||
return _cv.CvMat___eq__(self, arg)
|
|
||||||
def __ne__(self, arg):
|
|
||||||
"""
|
|
||||||
__ne__(self, None)
|
|
||||||
__ne__(self, CvArr src)
|
|
||||||
__ne__(self, double val)
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not arg:
|
|
||||||
return True
|
|
||||||
return _cv.CvMat___ne__(self, arg)
|
|
||||||
|
|
||||||
def __get_array_interface__ (self):
|
|
||||||
"""Compose numpy array interface
|
|
||||||
|
|
||||||
Via the numpy array interface, OpenCV data structures can be directly passed to numpy
|
|
||||||
methods without copying / converting. This tremendously speeds up mixing code from
|
|
||||||
OpenCV and numpy.
|
|
||||||
|
|
||||||
See: http://numpy.scipy.org/array_interface.shtml
|
|
||||||
|
|
||||||
@author Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
@date 2009-01-07
|
|
||||||
"""
|
|
||||||
|
|
||||||
if self.depth == IPL_DEPTH_8U:
|
|
||||||
typestr = '|u1'
|
|
||||||
bytes_per_pixel = 1
|
|
||||||
elif self.depth == IPL_DEPTH_8S:
|
|
||||||
typestr = '|i1'
|
|
||||||
bytes_per_pixel = 1
|
|
||||||
elif self.depth == IPL_DEPTH_16U:
|
|
||||||
typestr = '|u2'
|
|
||||||
bytes_per_pixel = 2
|
|
||||||
elif self.depth == IPL_DEPTH_16S:
|
|
||||||
typestr = '|i2'
|
|
||||||
bytes_per_pixel = 2
|
|
||||||
elif self.depth == IPL_DEPTH_32S:
|
|
||||||
typestr = '|i4'
|
|
||||||
bytes_per_pixel = 4
|
|
||||||
elif self.depth == IPL_DEPTH_32F:
|
|
||||||
typestr = '|f4'
|
|
||||||
bytes_per_pixel = 4
|
|
||||||
elif self.depth == IPL_DEPTH_64F:
|
|
||||||
typestr = '|f8'
|
|
||||||
bytes_per_pixel = 8
|
|
||||||
else:
|
|
||||||
raise TypeError("unknown resp. unhandled OpenCV image/matrix format")
|
|
||||||
|
|
||||||
if self.nChannels == 1:
|
|
||||||
# monochrome image, matrix with a single channel
|
|
||||||
return {'shape': (self.height, self.width),
|
|
||||||
'typestr': typestr,
|
|
||||||
'version': 3,
|
|
||||||
|
|
||||||
'data': (int (self.data.ptr), False),
|
|
||||||
'strides': (int (self.widthStep), int (bytes_per_pixel))}
|
|
||||||
else:
|
|
||||||
# color image, image with alpha, matrix with multiple channels
|
|
||||||
return {'shape': (self.height, self.width, self.nChannels),
|
|
||||||
'typestr': typestr,
|
|
||||||
'version': 3,
|
|
||||||
|
|
||||||
'data': (int (self.data.ptr), False),
|
|
||||||
'strides': (int (self.widthStep), int (self.nChannels * bytes_per_pixel), int (bytes_per_pixel))}
|
|
||||||
|
|
||||||
__array_interface__ = property (__get_array_interface__, doc = "numpy array interface description")
|
|
||||||
|
|
||||||
%}
|
|
||||||
|
|
||||||
} //extend CvMat
|
|
||||||
|
|
||||||
// slice access and assignment for IplImage
|
|
||||||
%extend _IplImage
|
|
||||||
{
|
|
||||||
char * __str__(){
|
|
||||||
static char str[8];
|
|
||||||
cvArrPrint( self );
|
|
||||||
str[0]=0;
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
// scalar assignment
|
|
||||||
void __setitem__(PyObject * object, double val){
|
|
||||||
CvMat tmp;
|
|
||||||
CvRect subrect = PySlice_to_CvRect( self, object );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
cvSet(&tmp, cvScalarAll(val));
|
|
||||||
}
|
|
||||||
void __setitem__(PyObject * object, CvPoint val){
|
|
||||||
CvMat tmp;
|
|
||||||
CvRect subrect = PySlice_to_CvRect( self, object );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
cvSet(&tmp, cvScalar(val.x, val.y));
|
|
||||||
}
|
|
||||||
void __setitem__(PyObject * object, CvPoint2D32f val){
|
|
||||||
CvMat tmp;
|
|
||||||
CvRect subrect = PySlice_to_CvRect( self, object );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
cvSet(&tmp, cvScalar(val.x, val.y));
|
|
||||||
}
|
|
||||||
void __setitem__(PyObject * object, CvScalar val){
|
|
||||||
CvMat tmp;
|
|
||||||
CvRect subrect = PySlice_to_CvRect( self, object );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
cvSet(&tmp, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
// array slice assignment
|
|
||||||
void __setitem__(PyObject * object, CvArr * arr){
|
|
||||||
CvMat tmp;
|
|
||||||
CvRect subrect = PySlice_to_CvRect( self, object );
|
|
||||||
cvGetSubRect(self, &tmp, subrect);
|
|
||||||
cvConvert(arr, &tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// slice access
|
|
||||||
PyObject * __getitem__(PyObject * object){
|
|
||||||
CvMat mat;
|
|
||||||
IplImage * im;
|
|
||||||
CvRect subrect = PySlice_to_CvRect( self, object );
|
|
||||||
|
|
||||||
// return scalar if single element
|
|
||||||
if(subrect.width==1 && subrect.height==1){
|
|
||||||
CvScalar * s;
|
|
||||||
int type = cvGetElemType( self );
|
|
||||||
if(CV_MAT_CN(type) > 1){
|
|
||||||
s = new CvScalar;
|
|
||||||
*s = cvGet2D( self, subrect.y, subrect.x );
|
|
||||||
return SWIG_NewPointerObj( s, $descriptor(CvScalar *), 1 );
|
|
||||||
}
|
|
||||||
switch(CV_MAT_DEPTH(type)){
|
|
||||||
case CV_8U:
|
|
||||||
return PyLong_FromUnsignedLong( CV_IMAGE_ELEM(self, uchar, subrect.y, subrect.x ) );
|
|
||||||
case CV_8S:
|
|
||||||
return PyLong_FromLong( CV_IMAGE_ELEM(self, char, subrect.y, subrect.x ) );
|
|
||||||
case CV_16U:
|
|
||||||
return PyLong_FromUnsignedLong( CV_IMAGE_ELEM(self, ushort, subrect.y, subrect.x ) );
|
|
||||||
case CV_16S:
|
|
||||||
return PyLong_FromLong( CV_IMAGE_ELEM(self, short, subrect.y, subrect.x ) );
|
|
||||||
case CV_32S:
|
|
||||||
return PyLong_FromLong( CV_IMAGE_ELEM(self, int, subrect.y, subrect.x ) );
|
|
||||||
case CV_32F:
|
|
||||||
return PyFloat_FromDouble( CV_IMAGE_ELEM(self, float, subrect.y, subrect.x) );
|
|
||||||
case CV_64F:
|
|
||||||
return PyFloat_FromDouble( CV_IMAGE_ELEM(self, double, subrect.y, subrect.x) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// otherwise return array
|
|
||||||
im = (IplImage *) cvAlloc(sizeof(IplImage));
|
|
||||||
cvGetSubRect(self, &mat, subrect);
|
|
||||||
im = cvGetImage(&mat, im);
|
|
||||||
return SWIG_NewPointerObj( im, $descriptor(_IplImage *), 1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,105 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
// 2006-08-02 Roman Stanchak <rstancha@cse.wustl.edu>
|
|
||||||
|
|
||||||
%include "pycvseq.hpp"
|
|
||||||
%template (CvTuple_CvPoint_2) CvTuple<CvPoint,2>;
|
|
||||||
%template (CvTuple_float_2) CvTuple<float,2>;
|
|
||||||
%template (CvTuple_float_3) CvTuple<float,3>;
|
|
||||||
|
|
||||||
%template (CvSeq_CvPoint) CvTypedSeq<CvPoint>;
|
|
||||||
%template (CvSeq_CvPoint2D32f) CvTypedSeq<CvPoint2D32f>;
|
|
||||||
%template (CvSeq_CvRect) CvTypedSeq<CvRect>;
|
|
||||||
%template (CvSeq_CvSeq) CvTypedSeq<CvSeq *>;
|
|
||||||
%template (CvSeq_CvQuadEdge2D) CvTypedSeq<CvQuadEdge2D>;
|
|
||||||
%template (CvSeq_CvConnectedComp) CvTypedSeq<CvConnectedComp>;
|
|
||||||
%template (CvSeq_CvPoint_2) CvTypedSeq< CvTuple<CvPoint,2> >;
|
|
||||||
%template (CvSeq_float_2) CvTypedSeq< CvTuple<float,2> >;
|
|
||||||
%template (CvSeq_float_3) CvTypedSeq< CvTuple<float,3> >;
|
|
||||||
|
|
||||||
%extend CvSeq {
|
|
||||||
%pythoncode %{
|
|
||||||
def __iter__(self):
|
|
||||||
"""
|
|
||||||
generator function iterating elements in the sequence
|
|
||||||
"""
|
|
||||||
for i in range(self.total):
|
|
||||||
yield self[i]
|
|
||||||
|
|
||||||
def vrange(self):
|
|
||||||
"""
|
|
||||||
generator function iterating along v_next
|
|
||||||
"""
|
|
||||||
s = self
|
|
||||||
t = type(self)
|
|
||||||
while s:
|
|
||||||
yield s
|
|
||||||
s = t.cast(s.v_next)
|
|
||||||
|
|
||||||
def hrange(self):
|
|
||||||
"""
|
|
||||||
generator function iterating along h_next
|
|
||||||
"""
|
|
||||||
s = self
|
|
||||||
t = type(self)
|
|
||||||
while s:
|
|
||||||
yield s
|
|
||||||
s = t.cast(s.h_next)
|
|
||||||
%}
|
|
||||||
}
|
|
||||||
|
|
||||||
// accessor to turn edges into a typed sequence
|
|
||||||
%extend CvSubdiv2D {
|
|
||||||
CvTypedSeq<CvQuadEdge2D> * typed_edges;
|
|
||||||
CvTypedSeq<CvQuadEdge2D> * typed_edges_get(){
|
|
||||||
return (CvTypedSeq<CvQuadEdge2D> *) self->edges;
|
|
||||||
}
|
|
||||||
void typed_edges_set( CvTypedSeq<CvQuadEdge2D> * ){
|
|
||||||
}
|
|
||||||
%pythoncode %{
|
|
||||||
def __iter__(self):
|
|
||||||
s = CvSeq_QuadEdge2D.cast(self)
|
|
||||||
for i in range(s.total):
|
|
||||||
yield s[i]
|
|
||||||
%}
|
|
||||||
}
|
|
||||||
|
|
@ -1,83 +0,0 @@
|
|||||||
#include <cxcore.h>
|
|
||||||
#include <cv.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "cvshadow.h"
|
|
||||||
|
|
||||||
CvArr * cvCvtSeqToArray_Shadow( const CvSeq* seq, CvArr * elements, CvSlice slice){
|
|
||||||
CvMat stub, *mat=(CvMat *)elements;
|
|
||||||
if(!CV_IS_MAT(mat)){
|
|
||||||
mat = cvGetMat(elements, &stub);
|
|
||||||
}
|
|
||||||
cvCvtSeqToArray( seq, mat->data.ptr, slice );
|
|
||||||
return elements;
|
|
||||||
}
|
|
||||||
|
|
||||||
double cvArcLength_Shadow( const CvSeq * seq, CvSlice slice, int is_closed){
|
|
||||||
return cvArcLength( seq, slice, is_closed );
|
|
||||||
}
|
|
||||||
double cvArcLength_Shadow( const CvArr * arr, CvSlice slice, int is_closed){
|
|
||||||
return cvArcLength( arr, slice, is_closed );
|
|
||||||
}
|
|
||||||
|
|
||||||
void cvMoments_Shadow( const CvSeq * seq, CvMoments * moments, int binary ){
|
|
||||||
cvMoments( seq, moments, binary );
|
|
||||||
}
|
|
||||||
|
|
||||||
void cvMoments_Shadow( const CvArr * seq, CvMoments * moments, int binary ){
|
|
||||||
cvMoments( seq, moments, binary );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CvTypedSeq<CvRect> * cvHaarDetectObjects_Shadow( const CvArr* image, CvHaarClassifierCascade* cascade,
|
|
||||||
CvMemStorage* storage, double scale_factor, int min_neighbors, int flags,
|
|
||||||
CvSize min_size )
|
|
||||||
{
|
|
||||||
return (CvTypedSeq<CvRect> *) cvHaarDetectObjects( image, cascade, storage, scale_factor,
|
|
||||||
min_neighbors, flags, min_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
CvTypedSeq<CvConnectedComp> * cvSegmentMotion_Shadow( const CvArr* mhi, CvArr* seg_mask, CvMemStorage* storage,
|
|
||||||
double timestamp, double seg_thresh ){
|
|
||||||
return (CvTypedSeq<CvConnectedComp> *) cvSegmentMotion( mhi, seg_mask, storage, timestamp, seg_thresh );
|
|
||||||
}
|
|
||||||
|
|
||||||
CvTypedSeq<CvPoint> * cvApproxPoly_Shadow( const void* src_seq, int header_size, CvMemStorage* storage,
|
|
||||||
int method, double parameter, int parameter2)
|
|
||||||
{
|
|
||||||
return (CvTypedSeq<CvPoint> *) cvApproxPoly( src_seq, header_size, storage, method, parameter, parameter2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Always return a new Mat of indices
|
|
||||||
CvMat * cvConvexHull2_Shadow( const CvArr * points, int orientation, int return_points){
|
|
||||||
CvMat * hull=0;
|
|
||||||
CvMat * points_mat=(CvMat *) points;
|
|
||||||
CvSeq * points_seq=(CvSeq *) points;
|
|
||||||
int npoints, type;
|
|
||||||
|
|
||||||
if(CV_IS_MAT(points_mat)){
|
|
||||||
npoints = MAX(points_mat->rows, points_mat->cols);
|
|
||||||
type = return_points ? points_mat->type : CV_32S;
|
|
||||||
}
|
|
||||||
else if(CV_IS_SEQ(points_seq)){
|
|
||||||
npoints = points_seq->total;
|
|
||||||
type = return_points ? CV_SEQ_ELTYPE(points_seq) : 1;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
CV_Error(CV_StsBadArg, "points must be a CvSeq or CvMat");
|
|
||||||
}
|
|
||||||
hull=cvCreateMat(1,npoints,type);
|
|
||||||
cvConvexHull2(points, hull, orientation, return_points);
|
|
||||||
|
|
||||||
return hull;
|
|
||||||
}
|
|
||||||
std::vector<CvPoint> cvSnakeImage_Shadow( const CvMat * image, std::vector<CvPoint> points,
|
|
||||||
std::vector<float> alpha, std::vector<float> beta,
|
|
||||||
std::vector<float> gamma,
|
|
||||||
CvSize win, CvTermCriteria criteria, int calc_gradient ){
|
|
||||||
IplImage ipl_stub;
|
|
||||||
cvSnakeImage( cvGetImage(image, &ipl_stub), &(points[0]), points.size(),
|
|
||||||
&((alpha)[0]), &((beta)[0]), &((gamma)[0]),
|
|
||||||
(alpha.size()>1 && beta.size()>1 && gamma.size()>1 ? CV_ARRAY : CV_VALUE),
|
|
||||||
win, criteria, calc_gradient );
|
|
||||||
return points;
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
#ifndef CV_SHADOW_H
|
|
||||||
#define CV_SHADOW_H
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include "cxtypes.h"
|
|
||||||
#include "cvtypes.h"
|
|
||||||
#include "pycvseq.hpp"
|
|
||||||
|
|
||||||
// modify cvCvtSeqToArray to take CvArr as input instead of raw data
|
|
||||||
CvArr * cvCvtSeqToArray_Shadow( const CvSeq* seq, CvArr * elements, CvSlice slice=CV_WHOLE_SEQ);
|
|
||||||
|
|
||||||
// Return a typed sequence instead of generic CvSeq
|
|
||||||
CvTypedSeq<CvRect> * cvHaarDetectObjects_Shadow( const CvArr* image, CvHaarClassifierCascade* cascade,
|
|
||||||
CvMemStorage* storage, double scale_factor=1.1, int min_neighbors=3, int flags=0,
|
|
||||||
CvSize min_size=cvSize(0,0) );
|
|
||||||
CvTypedSeq<CvConnectedComp> * cvSegmentMotion_Shadow( const CvArr* mhi, CvArr* seg_mask, CvMemStorage* storage,
|
|
||||||
double timestamp, double seg_thresh );
|
|
||||||
CvTypedSeq<CvPoint> * cvApproxPoly_Shadow( const void* src_seq, int header_size, CvMemStorage* storage,
|
|
||||||
int method, double parameter, int parameter2=0);
|
|
||||||
|
|
||||||
// Always return a new Mat of indices
|
|
||||||
CvMat * cvConvexHull2_Shadow( const CvArr * points, int orientation=CV_CLOCKWISE,
|
|
||||||
int return_points=0);
|
|
||||||
|
|
||||||
std::vector<CvPoint> cvSnakeImage_Shadow( const CvMat * image, std::vector<CvPoint> points,
|
|
||||||
std::vector<float> alpha, std::vector<float> beta, std::vector<float> gamma,
|
|
||||||
CvSize win, CvTermCriteria criteria, int calc_gradient=1 );
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,137 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
/* This file contains custom python shadow class code for certain troublesome functions */
|
|
||||||
|
|
||||||
%{
|
|
||||||
#include "cvshadow.h"
|
|
||||||
%}
|
|
||||||
|
|
||||||
// source %myshadow, %myrelease macros
|
|
||||||
%include "cvswigmacros.i"
|
|
||||||
|
|
||||||
%include "stl.i"
|
|
||||||
|
|
||||||
// %ignore, %rename must come before %include
|
|
||||||
%myshadow(cvCvtSeqToArray);
|
|
||||||
%myshadow(cvHaarDetectObjects);
|
|
||||||
%myshadow(cvSegmentMotion);
|
|
||||||
%myshadow(cvApproxPoly);
|
|
||||||
%myshadow(cvConvexHull2);
|
|
||||||
%newobject cvConvexHull2_Shadow; // shadowed functioned always returns new object
|
|
||||||
|
|
||||||
/* cvSnakeImage shadow uses a vector<CvPoint> and vector<float> */
|
|
||||||
%template(FloatVector) std::vector<float>;
|
|
||||||
%template(CvPointVector) std::vector<CvPoint>;
|
|
||||||
%myshadow(cvSnakeImage);
|
|
||||||
|
|
||||||
// must come after %ignore, %rename
|
|
||||||
%include "cvshadow.h"
|
|
||||||
|
|
||||||
/* return a typed CvSeq instead of generic for CvSubdiv2D edges -- see cvseq.i */
|
|
||||||
%rename (untyped_edges) CvSubdiv2D::edges;
|
|
||||||
%ignore CvSubdiv2D::edges;
|
|
||||||
%rename (edges) CvSubdiv2D::typed_edges;
|
|
||||||
|
|
||||||
/* Python doesn't know what to do with these */
|
|
||||||
%rename (asIplImage) operator IplImage*;
|
|
||||||
%rename (asCvMat) operator CvMat*;
|
|
||||||
%ignore operator const IplImage*;
|
|
||||||
%ignore operator const CvMat*;
|
|
||||||
|
|
||||||
/* Define sequence type for functions returning sequences */
|
|
||||||
%define %cast_seq( cvfunc, type )
|
|
||||||
%rename (cvfunc##Untyped) cvfunc;
|
|
||||||
%pythoncode %{
|
|
||||||
def cvfunc(*args):
|
|
||||||
seq = cvfunc##Untyped( *args )
|
|
||||||
return type.cast(seq)
|
|
||||||
%}
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
%cast_seq( cvHoughCircles, CvSeq_float_3 );
|
|
||||||
%cast_seq( cvPyrSegmentation, CvSeq_CvConnectedComp );
|
|
||||||
%cast_seq( cvApproxChains, CvSeq_CvPoint);
|
|
||||||
%cast_seq( cvContourFromContourTree, CvSeq_CvPoint );
|
|
||||||
%cast_seq( cvConvexityDefects, CvSeq_CvConvexityDefect );
|
|
||||||
|
|
||||||
/* Special cases ... */
|
|
||||||
%rename(cvFindContoursUntyped) cvFindContours;
|
|
||||||
%pythoncode %{
|
|
||||||
def cvFindContours( *args ):
|
|
||||||
count, seq = cvFindContoursUntyped( *args )
|
|
||||||
return count, CvSeq_CvPoint.cast(seq)
|
|
||||||
%}
|
|
||||||
|
|
||||||
/* cvHoughLines2 returns a different type of sequence depending on its args */
|
|
||||||
%rename (cvHoughLinesUntyped) cvHoughLines2;
|
|
||||||
%pythoncode %{
|
|
||||||
def cvHoughLines2( *args ):
|
|
||||||
seq = cvHoughLinesUntyped( *args )
|
|
||||||
type = CV_SEQ_ELTYPE(seq)
|
|
||||||
if type == CV_32SC4:
|
|
||||||
return CvSeq_CvPoint_2.cast(seq)
|
|
||||||
return CvSeq_float_2.cast(seq)
|
|
||||||
%}
|
|
||||||
|
|
||||||
// cvPointSeqFromMat
|
|
||||||
// cvSeqPartition
|
|
||||||
// cvSeqSlice
|
|
||||||
// cvTreeToNodeSeq
|
|
||||||
|
|
||||||
// Fix cvRelease* function to play nice w/ Python
|
|
||||||
// TODO some of these objects lack the delete method -- why???
|
|
||||||
%myrelease(cv, cvReleaseImage, CvMat); // IplImage is CvMat in Python
|
|
||||||
%myrelease(cv, cvReleaseMat, CvMat);
|
|
||||||
%myrelease(cv, cvReleaseStructuringElement, IplConvKernel);
|
|
||||||
%myrelease(cv, cvReleaseKalman, CvKalman);
|
|
||||||
%myrelease(cv, cvReleaseHist, CvHistogram);
|
|
||||||
%myrelease(cv, cvReleaseHaarClassifierCascade, CvHaarClassifierCascade);
|
|
||||||
//%myrelease(cvReleasePOSITObject, CvPOSITObject);
|
|
||||||
%myrelease(cv, cvReleaseImageHeader, CvMat); // IplImage is CvMat
|
|
||||||
%myrelease(cv, cvReleaseMatND, CvMatND);
|
|
||||||
%myrelease(cv, cvReleaseSparseMat, CvSparseMat);
|
|
||||||
%myrelease(cv, cvReleaseMemStorage, CvMemStorage);
|
|
||||||
%myrelease(cv, cvReleaseGraphScanner, CvGraphScanner);
|
|
||||||
//%myrelease(cvReleaseFileStorage, CvFileStorage);
|
|
||||||
|
|
||||||
// TODO implement this
|
|
||||||
%ignore cvRelease;
|
|
@ -1,75 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
/* This file contains swig macros that are used in several typemap files */
|
|
||||||
|
|
||||||
|
|
||||||
%define %myshadow(function)
|
|
||||||
%ignore function;
|
|
||||||
%rename (function) function##_Shadow;
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
// Elsewhere in this wrapper, the cvRelease* functions are mapped to
|
|
||||||
// the destructors for the corresponding OpenCV object wrapper. This
|
|
||||||
// is done in order to let Python handle memory management. If the
|
|
||||||
// reference count of the Python object wrapping the OpenCV object
|
|
||||||
// goes to 0, the garbage collector will call the destructor, and
|
|
||||||
// therefore the cvRelease* function, before freeing the Python object.
|
|
||||||
// However, if the user explicitly calls the cvRelease* function, we
|
|
||||||
// must prevent the Python garbage collector from calling it again when
|
|
||||||
// the refcount reaches 0 -- otherwise a double-free error occurs.
|
|
||||||
//
|
|
||||||
// Thus, below, we redirect each cvRelease* function to the
|
|
||||||
// corresponding OpenCV object's destructor. This has the effect of:
|
|
||||||
// (1) Calling the corresponding cvRelease* function, and therefore
|
|
||||||
// immediately releasing the OpenCV object.
|
|
||||||
// (2) Telling SWIG to disown memory management for this OpenCV object.
|
|
||||||
//
|
|
||||||
// Thus, when the refcount for the Python object reaches 0, the Python
|
|
||||||
// object is garbage collected, but since it no longer owns the OpenCV
|
|
||||||
// object, this is not freed again.
|
|
||||||
%define %myrelease(module, Function, Type)
|
|
||||||
%ignore Function;
|
|
||||||
%rename (Function) Function##_Shadow;
|
|
||||||
%pythoncode %{
|
|
||||||
Function = _##module##.delete_##Type
|
|
||||||
%}
|
|
||||||
%enddef
|
|
@ -1,113 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
|
|
||||||
// 2004-03-17, Gabriel Schreiber <schreiber@ient.rwth-aachen.de>
|
|
||||||
// Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
// Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
|
|
||||||
|
|
||||||
// Python header.
|
|
||||||
// It may be required that this header is the first to be included
|
|
||||||
// (see Python documentation for details)
|
|
||||||
#include "Python.h"
|
|
||||||
|
|
||||||
#include "error.h"
|
|
||||||
#include <sstream>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
// OpenCV headers
|
|
||||||
#include "cxcore.h"
|
|
||||||
#include "cxerror.h"
|
|
||||||
|
|
||||||
|
|
||||||
//=========================================================================
|
|
||||||
int SendErrorToPython
|
|
||||||
(
|
|
||||||
int status,
|
|
||||||
const char* func_name,
|
|
||||||
const char* err_msg,
|
|
||||||
const char* file_name,
|
|
||||||
int line,
|
|
||||||
void* /*userdata*/
|
|
||||||
)
|
|
||||||
throw(int)
|
|
||||||
{
|
|
||||||
std::stringstream message;
|
|
||||||
message
|
|
||||||
<< " openCV Error:"
|
|
||||||
<< "\n Status=" << cvErrorStr(status)
|
|
||||||
<< "\n function name=" << (func_name ? func_name : "unknown")
|
|
||||||
<< "\n error message=" << (err_msg ? err_msg : "unknown")
|
|
||||||
<< "\n file_name=" << (file_name ? file_name : "unknown")
|
|
||||||
<< "\n line=" << line
|
|
||||||
<< std::flush;
|
|
||||||
|
|
||||||
// Clear OpenCV's error status for the next call!
|
|
||||||
cvSetErrStatus( CV_StsOk );
|
|
||||||
|
|
||||||
// Set Python Error.
|
|
||||||
// ATTENTION: this only works if the function returning to
|
|
||||||
// Python returns 0 instead of a PyObject (see also "custom_typemaps.i"
|
|
||||||
PyErr_SetString(PyExc_RuntimeError, message.str().c_str());
|
|
||||||
throw 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//=========================================================================
|
|
||||||
void* void_ptr_generator()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=========================================================================
|
|
||||||
void** void_ptrptr_generator()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=========================================================================
|
|
||||||
CvErrorCallback function_ptr_generator()
|
|
||||||
{
|
|
||||||
return &SendErrorToPython;
|
|
||||||
}
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
|
|
||||||
// 2004-03-17, Gabriel Schreiber <schreiber@ient.rwth-aachen.de>
|
|
||||||
// Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
// Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
|
|
||||||
|
|
||||||
#include "cxcore.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function will set a Python error and throw an int.
|
|
||||||
* Exceptions are catched automatically by the SWIG code from "typemaps.i"
|
|
||||||
*/
|
|
||||||
int SendErrorToPython ( int status,
|
|
||||||
const char * func_name,
|
|
||||||
const char * err_msg,
|
|
||||||
const char * file_name,
|
|
||||||
int line,
|
|
||||||
void * /*userdata*/) throw(int);
|
|
||||||
|
|
||||||
/// Returns the adress of the static method "SendErrorToPython()"
|
|
||||||
CvErrorCallback function_ptr_generator();
|
|
||||||
|
|
||||||
/// Dummy to generate an empty void pointer
|
|
||||||
void * void_ptr_generator();
|
|
||||||
|
|
||||||
/// Dummy to generate an empty void double pointer
|
|
||||||
void ** void_ptrptr_generator();
|
|
@ -1,296 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
|
|
||||||
// 2004-03-16, Gabriel Schreiber <schreiber@ient.rwth-aachen.de>
|
|
||||||
// Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
// Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
|
|
||||||
%{
|
|
||||||
#include <cxtypes.h>
|
|
||||||
#include <cv.h>
|
|
||||||
#include <highgui.h>
|
|
||||||
#include "pyhelpers.h"
|
|
||||||
#include "pycvseq.hpp"
|
|
||||||
%}
|
|
||||||
// include python-specific files
|
|
||||||
%include "./nointpb.i"
|
|
||||||
%include "./pytypemaps.i"
|
|
||||||
%include "exception.i"
|
|
||||||
%include "cvswigmacros.i"
|
|
||||||
|
|
||||||
// handle camera and video writer destruction
|
|
||||||
%myrelease(highgui, cvReleaseCapture, CvCapture);
|
|
||||||
%myrelease(highgui, cvReleaseVideoWriter, CvVideoWriter);
|
|
||||||
|
|
||||||
/* the wrapping code to enable the use of Python-based mouse callbacks */
|
|
||||||
%header %{
|
|
||||||
/* This encapsulates the python callback and user_data for mouse callback */
|
|
||||||
struct PyCvMouseCBData {
|
|
||||||
PyObject * py_func;
|
|
||||||
PyObject * user_data;
|
|
||||||
};
|
|
||||||
/* This encapsulates the python callback and user_data for mouse callback */
|
|
||||||
/* C helper function which is responsible for calling
|
|
||||||
the Python real trackbar callback function */
|
|
||||||
static void icvPyOnMouse (int event, int x, int y,
|
|
||||||
int flags, PyCvMouseCBData * param) {
|
|
||||||
|
|
||||||
/* Must ensure this thread has a lock on the interpreter */
|
|
||||||
PyGILState_STATE state = PyGILState_Ensure();
|
|
||||||
|
|
||||||
PyObject *result;
|
|
||||||
|
|
||||||
/* the argument of the callback ready to be passed to Python code */
|
|
||||||
PyObject *arg1 = PyInt_FromLong (event);
|
|
||||||
PyObject *arg2 = PyInt_FromLong (x);
|
|
||||||
PyObject *arg3 = PyInt_FromLong (y);
|
|
||||||
PyObject *arg4 = PyInt_FromLong (flags);
|
|
||||||
PyObject *arg5 = param->user_data; // assume this is already a PyObject
|
|
||||||
|
|
||||||
/* build the tuple for calling the Python callback */
|
|
||||||
PyObject *arglist = Py_BuildValue ("(OOOOO)",
|
|
||||||
arg1, arg2, arg3, arg4, arg5);
|
|
||||||
|
|
||||||
/* call the Python callback */
|
|
||||||
result = PyEval_CallObject (param->py_func, arglist);
|
|
||||||
|
|
||||||
/* Errors in Python callback get swallowed, so report them here */
|
|
||||||
if(!result){
|
|
||||||
PyErr_Print();
|
|
||||||
cvError( CV_StsInternal, "icvPyOnMouse", "", __FILE__, __LINE__);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* cleanup */
|
|
||||||
Py_XDECREF (result);
|
|
||||||
|
|
||||||
/* Release Interpreter lock */
|
|
||||||
PyGILState_Release(state);
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
/**
|
|
||||||
* adapt cvSetMouseCallback to use python callback
|
|
||||||
*/
|
|
||||||
%rename (cvSetMouseCallbackOld) cvSetMouseCallback;
|
|
||||||
%rename (cvSetMouseCallback) cvSetMouseCallbackPy;
|
|
||||||
%inline %{
|
|
||||||
void cvSetMouseCallbackPy( const char* window_name, PyObject * on_mouse, PyObject * param=NULL ){
|
|
||||||
// TODO potential memory leak if mouse callback is redefined
|
|
||||||
PyCvMouseCBData * py_callback = new PyCvMouseCBData;
|
|
||||||
py_callback->py_func = on_mouse;
|
|
||||||
py_callback->user_data = param ? param : Py_None;
|
|
||||||
|
|
||||||
Py_XINCREF(py_callback->py_func);
|
|
||||||
Py_XINCREF(py_callback->user_data);
|
|
||||||
|
|
||||||
cvSetMouseCallback( window_name, (CvMouseCallback) icvPyOnMouse, (void *) py_callback );
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The following code enables trackbar callbacks from python. Unfortunately, there is no
|
|
||||||
* way to distinguish which trackbar the event originated from, so must hard code a
|
|
||||||
* fixed number of unique c callback functions using the macros below
|
|
||||||
*/
|
|
||||||
%wrapper %{
|
|
||||||
/* C helper function which is responsible for calling
|
|
||||||
the Python real trackbar callback function */
|
|
||||||
static void icvPyOnTrackbar( PyObject * py_cb_func, int pos) {
|
|
||||||
|
|
||||||
/* Must ensure this thread has a lock on the interpreter */
|
|
||||||
PyGILState_STATE state = PyGILState_Ensure();
|
|
||||||
|
|
||||||
PyObject *result;
|
|
||||||
|
|
||||||
/* the argument of the callback ready to be passed to Python code */
|
|
||||||
PyObject *arg1 = PyInt_FromLong (pos);
|
|
||||||
|
|
||||||
/* build the tuple for calling the Python callback */
|
|
||||||
PyObject *arglist = Py_BuildValue ("(O)", arg1);
|
|
||||||
|
|
||||||
/* call the Python callback */
|
|
||||||
result = PyEval_CallObject (py_cb_func, arglist);
|
|
||||||
|
|
||||||
/* Errors in Python callback get swallowed, so report them here */
|
|
||||||
if(!result){
|
|
||||||
PyErr_Print();
|
|
||||||
cvError( CV_StsInternal, "icvPyOnTrackbar", "", __FILE__, __LINE__);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* cleanup */
|
|
||||||
Py_XDECREF (result);
|
|
||||||
|
|
||||||
/* Release Interpreter lock */
|
|
||||||
PyGILState_Release(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ICV_PY_MAX_CB 10
|
|
||||||
|
|
||||||
struct PyCvTrackbar {
|
|
||||||
CvTrackbarCallback cv_func;
|
|
||||||
PyObject * py_func;
|
|
||||||
PyObject * py_pos;
|
|
||||||
};
|
|
||||||
|
|
||||||
static int my_trackbar_cb_size=0;
|
|
||||||
extern PyCvTrackbar my_trackbar_cb_funcs[ICV_PY_MAX_CB];
|
|
||||||
%}
|
|
||||||
|
|
||||||
/* Callback table entry */
|
|
||||||
%define %ICV_PY_CB_TAB_ENTRY(idx)
|
|
||||||
{(CvTrackbarCallback) icvPyTrackbarCB##idx, NULL, NULL }
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
/* Table of callbacks */
|
|
||||||
%define %ICV_PY_CB_TAB
|
|
||||||
%wrapper %{
|
|
||||||
PyCvTrackbar my_trackbar_cb_funcs[ICV_PY_MAX_CB] = {
|
|
||||||
%ICV_PY_CB_TAB_ENTRY(0),
|
|
||||||
%ICV_PY_CB_TAB_ENTRY(1),
|
|
||||||
%ICV_PY_CB_TAB_ENTRY(2),
|
|
||||||
%ICV_PY_CB_TAB_ENTRY(3),
|
|
||||||
%ICV_PY_CB_TAB_ENTRY(4),
|
|
||||||
%ICV_PY_CB_TAB_ENTRY(5),
|
|
||||||
%ICV_PY_CB_TAB_ENTRY(6),
|
|
||||||
%ICV_PY_CB_TAB_ENTRY(7),
|
|
||||||
%ICV_PY_CB_TAB_ENTRY(8),
|
|
||||||
%ICV_PY_CB_TAB_ENTRY(9)
|
|
||||||
};
|
|
||||||
%}
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
/* Callback definition */
|
|
||||||
%define %ICV_PY_CB_IMPL(idx)
|
|
||||||
%wrapper %{
|
|
||||||
static void icvPyTrackbarCB##idx(int pos){
|
|
||||||
if(!my_trackbar_cb_funcs[idx].py_func) return;
|
|
||||||
icvPyOnTrackbar( my_trackbar_cb_funcs[idx].py_func, pos );
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
%enddef
|
|
||||||
|
|
||||||
|
|
||||||
%ICV_PY_CB_IMPL(0);
|
|
||||||
%ICV_PY_CB_IMPL(1);
|
|
||||||
%ICV_PY_CB_IMPL(2);
|
|
||||||
%ICV_PY_CB_IMPL(3);
|
|
||||||
%ICV_PY_CB_IMPL(4);
|
|
||||||
%ICV_PY_CB_IMPL(5);
|
|
||||||
%ICV_PY_CB_IMPL(6);
|
|
||||||
%ICV_PY_CB_IMPL(7);
|
|
||||||
%ICV_PY_CB_IMPL(8);
|
|
||||||
%ICV_PY_CB_IMPL(9);
|
|
||||||
|
|
||||||
%ICV_PY_CB_TAB;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* typemap to memorize the Python callback when doing cvCreateTrackbar ()
|
|
||||||
*/
|
|
||||||
%typemap(in) CvTrackbarCallback {
|
|
||||||
|
|
||||||
if(my_trackbar_cb_size == ICV_PY_MAX_CB){
|
|
||||||
SWIG_exception(SWIG_IndexError, "Exceeded maximum number of trackbars");
|
|
||||||
}
|
|
||||||
|
|
||||||
my_trackbar_cb_size++;
|
|
||||||
|
|
||||||
if (!PyCallable_Check($input)) {
|
|
||||||
PyErr_SetString(PyExc_TypeError, "parameter must be callable");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Py_XINCREF((PyObject*) $input); /* Add a reference to new callback */
|
|
||||||
Py_XDECREF(my_trackbar_cb_funcs[my_trackbar_cb_size-1].py_func); /* Dispose of previous callback */
|
|
||||||
my_trackbar_cb_funcs[my_trackbar_cb_size-1].py_func = (PyObject *) $input;
|
|
||||||
|
|
||||||
/* prepare to call the C function who will register the callback */
|
|
||||||
$1 = my_trackbar_cb_funcs[ my_trackbar_cb_size-1 ].cv_func;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* typemap so that cvWaitKey returns a character in all cases except -1
|
|
||||||
*/
|
|
||||||
%rename (cvWaitKeyC) cvWaitKey;
|
|
||||||
%rename (cvWaitKey) cvWaitKeyPy;
|
|
||||||
%inline %{
|
|
||||||
PyObject * cvWaitKeyPy(int delay=0){
|
|
||||||
// In order for the event processing thread to run a python callback
|
|
||||||
// it must acquire the global interpreter lock, but cvWaitKey blocks, so
|
|
||||||
// this thread can never release the lock. So release it here.
|
|
||||||
PyThreadState * thread_state = PyEval_SaveThread();
|
|
||||||
int res = cvWaitKey(delay);
|
|
||||||
PyEval_RestoreThread( thread_state );
|
|
||||||
|
|
||||||
char str[2]={(char)res,0};
|
|
||||||
if(res==-1){
|
|
||||||
return PyLong_FromLong(-1);
|
|
||||||
}
|
|
||||||
return PyString_FromString(str);
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
/* HighGUI Python module initialization
|
|
||||||
* needed for callbacks to work in a threaded environment
|
|
||||||
*/
|
|
||||||
%init %{
|
|
||||||
PyEval_InitThreads();
|
|
||||||
%}
|
|
||||||
|
|
||||||
|
|
||||||
%include "../general/highgui.i"
|
|
||||||
|
|
||||||
%pythoncode
|
|
||||||
%{
|
|
||||||
|
|
||||||
__doc__ = """HighGUI provides minimalistic user interface parts and video input/output.
|
|
||||||
|
|
||||||
Dependent on the platform it was compiled on, this library provides methods
|
|
||||||
to draw a window for image display, capture video from a camera or framegrabber
|
|
||||||
or read/write video streams from/to the file system.
|
|
||||||
|
|
||||||
This wrapper was semi-automatically created from the C/C++ headers and therefore
|
|
||||||
contains no Python documentation. Because all identifiers are identical to their
|
|
||||||
C/C++ counterparts, you can consult the standard manuals that come with OpenCV.
|
|
||||||
"""
|
|
||||||
|
|
||||||
%}
|
|
@ -1,457 +0,0 @@
|
|||||||
# This file was automatically generated by SWIG (http://www.swig.org).
|
|
||||||
# Version 1.3.40
|
|
||||||
#
|
|
||||||
# Do not make changes to this file unless you know what you are doing--modify
|
|
||||||
# the SWIG interface file instead.
|
|
||||||
# This file is compatible with both classic and new-style classes.
|
|
||||||
|
|
||||||
from sys import version_info
|
|
||||||
if version_info >= (2,6,0):
|
|
||||||
def swig_import_helper():
|
|
||||||
from os.path import dirname
|
|
||||||
import imp
|
|
||||||
fp = None
|
|
||||||
try:
|
|
||||||
fp, pathname, description = imp.find_module('_highgui', [dirname(__file__)])
|
|
||||||
except ImportError:
|
|
||||||
import _highgui
|
|
||||||
return _highgui
|
|
||||||
if fp is not None:
|
|
||||||
try:
|
|
||||||
_mod = imp.load_module('_highgui', fp, pathname, description)
|
|
||||||
finally:
|
|
||||||
fp.close()
|
|
||||||
return _mod
|
|
||||||
_highgui = swig_import_helper()
|
|
||||||
del swig_import_helper
|
|
||||||
else:
|
|
||||||
import _highgui
|
|
||||||
del version_info
|
|
||||||
try:
|
|
||||||
_swig_property = property
|
|
||||||
except NameError:
|
|
||||||
pass # Python < 2.2 doesn't have 'property'.
|
|
||||||
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
|
|
||||||
if (name == "thisown"): return self.this.own(value)
|
|
||||||
if (name == "this"):
|
|
||||||
if type(value).__name__ == 'SwigPyObject':
|
|
||||||
self.__dict__[name] = value
|
|
||||||
return
|
|
||||||
method = class_type.__swig_setmethods__.get(name,None)
|
|
||||||
if method: return method(self,value)
|
|
||||||
if (not static) or hasattr(self,name):
|
|
||||||
self.__dict__[name] = value
|
|
||||||
else:
|
|
||||||
raise AttributeError("You cannot add attributes to %s" % self)
|
|
||||||
|
|
||||||
def _swig_setattr(self,class_type,name,value):
|
|
||||||
return _swig_setattr_nondynamic(self,class_type,name,value,0)
|
|
||||||
|
|
||||||
def _swig_getattr(self,class_type,name):
|
|
||||||
if (name == "thisown"): return self.this.own()
|
|
||||||
method = class_type.__swig_getmethods__.get(name,None)
|
|
||||||
if method: return method(self)
|
|
||||||
raise AttributeError(name)
|
|
||||||
|
|
||||||
def _swig_repr(self):
|
|
||||||
try: strthis = "proxy of " + self.this.__repr__()
|
|
||||||
except: strthis = ""
|
|
||||||
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
|
|
||||||
|
|
||||||
try:
|
|
||||||
_object = object
|
|
||||||
_newclass = 1
|
|
||||||
except AttributeError:
|
|
||||||
class _object : pass
|
|
||||||
_newclass = 0
|
|
||||||
|
|
||||||
|
|
||||||
class CvRNG_Wrapper(_object):
|
|
||||||
__swig_setmethods__ = {}
|
|
||||||
__setattr__ = lambda self, name, value: _swig_setattr(self, CvRNG_Wrapper, name, value)
|
|
||||||
__swig_getmethods__ = {}
|
|
||||||
__getattr__ = lambda self, name: _swig_getattr(self, CvRNG_Wrapper, name)
|
|
||||||
__repr__ = _swig_repr
|
|
||||||
def __init__(self, *args):
|
|
||||||
this = _highgui.new_CvRNG_Wrapper(*args)
|
|
||||||
try: self.this.append(this)
|
|
||||||
except: self.this = this
|
|
||||||
def ptr(self): return _highgui.CvRNG_Wrapper_ptr(self)
|
|
||||||
def ref(self): return _highgui.CvRNG_Wrapper_ref(self)
|
|
||||||
def __eq__(self, *args): return _highgui.CvRNG_Wrapper___eq__(self, *args)
|
|
||||||
def __ne__(self, *args): return _highgui.CvRNG_Wrapper___ne__(self, *args)
|
|
||||||
__swig_destroy__ = _highgui.delete_CvRNG_Wrapper
|
|
||||||
__del__ = lambda self : None;
|
|
||||||
CvRNG_Wrapper_swigregister = _highgui.CvRNG_Wrapper_swigregister
|
|
||||||
CvRNG_Wrapper_swigregister(CvRNG_Wrapper)
|
|
||||||
|
|
||||||
class CvSubdiv2DEdge_Wrapper(_object):
|
|
||||||
__swig_setmethods__ = {}
|
|
||||||
__setattr__ = lambda self, name, value: _swig_setattr(self, CvSubdiv2DEdge_Wrapper, name, value)
|
|
||||||
__swig_getmethods__ = {}
|
|
||||||
__getattr__ = lambda self, name: _swig_getattr(self, CvSubdiv2DEdge_Wrapper, name)
|
|
||||||
__repr__ = _swig_repr
|
|
||||||
def __init__(self, *args):
|
|
||||||
this = _highgui.new_CvSubdiv2DEdge_Wrapper(*args)
|
|
||||||
try: self.this.append(this)
|
|
||||||
except: self.this = this
|
|
||||||
def ptr(self): return _highgui.CvSubdiv2DEdge_Wrapper_ptr(self)
|
|
||||||
def ref(self): return _highgui.CvSubdiv2DEdge_Wrapper_ref(self)
|
|
||||||
def __eq__(self, *args): return _highgui.CvSubdiv2DEdge_Wrapper___eq__(self, *args)
|
|
||||||
def __ne__(self, *args): return _highgui.CvSubdiv2DEdge_Wrapper___ne__(self, *args)
|
|
||||||
__swig_destroy__ = _highgui.delete_CvSubdiv2DEdge_Wrapper
|
|
||||||
__del__ = lambda self : None;
|
|
||||||
CvSubdiv2DEdge_Wrapper_swigregister = _highgui.CvSubdiv2DEdge_Wrapper_swigregister
|
|
||||||
CvSubdiv2DEdge_Wrapper_swigregister(CvSubdiv2DEdge_Wrapper)
|
|
||||||
|
|
||||||
cvReleaseCapture = _highgui.delete_CvCapture
|
|
||||||
|
|
||||||
cvReleaseVideoWriter = _highgui.delete_CvVideoWriter
|
|
||||||
|
|
||||||
|
|
||||||
def cvRetrieveFrame(*args):
|
|
||||||
"""cvRetrieveFrame(CvCapture capture) -> CvMat"""
|
|
||||||
return _highgui.cvRetrieveFrame(*args)
|
|
||||||
|
|
||||||
def cvQueryFrame(*args):
|
|
||||||
"""cvQueryFrame(CvCapture capture) -> CvMat"""
|
|
||||||
return _highgui.cvQueryFrame(*args)
|
|
||||||
|
|
||||||
def cvInitSystem(*args):
|
|
||||||
"""cvInitSystem(int argc, char argv) -> int"""
|
|
||||||
return _highgui.cvInitSystem(*args)
|
|
||||||
|
|
||||||
def cvStartWindowThread():
|
|
||||||
"""cvStartWindowThread() -> int"""
|
|
||||||
return _highgui.cvStartWindowThread()
|
|
||||||
CV_WINDOW_AUTOSIZE = _highgui.CV_WINDOW_AUTOSIZE
|
|
||||||
|
|
||||||
def cvNamedWindow(*args):
|
|
||||||
"""cvNamedWindow(char name, int flags = 1) -> int"""
|
|
||||||
return _highgui.cvNamedWindow(*args)
|
|
||||||
|
|
||||||
def cvShowImage(*args):
|
|
||||||
"""cvShowImage(char name, CvArr image)"""
|
|
||||||
return _highgui.cvShowImage(*args)
|
|
||||||
|
|
||||||
def cvResizeWindow(*args):
|
|
||||||
"""cvResizeWindow(char name, int width, int height)"""
|
|
||||||
return _highgui.cvResizeWindow(*args)
|
|
||||||
|
|
||||||
def cvMoveWindow(*args):
|
|
||||||
"""cvMoveWindow(char name, int x, int y)"""
|
|
||||||
return _highgui.cvMoveWindow(*args)
|
|
||||||
|
|
||||||
def cvDestroyWindow(*args):
|
|
||||||
"""cvDestroyWindow(char name)"""
|
|
||||||
return _highgui.cvDestroyWindow(*args)
|
|
||||||
|
|
||||||
def cvDestroyAllWindows():
|
|
||||||
"""cvDestroyAllWindows()"""
|
|
||||||
return _highgui.cvDestroyAllWindows()
|
|
||||||
|
|
||||||
def cvGetWindowHandle(*args):
|
|
||||||
"""cvGetWindowHandle(char name) -> void"""
|
|
||||||
return _highgui.cvGetWindowHandle(*args)
|
|
||||||
|
|
||||||
def cvGetWindowName(*args):
|
|
||||||
"""cvGetWindowName(void window_handle) -> char"""
|
|
||||||
return _highgui.cvGetWindowName(*args)
|
|
||||||
|
|
||||||
def cvCreateTrackbar(*args):
|
|
||||||
"""
|
|
||||||
cvCreateTrackbar(char trackbar_name, char window_name, int value, int count,
|
|
||||||
CvTrackbarCallback on_change) -> int
|
|
||||||
"""
|
|
||||||
return _highgui.cvCreateTrackbar(*args)
|
|
||||||
|
|
||||||
def cvCreateTrackbar2(*args):
|
|
||||||
"""
|
|
||||||
cvCreateTrackbar2(char trackbar_name, char window_name, int value, int count,
|
|
||||||
CvTrackbarCallback2 on_change, void userdata = None) -> int
|
|
||||||
"""
|
|
||||||
return _highgui.cvCreateTrackbar2(*args)
|
|
||||||
|
|
||||||
def cvGetTrackbarPos(*args):
|
|
||||||
"""cvGetTrackbarPos(char trackbar_name, char window_name) -> int"""
|
|
||||||
return _highgui.cvGetTrackbarPos(*args)
|
|
||||||
|
|
||||||
def cvSetTrackbarPos(*args):
|
|
||||||
"""cvSetTrackbarPos(char trackbar_name, char window_name, int pos)"""
|
|
||||||
return _highgui.cvSetTrackbarPos(*args)
|
|
||||||
CV_EVENT_MOUSEMOVE = _highgui.CV_EVENT_MOUSEMOVE
|
|
||||||
CV_EVENT_LBUTTONDOWN = _highgui.CV_EVENT_LBUTTONDOWN
|
|
||||||
CV_EVENT_RBUTTONDOWN = _highgui.CV_EVENT_RBUTTONDOWN
|
|
||||||
CV_EVENT_MBUTTONDOWN = _highgui.CV_EVENT_MBUTTONDOWN
|
|
||||||
CV_EVENT_LBUTTONUP = _highgui.CV_EVENT_LBUTTONUP
|
|
||||||
CV_EVENT_RBUTTONUP = _highgui.CV_EVENT_RBUTTONUP
|
|
||||||
CV_EVENT_MBUTTONUP = _highgui.CV_EVENT_MBUTTONUP
|
|
||||||
CV_EVENT_LBUTTONDBLCLK = _highgui.CV_EVENT_LBUTTONDBLCLK
|
|
||||||
CV_EVENT_RBUTTONDBLCLK = _highgui.CV_EVENT_RBUTTONDBLCLK
|
|
||||||
CV_EVENT_MBUTTONDBLCLK = _highgui.CV_EVENT_MBUTTONDBLCLK
|
|
||||||
CV_EVENT_FLAG_LBUTTON = _highgui.CV_EVENT_FLAG_LBUTTON
|
|
||||||
CV_EVENT_FLAG_RBUTTON = _highgui.CV_EVENT_FLAG_RBUTTON
|
|
||||||
CV_EVENT_FLAG_MBUTTON = _highgui.CV_EVENT_FLAG_MBUTTON
|
|
||||||
CV_EVENT_FLAG_CTRLKEY = _highgui.CV_EVENT_FLAG_CTRLKEY
|
|
||||||
CV_EVENT_FLAG_SHIFTKEY = _highgui.CV_EVENT_FLAG_SHIFTKEY
|
|
||||||
CV_EVENT_FLAG_ALTKEY = _highgui.CV_EVENT_FLAG_ALTKEY
|
|
||||||
|
|
||||||
def cvSetMouseCallbackOld(*args):
|
|
||||||
"""cvSetMouseCallbackOld(char window_name, CvMouseCallback on_mouse, void param = None)"""
|
|
||||||
return _highgui.cvSetMouseCallbackOld(*args)
|
|
||||||
CV_LOAD_IMAGE_UNCHANGED = _highgui.CV_LOAD_IMAGE_UNCHANGED
|
|
||||||
CV_LOAD_IMAGE_GRAYSCALE = _highgui.CV_LOAD_IMAGE_GRAYSCALE
|
|
||||||
CV_LOAD_IMAGE_COLOR = _highgui.CV_LOAD_IMAGE_COLOR
|
|
||||||
CV_LOAD_IMAGE_ANYDEPTH = _highgui.CV_LOAD_IMAGE_ANYDEPTH
|
|
||||||
CV_LOAD_IMAGE_ANYCOLOR = _highgui.CV_LOAD_IMAGE_ANYCOLOR
|
|
||||||
|
|
||||||
def cvLoadImageM(*args):
|
|
||||||
"""cvLoadImageM(char filename, int iscolor = 1) -> CvMat"""
|
|
||||||
return _highgui.cvLoadImageM(*args)
|
|
||||||
CV_IMWRITE_JPEG_QUALITY = _highgui.CV_IMWRITE_JPEG_QUALITY
|
|
||||||
CV_IMWRITE_PNG_COMPRESSION = _highgui.CV_IMWRITE_PNG_COMPRESSION
|
|
||||||
CV_IMWRITE_PXM_BINARY = _highgui.CV_IMWRITE_PXM_BINARY
|
|
||||||
|
|
||||||
def cvSaveImage(*args):
|
|
||||||
"""cvSaveImage(char filename, CvArr image, int params = None) -> int"""
|
|
||||||
return _highgui.cvSaveImage(*args)
|
|
||||||
|
|
||||||
def cvDecodeImage(*args):
|
|
||||||
"""cvDecodeImage(CvMat buf, int iscolor = 1)"""
|
|
||||||
return _highgui.cvDecodeImage(*args)
|
|
||||||
|
|
||||||
def cvDecodeImageM(*args):
|
|
||||||
"""cvDecodeImageM(CvMat buf, int iscolor = 1) -> CvMat"""
|
|
||||||
return _highgui.cvDecodeImageM(*args)
|
|
||||||
|
|
||||||
def cvEncodeImage(*args):
|
|
||||||
"""cvEncodeImage(char ext, CvArr image, int params = None) -> CvMat"""
|
|
||||||
return _highgui.cvEncodeImage(*args)
|
|
||||||
CV_CVTIMG_FLIP = _highgui.CV_CVTIMG_FLIP
|
|
||||||
CV_CVTIMG_SWAP_RB = _highgui.CV_CVTIMG_SWAP_RB
|
|
||||||
|
|
||||||
def cvConvertImage(*args):
|
|
||||||
"""cvConvertImage(CvArr src, CvArr dst, int flags = 0)"""
|
|
||||||
return _highgui.cvConvertImage(*args)
|
|
||||||
|
|
||||||
def cvWaitKeyC(delay = 0):
|
|
||||||
"""cvWaitKeyC(int delay = 0) -> int"""
|
|
||||||
return _highgui.cvWaitKeyC(delay)
|
|
||||||
|
|
||||||
def cvCreateFileCapture(*args):
|
|
||||||
"""cvCreateFileCapture(char filename) -> CvCapture"""
|
|
||||||
return _highgui.cvCreateFileCapture(*args)
|
|
||||||
CV_CAP_ANY = _highgui.CV_CAP_ANY
|
|
||||||
CV_CAP_MIL = _highgui.CV_CAP_MIL
|
|
||||||
CV_CAP_VFW = _highgui.CV_CAP_VFW
|
|
||||||
CV_CAP_V4L = _highgui.CV_CAP_V4L
|
|
||||||
CV_CAP_V4L2 = _highgui.CV_CAP_V4L2
|
|
||||||
CV_CAP_FIREWARE = _highgui.CV_CAP_FIREWARE
|
|
||||||
CV_CAP_FIREWIRE = _highgui.CV_CAP_FIREWIRE
|
|
||||||
CV_CAP_IEEE1394 = _highgui.CV_CAP_IEEE1394
|
|
||||||
CV_CAP_DC1394 = _highgui.CV_CAP_DC1394
|
|
||||||
CV_CAP_CMU1394 = _highgui.CV_CAP_CMU1394
|
|
||||||
CV_CAP_STEREO = _highgui.CV_CAP_STEREO
|
|
||||||
CV_CAP_TYZX = _highgui.CV_CAP_TYZX
|
|
||||||
CV_TYZX_LEFT = _highgui.CV_TYZX_LEFT
|
|
||||||
CV_TYZX_RIGHT = _highgui.CV_TYZX_RIGHT
|
|
||||||
CV_TYZX_COLOR = _highgui.CV_TYZX_COLOR
|
|
||||||
CV_TYZX_Z = _highgui.CV_TYZX_Z
|
|
||||||
CV_CAP_QT = _highgui.CV_CAP_QT
|
|
||||||
CV_CAP_UNICAP = _highgui.CV_CAP_UNICAP
|
|
||||||
CV_CAP_DSHOW = _highgui.CV_CAP_DSHOW
|
|
||||||
|
|
||||||
def cvCreateCameraCapture(*args):
|
|
||||||
"""cvCreateCameraCapture(int index) -> CvCapture"""
|
|
||||||
return _highgui.cvCreateCameraCapture(*args)
|
|
||||||
|
|
||||||
def cvGrabFrame(*args):
|
|
||||||
"""cvGrabFrame(CvCapture capture) -> int"""
|
|
||||||
return _highgui.cvGrabFrame(*args)
|
|
||||||
|
|
||||||
def cvRetrieveFrame__Deprecated(*args):
|
|
||||||
"""cvRetrieveFrame__Deprecated(CvCapture capture, int streamIdx = 0)"""
|
|
||||||
return _highgui.cvRetrieveFrame__Deprecated(*args)
|
|
||||||
|
|
||||||
def cvQueryFrame__Deprecated(*args):
|
|
||||||
"""cvQueryFrame__Deprecated(CvCapture capture)"""
|
|
||||||
return _highgui.cvQueryFrame__Deprecated(*args)
|
|
||||||
CV_CAP_PROP_POS_MSEC = _highgui.CV_CAP_PROP_POS_MSEC
|
|
||||||
CV_CAP_PROP_POS_FRAMES = _highgui.CV_CAP_PROP_POS_FRAMES
|
|
||||||
CV_CAP_PROP_POS_AVI_RATIO = _highgui.CV_CAP_PROP_POS_AVI_RATIO
|
|
||||||
CV_CAP_PROP_FRAME_WIDTH = _highgui.CV_CAP_PROP_FRAME_WIDTH
|
|
||||||
CV_CAP_PROP_FRAME_HEIGHT = _highgui.CV_CAP_PROP_FRAME_HEIGHT
|
|
||||||
CV_CAP_PROP_FPS = _highgui.CV_CAP_PROP_FPS
|
|
||||||
CV_CAP_PROP_FOURCC = _highgui.CV_CAP_PROP_FOURCC
|
|
||||||
CV_CAP_PROP_FRAME_COUNT = _highgui.CV_CAP_PROP_FRAME_COUNT
|
|
||||||
CV_CAP_PROP_FORMAT = _highgui.CV_CAP_PROP_FORMAT
|
|
||||||
CV_CAP_PROP_MODE = _highgui.CV_CAP_PROP_MODE
|
|
||||||
CV_CAP_PROP_BRIGHTNESS = _highgui.CV_CAP_PROP_BRIGHTNESS
|
|
||||||
CV_CAP_PROP_CONTRAST = _highgui.CV_CAP_PROP_CONTRAST
|
|
||||||
CV_CAP_PROP_SATURATION = _highgui.CV_CAP_PROP_SATURATION
|
|
||||||
CV_CAP_PROP_HUE = _highgui.CV_CAP_PROP_HUE
|
|
||||||
CV_CAP_PROP_GAIN = _highgui.CV_CAP_PROP_GAIN
|
|
||||||
CV_CAP_PROP_EXPOSURE = _highgui.CV_CAP_PROP_EXPOSURE
|
|
||||||
CV_CAP_PROP_CONVERT_RGB = _highgui.CV_CAP_PROP_CONVERT_RGB
|
|
||||||
CV_CAP_PROP_WHITE_BALANCE = _highgui.CV_CAP_PROP_WHITE_BALANCE
|
|
||||||
CV_CAP_PROP_RECTIFICATION = _highgui.CV_CAP_PROP_RECTIFICATION
|
|
||||||
|
|
||||||
def cvGetCaptureProperty(*args):
|
|
||||||
"""cvGetCaptureProperty(CvCapture capture, int property_id) -> double"""
|
|
||||||
return _highgui.cvGetCaptureProperty(*args)
|
|
||||||
|
|
||||||
def cvSetCaptureProperty(*args):
|
|
||||||
"""cvSetCaptureProperty(CvCapture capture, int property_id, double value) -> int"""
|
|
||||||
return _highgui.cvSetCaptureProperty(*args)
|
|
||||||
|
|
||||||
def cvGetCaptureDomain(*args):
|
|
||||||
"""cvGetCaptureDomain(CvCapture capture) -> int"""
|
|
||||||
return _highgui.cvGetCaptureDomain(*args)
|
|
||||||
|
|
||||||
def CV_FOURCC(*args):
|
|
||||||
"""CV_FOURCC(char c1, char c2, char c3, char c4) -> int"""
|
|
||||||
return _highgui.CV_FOURCC(*args)
|
|
||||||
CV_FOURCC_PROMPT = _highgui.CV_FOURCC_PROMPT
|
|
||||||
|
|
||||||
def cvCreateVideoWriter(*args):
|
|
||||||
"""
|
|
||||||
cvCreateVideoWriter(char filename, int fourcc, double fps, CvSize frame_size,
|
|
||||||
int is_color = 1) -> CvVideoWriter
|
|
||||||
"""
|
|
||||||
return _highgui.cvCreateVideoWriter(*args)
|
|
||||||
|
|
||||||
def cvWriteFrame(*args):
|
|
||||||
"""cvWriteFrame(CvVideoWriter writer, image) -> int"""
|
|
||||||
return _highgui.cvWriteFrame(*args)
|
|
||||||
HG_AUTOSIZE = _highgui.HG_AUTOSIZE
|
|
||||||
class CvvImage(_object):
|
|
||||||
"""Proxy of C++ CvvImage class"""
|
|
||||||
__swig_setmethods__ = {}
|
|
||||||
__setattr__ = lambda self, name, value: _swig_setattr(self, CvvImage, name, value)
|
|
||||||
__swig_getmethods__ = {}
|
|
||||||
__getattr__ = lambda self, name: _swig_getattr(self, CvvImage, name)
|
|
||||||
__repr__ = _swig_repr
|
|
||||||
def __init__(self):
|
|
||||||
"""__init__(self) -> CvvImage"""
|
|
||||||
this = _highgui.new_CvvImage()
|
|
||||||
try: self.this.append(this)
|
|
||||||
except: self.this = this
|
|
||||||
__swig_destroy__ = _highgui.delete_CvvImage
|
|
||||||
__del__ = lambda self : None;
|
|
||||||
def Create(self, *args):
|
|
||||||
"""
|
|
||||||
Create(self, int width, int height, int bits_per_pixel, int image_origin = 0) -> bool
|
|
||||||
Create(self, int width, int height, int bits_per_pixel) -> bool
|
|
||||||
"""
|
|
||||||
return _highgui.CvvImage_Create(self, *args)
|
|
||||||
|
|
||||||
def Load(self, *args):
|
|
||||||
"""
|
|
||||||
Load(self, char filename, int desired_color = 1) -> bool
|
|
||||||
Load(self, char filename) -> bool
|
|
||||||
"""
|
|
||||||
return _highgui.CvvImage_Load(self, *args)
|
|
||||||
|
|
||||||
def LoadRect(self, *args):
|
|
||||||
"""LoadRect(self, char filename, int desired_color, CvRect r) -> bool"""
|
|
||||||
return _highgui.CvvImage_LoadRect(self, *args)
|
|
||||||
|
|
||||||
def Save(self, *args):
|
|
||||||
"""Save(self, char filename) -> bool"""
|
|
||||||
return _highgui.CvvImage_Save(self, *args)
|
|
||||||
|
|
||||||
def CopyOf(self, *args):
|
|
||||||
"""
|
|
||||||
CopyOf(self, CvvImage image, int desired_color = -1)
|
|
||||||
CopyOf(self, CvvImage image)
|
|
||||||
CopyOf(self, img, int desired_color = -1)
|
|
||||||
CopyOf(self, img)
|
|
||||||
"""
|
|
||||||
return _highgui.CvvImage_CopyOf(self, *args)
|
|
||||||
|
|
||||||
def GetImage(self):
|
|
||||||
"""GetImage(self)"""
|
|
||||||
return _highgui.CvvImage_GetImage(self)
|
|
||||||
|
|
||||||
def Destroy(self):
|
|
||||||
"""Destroy(self)"""
|
|
||||||
return _highgui.CvvImage_Destroy(self)
|
|
||||||
|
|
||||||
def Width(self):
|
|
||||||
"""Width(self) -> int"""
|
|
||||||
return _highgui.CvvImage_Width(self)
|
|
||||||
|
|
||||||
def Height(self):
|
|
||||||
"""Height(self) -> int"""
|
|
||||||
return _highgui.CvvImage_Height(self)
|
|
||||||
|
|
||||||
def Bpp(self):
|
|
||||||
"""Bpp(self) -> int"""
|
|
||||||
return _highgui.CvvImage_Bpp(self)
|
|
||||||
|
|
||||||
def Fill(self, *args):
|
|
||||||
"""Fill(self, int color)"""
|
|
||||||
return _highgui.CvvImage_Fill(self, *args)
|
|
||||||
|
|
||||||
def Show(self, *args):
|
|
||||||
"""Show(self, char window)"""
|
|
||||||
return _highgui.CvvImage_Show(self, *args)
|
|
||||||
|
|
||||||
CvvImage_swigregister = _highgui.CvvImage_swigregister
|
|
||||||
CvvImage_swigregister(CvvImage)
|
|
||||||
|
|
||||||
def cvSetMouseCallback(*args):
|
|
||||||
return _highgui.cvSetMouseCallback(*args)
|
|
||||||
cvSetMouseCallback = _highgui.cvSetMouseCallback
|
|
||||||
|
|
||||||
def cvWaitKey(delay = 0):
|
|
||||||
return _highgui.cvWaitKey(delay)
|
|
||||||
cvWaitKey = _highgui.cvWaitKey
|
|
||||||
|
|
||||||
def cvLoadImage(*args):
|
|
||||||
"""
|
|
||||||
cvLoadImage(char filename, int iscolor = 1) -> CvMat
|
|
||||||
cvLoadImage(char filename) -> CvMat
|
|
||||||
"""
|
|
||||||
return _highgui.cvLoadImage(*args)
|
|
||||||
|
|
||||||
class CvCapture(_object):
|
|
||||||
"""Proxy of C++ CvCapture class"""
|
|
||||||
__swig_setmethods__ = {}
|
|
||||||
__setattr__ = lambda self, name, value: _swig_setattr(self, CvCapture, name, value)
|
|
||||||
__swig_getmethods__ = {}
|
|
||||||
__getattr__ = lambda self, name: _swig_getattr(self, CvCapture, name)
|
|
||||||
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
|
|
||||||
__repr__ = _swig_repr
|
|
||||||
__swig_destroy__ = _highgui.delete_CvCapture
|
|
||||||
__del__ = lambda self : None;
|
|
||||||
CvCapture_swigregister = _highgui.CvCapture_swigregister
|
|
||||||
CvCapture_swigregister(CvCapture)
|
|
||||||
|
|
||||||
class CvVideoWriter(_object):
|
|
||||||
"""Proxy of C++ CvVideoWriter class"""
|
|
||||||
__swig_setmethods__ = {}
|
|
||||||
__setattr__ = lambda self, name, value: _swig_setattr(self, CvVideoWriter, name, value)
|
|
||||||
__swig_getmethods__ = {}
|
|
||||||
__getattr__ = lambda self, name: _swig_getattr(self, CvVideoWriter, name)
|
|
||||||
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
|
|
||||||
__repr__ = _swig_repr
|
|
||||||
__swig_destroy__ = _highgui.delete_CvVideoWriter
|
|
||||||
__del__ = lambda self : None;
|
|
||||||
CvVideoWriter_swigregister = _highgui.CvVideoWriter_swigregister
|
|
||||||
CvVideoWriter_swigregister(CvVideoWriter)
|
|
||||||
|
|
||||||
__doc__ = """HighGUI provides minimalistic user interface parts and video input/output.
|
|
||||||
|
|
||||||
Dependent on the platform it was compiled on, this library provides methods
|
|
||||||
to draw a window for image display, capture video from a camera or framegrabber
|
|
||||||
or read/write video streams from/to the file system.
|
|
||||||
|
|
||||||
This wrapper was semi-automatically created from the C/C++ headers and therefore
|
|
||||||
contains no Python documentation. Because all identifiers are identical to their
|
|
||||||
C/C++ counterparts, you can consult the standard manuals that come with OpenCV.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,152 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
|
|
||||||
// 2004-03-16, Gabriel Schreiber <schreiber@ient.rwth-aachen.de>
|
|
||||||
// Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
// Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
|
|
||||||
// 2006-08-29 Roman Stanchak -- converted to use CvMat rather than IplImage
|
|
||||||
|
|
||||||
|
|
||||||
%{
|
|
||||||
|
|
||||||
/// Accessor to convert a Python string into the imageData.
|
|
||||||
void CvMat_imageData_set(CvMat * self, PyObject* object)
|
|
||||||
{
|
|
||||||
char* py_string = PyString_AsString(object);
|
|
||||||
int depth = CV_MAT_DEPTH(self->type);
|
|
||||||
int cn = CV_MAT_CN(self->type);
|
|
||||||
|
|
||||||
int step = self->step ? self->step : CV_ELEM_SIZE(self->type) * self->cols;
|
|
||||||
|
|
||||||
if (depth == CV_8U && cn==3){
|
|
||||||
// RGB case
|
|
||||||
// The data is reordered beause OpenCV uses BGR instead of RGB
|
|
||||||
|
|
||||||
for (long line = 0; line < self->rows; ++line)
|
|
||||||
for (long pixel = 0; pixel < self->cols; ++pixel)
|
|
||||||
{
|
|
||||||
// In OpenCV the beginning of the lines are aligned
|
|
||||||
// to 4 Bytes. So use step instead of cols.
|
|
||||||
long position = line*step + pixel*3;
|
|
||||||
long sourcepos = line*self->cols*3 + pixel*3;
|
|
||||||
self->data.ptr[position ] = py_string[sourcepos+2];
|
|
||||||
self->data.ptr[position+1] = py_string[sourcepos+1];
|
|
||||||
self->data.ptr[position+2] = py_string[sourcepos ];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (depth == CV_8U && cn==1)
|
|
||||||
{
|
|
||||||
// Grayscale 8bit case
|
|
||||||
|
|
||||||
for (long line = 0; line < self->rows; ++line)
|
|
||||||
{
|
|
||||||
// In OpenCV the beginning of the lines are aligned
|
|
||||||
// to 4 Bytes. So use step instead of cols.
|
|
||||||
memcpy
|
|
||||||
(
|
|
||||||
self->data.ptr + line*step,
|
|
||||||
py_string + line*self->cols,
|
|
||||||
step
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( depth == CV_32F )
|
|
||||||
{
|
|
||||||
// float (32bit) case
|
|
||||||
for (long line = 0; line < self->rows; ++line)
|
|
||||||
{
|
|
||||||
// here we don not have to care about alignment as the Floats are
|
|
||||||
// as long as the alignment
|
|
||||||
memcpy
|
|
||||||
(
|
|
||||||
self->data.ptr + line*step,
|
|
||||||
py_string + line*self->cols*sizeof(float),
|
|
||||||
step
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( depth == CV_64F )
|
|
||||||
{
|
|
||||||
// double (64bit) case
|
|
||||||
for (long line = 0; line < self->rows; ++line)
|
|
||||||
{
|
|
||||||
// here we don not have to care about alignment as the Floats are
|
|
||||||
// as long as the alignment
|
|
||||||
memcpy
|
|
||||||
(
|
|
||||||
self->data.ptr + line*step,
|
|
||||||
py_string + line*self->cols*sizeof(double),
|
|
||||||
step
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// make some noise
|
|
||||||
SendErrorToPython (SWIG_TypeError,
|
|
||||||
"CvMat_imageData_set",
|
|
||||||
"cannot convert string data to this image format",
|
|
||||||
__FILE__, __LINE__, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Accessor to convert the imageData into a Python string.
|
|
||||||
PyObject* CvMat_imageData_get(CvMat * self)
|
|
||||||
{
|
|
||||||
if (!self->data.ptr)
|
|
||||||
{
|
|
||||||
PyErr_SetString(PyExc_TypeError, "Data pointer of CvMat is NULL");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int step = self->step ? self->step : CV_ELEM_SIZE(self->type) * self->cols;
|
|
||||||
return PyString_FromStringAndSize((const char *)self->data.ptr, self->rows*step);
|
|
||||||
}
|
|
||||||
|
|
||||||
%}
|
|
||||||
|
|
||||||
// add virtual member variable to CvMat
|
|
||||||
%extend CvMat {
|
|
||||||
PyObject * imageData;
|
|
||||||
};
|
|
@ -1,269 +0,0 @@
|
|||||||
#########################################################################################
|
|
||||||
#
|
|
||||||
# IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
#
|
|
||||||
# By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
# If you do not agree to this license, do not download, install,
|
|
||||||
# copy or use the software.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Intel License Agreement
|
|
||||||
# For Open Source Computer Vision Library
|
|
||||||
#
|
|
||||||
# Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
# Third party copyrights are property of their respective owners.
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
# are permitted provided that the following conditions are met:
|
|
||||||
#
|
|
||||||
# * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
# this list of conditions and the following disclaimer.
|
|
||||||
#
|
|
||||||
# * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
# this list of conditions and the following disclaimer in the documentation
|
|
||||||
# and/or other materials provided with the distribution.
|
|
||||||
#
|
|
||||||
# * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
# derived from this software without specific prior written permission.
|
|
||||||
#
|
|
||||||
# This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
# any express or implied warranties, including, but not limited to, the implied
|
|
||||||
# warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
# In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
# indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
# (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
# loss of use, data, or profits; or business interruption) however caused
|
|
||||||
# and on any theory of liability, whether in contract, strict liability,
|
|
||||||
# or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
# the use of this software, even if advised of the possibility of such damage.
|
|
||||||
#
|
|
||||||
#########################################################################################
|
|
||||||
|
|
||||||
"""Matlab syntax for OpenCV
|
|
||||||
|
|
||||||
For those who have switched from Matlab, this module offers similar syntax to the basic
|
|
||||||
Matlab commands. I.e. you can invoke 'imread' to load images, 'imshow', etc.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from cv import *
|
|
||||||
from highgui import cvShowImage,cvNamedWindow,cvLoadImage,cvWaitKey
|
|
||||||
|
|
||||||
#__all__ = ['imagesc', 'display', 'imread', 'imshow', 'saveimage', 'loadimage', 'pause',
|
|
||||||
# 'Image', 'Image8', 'Image8c3', 'Image32s', 'Image32f', 'Image64f']
|
|
||||||
|
|
||||||
def eye(*args):
|
|
||||||
mat = array(*args)
|
|
||||||
cvSetIdentity(mat);
|
|
||||||
return mat
|
|
||||||
|
|
||||||
def ones(*args):
|
|
||||||
mat = array(*args)
|
|
||||||
cvSet(mat, cvScalarAll(1.0))
|
|
||||||
return mat
|
|
||||||
|
|
||||||
def zeros(*args):
|
|
||||||
mat = array(*args)
|
|
||||||
cvSet(mat, cvScalarAll(0.0))
|
|
||||||
return mat
|
|
||||||
|
|
||||||
def array(*args):
|
|
||||||
m=1
|
|
||||||
n=1
|
|
||||||
c=1
|
|
||||||
classname='single'
|
|
||||||
nargs = len(args)
|
|
||||||
# nasty argument parsing
|
|
||||||
if nargs>0:
|
|
||||||
if isinstance(args[0],tuple) or isinstance(args[0],list) and len(args[0]) > 1:
|
|
||||||
m=args[0][0]
|
|
||||||
n=args[0][1]
|
|
||||||
if len(args[0])>2:
|
|
||||||
c=args[0][2]
|
|
||||||
if len(args)>1:
|
|
||||||
classname = args[1]
|
|
||||||
else:
|
|
||||||
m=args[0]
|
|
||||||
if nargs == 1:
|
|
||||||
n=args[0]
|
|
||||||
elif nargs > 1:
|
|
||||||
# is the last argument the classname?
|
|
||||||
if args[nargs-1].__class__ == str:
|
|
||||||
classname = args[nargs-1]
|
|
||||||
nargs-=1
|
|
||||||
if nargs > 1:
|
|
||||||
n = args[1]
|
|
||||||
if nargs > 2:
|
|
||||||
c = args[2]
|
|
||||||
|
|
||||||
if(classname=='double'):
|
|
||||||
depth=cv.CV_64F
|
|
||||||
elif(classname=='single'):
|
|
||||||
depth=cv.CV_32F
|
|
||||||
elif(classname=='int8'):
|
|
||||||
depth=cv.CV_8S
|
|
||||||
elif(classname=='uint8'):
|
|
||||||
depth=cv.CV_8U
|
|
||||||
elif(classname=='int16'):
|
|
||||||
depth=cv.CV_16S
|
|
||||||
elif(classname=='uint16'):
|
|
||||||
depth=cv.CV_16U
|
|
||||||
elif(classname=='int32' or classname=='uint32' or
|
|
||||||
classname=='int64' or classname=='uint64'):
|
|
||||||
depth=cv.CV_32S
|
|
||||||
else:
|
|
||||||
depth=cv.CV_32F
|
|
||||||
depth = CV_MAKETYPE(depth, c)
|
|
||||||
return cvCreateMat(m,n,depth)
|
|
||||||
|
|
||||||
def size(X,dim=-1):
|
|
||||||
# CvMat
|
|
||||||
if hasattr(X, "type"):
|
|
||||||
sz = (X.rows, X.cols, CV_MAT_CN(X.type))
|
|
||||||
# IplImage
|
|
||||||
elif hasattr(X, "nChannels"):
|
|
||||||
sz = (X.height, X.width, X.nChannels)
|
|
||||||
# CvMatNd
|
|
||||||
else:
|
|
||||||
sz = cvGetDims(X)
|
|
||||||
|
|
||||||
if dim is -1:
|
|
||||||
return sz
|
|
||||||
return sz[dim]
|
|
||||||
|
|
||||||
def reshape(X, m, n=1, c=-1):
|
|
||||||
'''
|
|
||||||
reshape will produce different results in matlab and python due to the
|
|
||||||
order of elements stored in the array (row-major vs. column major)
|
|
||||||
'''
|
|
||||||
if c==-1:
|
|
||||||
c = CV_MAT_CN(X)
|
|
||||||
return cvReshape(X, c, m)
|
|
||||||
|
|
||||||
|
|
||||||
def im2float(im):
|
|
||||||
mat = cvGetMat(im);
|
|
||||||
if CV_MAT_DEPTH(mat.type)==CV_32F:
|
|
||||||
return mat
|
|
||||||
|
|
||||||
im64f = array(size(im), 'float')
|
|
||||||
cvConvertScale(im, im64f, 1.0, 0.0)
|
|
||||||
return im64f
|
|
||||||
|
|
||||||
def im2double(im):
|
|
||||||
mat = cvGetMat(im);
|
|
||||||
if CV_MAT_DEPTH(mat.type)==CV_64F:
|
|
||||||
return mat
|
|
||||||
im64f = array(size(im), 'double')
|
|
||||||
cvConvertScale(im, im64f, 1.0, 0.0)
|
|
||||||
return im64f
|
|
||||||
|
|
||||||
def rgb2ntsc (rgb):
|
|
||||||
trans = [ [0.299, 0.596, 0.211], [0.587, -0.274, -0.523], [0.114, -0.322, 0.312] ];
|
|
||||||
return rgb * trans;
|
|
||||||
|
|
||||||
def rgb2gray(rgb):
|
|
||||||
ntscmap = rgb2ntsc (rgb);
|
|
||||||
graymap = ntscmap [:, 1] * ones (1, 3);
|
|
||||||
return graymap
|
|
||||||
|
|
||||||
class cvImageViewer:
|
|
||||||
"""
|
|
||||||
Wrapper class for some matlab/octave/scilab syntax image viewing functions
|
|
||||||
"""
|
|
||||||
currentWindowName = ""
|
|
||||||
currentWindow = -1
|
|
||||||
maxWindow = -1
|
|
||||||
|
|
||||||
def imagesc(self,im, clims=None):
|
|
||||||
"""
|
|
||||||
Display a normalized version of the image
|
|
||||||
"""
|
|
||||||
if(self.currentWindow==-1):
|
|
||||||
self.display()
|
|
||||||
|
|
||||||
# don't normalize multichannel image
|
|
||||||
#if(im.nChannels>1):
|
|
||||||
# if(im.depth!=cv.IPL_DEPTH_8U):
|
|
||||||
# im2 = cvCreateImage( cvSize(im.width, im.height), cv.IPL_DEPTH_8U, im.nChannels)
|
|
||||||
# cvScale(im, im2)
|
|
||||||
# im = im2
|
|
||||||
# cvShowImage(self.currentWindowName, im)
|
|
||||||
# return self.currentWindow
|
|
||||||
|
|
||||||
# normalize image
|
|
||||||
if clims:
|
|
||||||
[minv, maxv] = clims
|
|
||||||
else:
|
|
||||||
[minv,maxv] = cvMinMaxLoc(im)
|
|
||||||
if maxv != minv:
|
|
||||||
s = 255.0/(maxv-minv)
|
|
||||||
shift = 255*(-minv)/(maxv-minv)
|
|
||||||
else:
|
|
||||||
s = 1.0
|
|
||||||
shift = -maxv
|
|
||||||
|
|
||||||
im2 = array( size(im), 'uint8' )
|
|
||||||
cvConvertScale(im, im2, s, shift)
|
|
||||||
|
|
||||||
cvShowImage(self.currentWindowName, im2)
|
|
||||||
|
|
||||||
def image(self, im):
|
|
||||||
"""
|
|
||||||
Display image as is -- probably not what you'd expect for FP or integer images
|
|
||||||
"""
|
|
||||||
if(self.currentWindow==-1):
|
|
||||||
self.display()
|
|
||||||
|
|
||||||
cvShowImage(self.currentWindowName,im)
|
|
||||||
return self.currentWindow
|
|
||||||
|
|
||||||
|
|
||||||
def display(self, index=-1):
|
|
||||||
"""
|
|
||||||
open a new window
|
|
||||||
"""
|
|
||||||
if(index==-1):
|
|
||||||
self.maxWindow = self.maxWindow+1;
|
|
||||||
index= self.maxWindow;
|
|
||||||
|
|
||||||
if(index > self.maxWindow):
|
|
||||||
self.maxWindow = index;
|
|
||||||
|
|
||||||
self.currentWindow = index;
|
|
||||||
self.currentWindowName = "opencv-python window %d" % self.currentWindow
|
|
||||||
cvNamedWindow(self.currentWindowName,0)
|
|
||||||
return self.currentWindow
|
|
||||||
|
|
||||||
def drawnow():
|
|
||||||
cvWaitKey(10)
|
|
||||||
|
|
||||||
def pause(delay=-1):
|
|
||||||
if delay<0:
|
|
||||||
cvWaitKey(-1)
|
|
||||||
else:
|
|
||||||
cvWaitKey(delay*1000)
|
|
||||||
|
|
||||||
c = cvImageViewer()
|
|
||||||
imagesc = c.imagesc
|
|
||||||
display = c.display
|
|
||||||
image = c.image
|
|
||||||
imshow = c.image
|
|
||||||
|
|
||||||
def imread(fname):
|
|
||||||
return cvLoadImage(fname, -1)
|
|
||||||
loadimage = imread
|
|
||||||
imload = imread
|
|
||||||
|
|
||||||
def imsave(im, fname, format):
|
|
||||||
return cvSaveImage(fname, im)
|
|
||||||
saveimage = imsave
|
|
||||||
|
|
||||||
def gradient(F):
|
|
||||||
F = im2float(F)
|
|
||||||
Fx = array(size(F))
|
|
||||||
Fy = array(size(F))
|
|
||||||
|
|
||||||
# new images
|
|
||||||
cvSobel(F, Fx, 1, 0, CV_SCHARR)
|
|
||||||
cvSobel(F, Fy, 0, 1, CV_SCHARR)
|
|
||||||
return (Fx, Fy)
|
|
@ -1,118 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
|
|
||||||
// 2004-03-16, Mark Asbach <asbach@ient.rwth-aachen.de>
|
|
||||||
// Institute of Communications Engineering, RWTH Aachen University
|
|
||||||
|
|
||||||
%module(package="opencv") ml
|
|
||||||
|
|
||||||
%{
|
|
||||||
#include <ml.h>
|
|
||||||
#include <cxtypes.h>
|
|
||||||
#include <cv.h>
|
|
||||||
#include <highgui.h>
|
|
||||||
#include "pyhelpers.h"
|
|
||||||
#include "pycvseq.hpp"
|
|
||||||
%}
|
|
||||||
|
|
||||||
// include python-specific files
|
|
||||||
%include "./nointpb.i"
|
|
||||||
%include "./pytypemaps.i"
|
|
||||||
%include "exception.i"
|
|
||||||
|
|
||||||
%import "../general/cv.i"
|
|
||||||
|
|
||||||
%include "../general/memory.i"
|
|
||||||
%include "../general/typemaps.i"
|
|
||||||
|
|
||||||
%newobject cvCreateCNNConvolutionLayer;
|
|
||||||
%newobject cvCreateCNNSubSamplingLayer;
|
|
||||||
%newobject cvCreateCNNFullConnectLayer;
|
|
||||||
%newobject cvCreateCNNetwork;
|
|
||||||
%newobject cvTrainCNNClassifier;
|
|
||||||
|
|
||||||
%newobject cvCreateCrossValidationEstimateModel;
|
|
||||||
|
|
||||||
|
|
||||||
%pythoncode
|
|
||||||
%{
|
|
||||||
|
|
||||||
__doc__ = """Machine Learning
|
|
||||||
|
|
||||||
The Machine Learning library (ML) is a set of classes and functions for
|
|
||||||
statistical classification, regression and clustering of data.
|
|
||||||
|
|
||||||
Most of the classification and regression algorithms are implemented as classes.
|
|
||||||
As the algorithms have different sets of features (like ability to handle missing
|
|
||||||
measurements, or categorical input variables etc.), there is only little common
|
|
||||||
ground between the classes. This common ground is defined by the class CvStatModel
|
|
||||||
that all the other ML classes are derived from.
|
|
||||||
|
|
||||||
This wrapper was semi-automatically created from the C/C++ headers and therefore
|
|
||||||
contains no Python documentation. Because all identifiers are identical to their
|
|
||||||
C/C++ counterparts, you can consult the standard manuals that come with OpenCV.
|
|
||||||
"""
|
|
||||||
|
|
||||||
%}
|
|
||||||
|
|
||||||
%extend CvEM
|
|
||||||
{
|
|
||||||
PyObject * get_covs()
|
|
||||||
{
|
|
||||||
CvMat ** pointers = const_cast<CvMat **> (self->get_covs());
|
|
||||||
int n = self->get_nclusters();
|
|
||||||
|
|
||||||
PyObject * result = PyTuple_New(n);
|
|
||||||
for (int i=0; i<n; ++i)
|
|
||||||
{
|
|
||||||
PyObject * obj = SWIG_NewPointerObj(pointers[i], $descriptor(CvMat *), 0);
|
|
||||||
PyTuple_SetItem(result, i, obj);
|
|
||||||
//Py_DECREF(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
%ignore CvEM::get_covs;
|
|
||||||
|
|
||||||
%include "ml.h"
|
|
File diff suppressed because it is too large
Load Diff
@ -1,34 +0,0 @@
|
|||||||
/* This file is to prevent problems with swig <= 1.3.25 which use
|
|
||||||
PyInt_AS_LONG and may cause some corruption on RedHat systems.
|
|
||||||
|
|
||||||
Include it in every .i file who generate a C/C++ file */
|
|
||||||
|
|
||||||
%runtime%{
|
|
||||||
/* define the PyAPI_FUNC macro if it doesn't exist, for example with Python
|
|
||||||
version below 2.3... But not really tested... */
|
|
||||||
#ifndef PyAPI_FUNC
|
|
||||||
# define PyAPI_FUNC(RTYPE) RTYPE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* remove the PyInt_AS_LONG if defined, as this cause problems on RedHat */
|
|
||||||
#ifdef PyInt_AS_LONG
|
|
||||||
#undef PyInt_AS_LONG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* wrapper to the better function PyInt_AsLong, removing problems
|
|
||||||
with RedHat (I hope) */
|
|
||||||
long PyInt_AS_LONG (PyObject *obj) {
|
|
||||||
return PyInt_AsLong (obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* remove the PyFloat_AS_DOUBLE if defined, to prevent errors */
|
|
||||||
#ifdef PyFloat_AS_DOUBLE
|
|
||||||
#undef PyFloat_AS_DOUBLE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* wrapper to the better function PyFloat_AS_DOUBLE, to prevent errors */
|
|
||||||
double PyFloat_AS_DOUBLE (PyObject *obj) {
|
|
||||||
return PyFloat_AsDouble (obj);
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
|
|
@ -1,104 +0,0 @@
|
|||||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
|
||||||
//
|
|
||||||
// By downloading, copying, installing or using the software you agree to this license.
|
|
||||||
// If you do not agree to this license, do not download, install,
|
|
||||||
// copy or use the software.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
|
||||||
// Third party copyrights are property of their respective owners.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
// are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistribution's of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
|
||||||
// derived from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
// This software is provided by the copyright holders and contributors "as is" and
|
|
||||||
// any express or implied warranties, including, but not limited to, the implied
|
|
||||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
|
||||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
|
||||||
// indirect, incidental, special, exemplary, or consequential damages
|
|
||||||
// (including, but not limited to, procurement of substitute goods or services;
|
|
||||||
// loss of use, data, or profits; or business interruption) however caused
|
|
||||||
// and on any theory of liability, whether in contract, strict liability,
|
|
||||||
// or tort (including negligence or otherwise) arising in any way out of
|
|
||||||
// the use of this software, even if advised of the possibility of such damage.
|
|
||||||
//
|
|
||||||
//M*/
|
|
||||||
|
|
||||||
#ifndef PY_CV_SEQ_H
|
|
||||||
#define PY_CV_SEQ_H
|
|
||||||
|
|
||||||
#include "cxcore.h"
|
|
||||||
#include "cvtypes.h"
|
|
||||||
|
|
||||||
|
|
||||||
/** class to make sequence iteration nicer */
|
|
||||||
template<class T>
|
|
||||||
class CvTypedSeqReader : public CvSeqReader {
|
|
||||||
int pos;
|
|
||||||
public:
|
|
||||||
CvTypedSeqReader( const CvSeq * seq ){
|
|
||||||
cvStartReadSeq( seq, this );
|
|
||||||
pos = 0;
|
|
||||||
}
|
|
||||||
T * current(){
|
|
||||||
return (T*) this->ptr;
|
|
||||||
}
|
|
||||||
void next(){
|
|
||||||
CV_NEXT_SEQ_ELEM( this->seq->elem_size, *this );
|
|
||||||
pos++;
|
|
||||||
}
|
|
||||||
bool valid(){
|
|
||||||
return pos<this->seq->total;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
class CvTypedSeq : public CvSeq {
|
|
||||||
public:
|
|
||||||
static CvTypedSeq<T> * cast(CvSeq * seq){
|
|
||||||
return (CvTypedSeq<T> *) seq;
|
|
||||||
}
|
|
||||||
T * __getitem__ (int i){
|
|
||||||
return (T *) cvGetSeqElem(this, i);
|
|
||||||
}
|
|
||||||
void __setitem__ (int i, T * obj){
|
|
||||||
T * ptr = this->__getitem__(i);
|
|
||||||
memcpy(ptr, obj, sizeof(T));
|
|
||||||
}
|
|
||||||
void append(T * obj){
|
|
||||||
cvSeqPush( this, obj );
|
|
||||||
}
|
|
||||||
T * pop(){
|
|
||||||
T * obj = new T;
|
|
||||||
cvSeqPop( this, obj );
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T, int size=2>
|
|
||||||
struct CvTuple {
|
|
||||||
T val[2];
|
|
||||||
void __setitem__(int i, T * obj){
|
|
||||||
val[i] = *obj;
|
|
||||||
}
|
|
||||||
const T & __getitem__(int i){
|
|
||||||
return val[i];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //PY_CV_SEQ_H
|
|
@ -1,606 +0,0 @@
|
|||||||
#include "pyhelpers.h"
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
int PySwigObject_Check(PyObject *op);
|
|
||||||
|
|
||||||
/* Py_ssize_t for old Pythons */
|
|
||||||
#if PY_VERSION_HEX < 0x02050000
|
|
||||||
typedef int Py_ssize_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PyObject * PyTuple_FromIntArray(int * arr, int len){
|
|
||||||
PyObject * obj = PyTuple_New(len);
|
|
||||||
for(int i=0; i<len; i++){
|
|
||||||
PyTuple_SetItem(obj, i, PyLong_FromLong( arr[i] ) );
|
|
||||||
}
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject * SWIG_SetResult(PyObject * result, PyObject * obj){
|
|
||||||
if(result){
|
|
||||||
Py_DECREF(result);
|
|
||||||
}
|
|
||||||
result = PyTuple_New(1);
|
|
||||||
PyTuple_SetItem(result, 0, obj);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject * SWIG_AppendResult(PyObject * result, PyObject ** to_add, int num){
|
|
||||||
if ((!result) || (result == Py_None)) {
|
|
||||||
/* no other results, so just add our values */
|
|
||||||
|
|
||||||
/* if only one object, return that */
|
|
||||||
if(num==1){
|
|
||||||
return to_add[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* create a new tuple to put in our new pointer python objects */
|
|
||||||
result = PyTuple_New (num);
|
|
||||||
|
|
||||||
/* put in our new pointer python objects */
|
|
||||||
for(int i=0; i<num; i++){
|
|
||||||
PyTuple_SetItem (result, i, to_add[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* we have other results, so add it to the end */
|
|
||||||
|
|
||||||
if (!PyTuple_Check (result)) {
|
|
||||||
/* previous result is not a tuple, so create one and put
|
|
||||||
previous result and current pointer in it */
|
|
||||||
|
|
||||||
/* first, save previous result */
|
|
||||||
PyObject *obj_save = result;
|
|
||||||
|
|
||||||
/* then, create the tuple */
|
|
||||||
result = PyTuple_New (1);
|
|
||||||
|
|
||||||
/* finaly, put the saved value in the tuple */
|
|
||||||
PyTuple_SetItem (result, 0, obj_save);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* create a new tuple to put in our new pointer python object */
|
|
||||||
PyObject *my_obj = PyTuple_New (num);
|
|
||||||
|
|
||||||
/* put in our new pointer python object */
|
|
||||||
for( int i=0; i<num ; i++ ){
|
|
||||||
PyTuple_SetItem (my_obj, i, to_add[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* save the previous result */
|
|
||||||
PyObject *obj_save = result;
|
|
||||||
|
|
||||||
/* concat previous and our new result */
|
|
||||||
result = PySequence_Concat (obj_save, my_obj);
|
|
||||||
|
|
||||||
/* decrement the usage of no more used objects */
|
|
||||||
Py_DECREF (obj_save);
|
|
||||||
Py_DECREF (my_obj);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void cv_arr_write(FILE * f, const char * fmt, T * data, size_t rows, size_t nch, size_t step){
|
|
||||||
size_t i,j,k;
|
|
||||||
char * cdata = (char *) data;
|
|
||||||
const char * chdelim1="", * chdelim2="";
|
|
||||||
|
|
||||||
// only output channel parens if > 1
|
|
||||||
if(nch>1){
|
|
||||||
chdelim1="(";
|
|
||||||
chdelim2=")";
|
|
||||||
}
|
|
||||||
|
|
||||||
fputs("[",f);
|
|
||||||
for(i=0; i<rows; i++){
|
|
||||||
fputs("[",f);
|
|
||||||
|
|
||||||
// first element
|
|
||||||
// out<<chdelim1;
|
|
||||||
fputs(chdelim1, f);
|
|
||||||
fprintf(f, fmt, ((T*)(cdata+i*step))[0]);
|
|
||||||
for(k=1; k<nch; k++){
|
|
||||||
fputs(", ", f);
|
|
||||||
fprintf(f, fmt, ((T*)(cdata+i*step))[k]);
|
|
||||||
}
|
|
||||||
fputs(chdelim2,f);
|
|
||||||
|
|
||||||
// remaining elements
|
|
||||||
for(j=nch*sizeof(T); j<step; j+=(nch*sizeof(T))){
|
|
||||||
fprintf(f, ",%s", chdelim1);
|
|
||||||
fprintf(f, fmt, ((T*)(cdata+i*step+j))[0]);
|
|
||||||
for(k=1; k<nch; k++){
|
|
||||||
fputs(", ", f);
|
|
||||||
fprintf(f, fmt, ((T*)(cdata+i*step+j))[k]);
|
|
||||||
}
|
|
||||||
fputs(chdelim2, f);
|
|
||||||
}
|
|
||||||
fputs( "]\n", f );
|
|
||||||
}
|
|
||||||
fputs( "]", f );
|
|
||||||
}
|
|
||||||
|
|
||||||
void cvArrPrint(CvArr * arr){
|
|
||||||
CvMat * mat;
|
|
||||||
CvMat stub;
|
|
||||||
|
|
||||||
mat = cvGetMat(arr, &stub);
|
|
||||||
|
|
||||||
int cn = CV_MAT_CN(mat->type);
|
|
||||||
int depth = CV_MAT_DEPTH(mat->type);
|
|
||||||
int step = MAX(mat->step, cn*mat->cols*CV_ELEM_SIZE(depth));
|
|
||||||
|
|
||||||
|
|
||||||
switch(depth){
|
|
||||||
case CV_8U:
|
|
||||||
cv_arr_write(stdout, "%u", (uchar *)mat->data.ptr, mat->rows, cn, step);
|
|
||||||
break;
|
|
||||||
case CV_8S:
|
|
||||||
cv_arr_write(stdout, "%d", (char *)mat->data.ptr, mat->rows, cn, step);
|
|
||||||
break;
|
|
||||||
case CV_16U:
|
|
||||||
cv_arr_write(stdout, "%u", (ushort *)mat->data.ptr, mat->rows, cn, step);
|
|
||||||
break;
|
|
||||||
case CV_16S:
|
|
||||||
cv_arr_write(stdout, "%d", (short *)mat->data.ptr, mat->rows, cn, step);
|
|
||||||
break;
|
|
||||||
case CV_32S:
|
|
||||||
cv_arr_write(stdout, "%d", (int *)mat->data.ptr, mat->rows, cn, step);
|
|
||||||
break;
|
|
||||||
case CV_32F:
|
|
||||||
cv_arr_write(stdout, "%f", (float *)mat->data.ptr, mat->rows, cn, step);
|
|
||||||
break;
|
|
||||||
case CV_64F:
|
|
||||||
cv_arr_write(stdout, "%g", (double *)mat->data.ptr, mat->rows, cn, step);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
CV_Error( CV_StsError, "Unknown element type");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// deal with negative array indices
|
|
||||||
int PyLong_AsIndex( PyObject * idx_object, int len ){
|
|
||||||
int idx = PyLong_AsLong( idx_object );
|
|
||||||
if(idx<0) return len+idx;
|
|
||||||
return idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
CvRect PySlice_to_CvRect(CvArr * src, PyObject * idx_object){
|
|
||||||
CvSize sz = cvGetSize(src);
|
|
||||||
//printf("Size %dx%d\n", sz.height, sz.width);
|
|
||||||
int lower[2], upper[2];
|
|
||||||
Py_ssize_t len, start, stop, step, slicelength;
|
|
||||||
|
|
||||||
if(PyInt_Check(idx_object) || PyLong_Check(idx_object)){
|
|
||||||
// if array is a row vector, assume index into columns
|
|
||||||
if(sz.height>1){
|
|
||||||
lower[0] = PyLong_AsIndex( idx_object, sz.height );
|
|
||||||
upper[0] = lower[0] + 1;
|
|
||||||
lower[1] = 0;
|
|
||||||
upper[1] = sz.width;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
lower[0] = 0;
|
|
||||||
upper[0] = sz.height;
|
|
||||||
lower[1] = PyLong_AsIndex( idx_object, sz.width );
|
|
||||||
upper[1] = lower[1]+1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1. Slice
|
|
||||||
else if(PySlice_Check(idx_object)){
|
|
||||||
len = sz.height;
|
|
||||||
if(PySlice_GetIndicesEx( (PySliceObject*)idx_object, len, &start, &stop, &step, &slicelength )!=0){
|
|
||||||
printf("Error in PySlice_GetIndicesEx: returning NULL");
|
|
||||||
PyErr_SetString(PyExc_Exception, "Error");
|
|
||||||
return cvRect(0,0,0,0);
|
|
||||||
}
|
|
||||||
// if array is a row vector, assume index bounds are into columns
|
|
||||||
if(sz.height>1){
|
|
||||||
lower[0] = (int) start; // use c convention of start index = 0
|
|
||||||
upper[0] = (int) stop; // use c convention
|
|
||||||
lower[1] = 0;
|
|
||||||
upper[1] = sz.width;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
lower[1] = (int) start; // use c convention of start index = 0
|
|
||||||
upper[1] = (int) stop; // use c convention
|
|
||||||
lower[0] = 0;
|
|
||||||
upper[0] = sz.height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Tuple
|
|
||||||
else if(PyTuple_Check(idx_object)){
|
|
||||||
//printf("PyTuple{\n");
|
|
||||||
if(PyObject_Length(idx_object)!=2){
|
|
||||||
//printf("Expected a sequence of length 2: returning NULL");
|
|
||||||
PyErr_SetString(PyExc_ValueError, "Expected a sequence with 2 elements");
|
|
||||||
return cvRect(0,0,0,0);
|
|
||||||
}
|
|
||||||
for(int i=0; i<2; i++){
|
|
||||||
PyObject *o = PyTuple_GetItem(idx_object, i);
|
|
||||||
|
|
||||||
// 2a. Slice -- same as above
|
|
||||||
if(PySlice_Check(o)){
|
|
||||||
//printf("PySlice\n");
|
|
||||||
len = (i==0 ? sz.height : sz.width);
|
|
||||||
if(PySlice_GetIndicesEx( (PySliceObject*)o, len, &start, &stop, &step, &slicelength )!=0){
|
|
||||||
PyErr_SetString(PyExc_Exception, "Error");
|
|
||||||
printf("Error in PySlice_GetIndicesEx: returning NULL");
|
|
||||||
return cvRect(0,0,0,0);
|
|
||||||
}
|
|
||||||
//printf("PySlice_GetIndecesEx(%d, %d, %d, %d, %d)\n", len, start, stop, step, slicelength);
|
|
||||||
lower[i] = start;
|
|
||||||
upper[i] = stop;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2b. Integer
|
|
||||||
else if(PyInt_Check(o) || PyLong_Check(o)){
|
|
||||||
//printf("PyInt\n");
|
|
||||||
lower[i] = PyLong_AsIndex(o, i==0 ? sz.height : sz.width);
|
|
||||||
upper[i] = lower[i]+1;
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
PyErr_SetString(PyExc_TypeError, "Expected a sequence of slices or integers");
|
|
||||||
printf("Expected a slice or int as sequence item: returning NULL");
|
|
||||||
return cvRect(0,0,0,0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
PyErr_SetString( PyExc_TypeError, "Expected a slice or sequence");
|
|
||||||
printf("Expected a slice or sequence: returning NULL");
|
|
||||||
return cvRect(0,0,0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//lower[0] = MAX(0, lower[0]);
|
|
||||||
//lower[1] = MAX(0, lower[1]);
|
|
||||||
//upper[0] = MIN(sz.height, upper[0]);
|
|
||||||
//upper[1] = MIN(sz.width, upper[1]);
|
|
||||||
//printf("Slice=%d %d %d %d\n", lower[0], upper[0], lower[1], upper[1]);
|
|
||||||
return cvRect(lower[1],lower[0], upper[1]-lower[1], upper[0]-lower[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CheckSliceBounds(CvRect * rect, int w, int h){
|
|
||||||
//printf("__setitem__ slice(%d:%d, %d:%d) array(%d,%d)", rect.x, rect.y, rect.x+rect.width, rect.y+rect.height, w, h);
|
|
||||||
if(rect->width<=0 || rect->height<=0 ||
|
|
||||||
rect->width>w || rect->height>h ||
|
|
||||||
rect->x<0 || rect->y<0 ||
|
|
||||||
rect->x>= w || rect->y >=h){
|
|
||||||
char errstr[256];
|
|
||||||
|
|
||||||
// previous function already set error string
|
|
||||||
if(rect->width==0 && rect->height==0 && rect->x==0 && rect->y==0) return -1;
|
|
||||||
|
|
||||||
sprintf(errstr, "Requested slice [ %d:%d %d:%d ] oversteps array sized [ %d %d ]",
|
|
||||||
rect->x, rect->y, rect->x+rect->width, rect->y+rect->height, w, h);
|
|
||||||
PyErr_SetString(PyExc_IndexError, errstr);
|
|
||||||
//PyErr_SetString(PyExc_ValueError, errstr);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
double PyObject_AsDouble(PyObject * obj){
|
|
||||||
if(PyNumber_Check(obj)){
|
|
||||||
if(PyFloat_Check(obj)){
|
|
||||||
return PyFloat_AsDouble(obj);
|
|
||||||
}
|
|
||||||
else if(PyInt_Check(obj) || PyLong_Check(obj)){
|
|
||||||
return (double) PyLong_AsLong(obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PyErr_SetString( PyExc_TypeError, "Could not convert python object to Double");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
long PyObject_AsLong(PyObject * obj){
|
|
||||||
if(PyNumber_Check(obj)){
|
|
||||||
if(PyFloat_Check(obj)){
|
|
||||||
return (long) PyFloat_AsDouble(obj);
|
|
||||||
}
|
|
||||||
else if(PyInt_Check(obj) || PyLong_Check(obj)){
|
|
||||||
return PyLong_AsLong(obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PyErr_SetString( PyExc_TypeError, "Could not convert python object to Long");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
CvArr * PyArray_to_CvArr (PyObject * obj)
|
|
||||||
{
|
|
||||||
// let's try to create a temporary CvMat header that points to the
|
|
||||||
// data owned by obj and reflects its memory layout
|
|
||||||
|
|
||||||
CvArr * cvarr = NULL;
|
|
||||||
|
|
||||||
void * raw_data = 0;
|
|
||||||
long rows;
|
|
||||||
long cols;
|
|
||||||
long channels;
|
|
||||||
long step;
|
|
||||||
long mat_type = 7;
|
|
||||||
long element_size = 1;
|
|
||||||
|
|
||||||
// infer layout from array interface
|
|
||||||
PyObject * interface = PyObject_GetAttrString (obj, "__array_interface__");
|
|
||||||
|
|
||||||
|
|
||||||
// the array interface should be a dict
|
|
||||||
if (PyMapping_Check (interface))
|
|
||||||
{
|
|
||||||
if (PyMapping_HasKeyString (interface, (char*)"version") &&
|
|
||||||
PyMapping_HasKeyString (interface, (char*)"shape") &&
|
|
||||||
PyMapping_HasKeyString (interface, (char*)"typestr") &&
|
|
||||||
PyMapping_HasKeyString (interface, (char*)"data"))
|
|
||||||
{
|
|
||||||
PyObject * version = PyMapping_GetItemString (interface, (char*)"version");
|
|
||||||
PyObject * shape = PyMapping_GetItemString (interface, (char*)"shape");
|
|
||||||
PyObject * typestr = PyMapping_GetItemString (interface, (char*)"typestr");
|
|
||||||
PyObject * data = PyMapping_GetItemString (interface, (char*)"data");
|
|
||||||
|
|
||||||
if (!PyInt_Check (version) || PyInt_AsLong (version) != 3)
|
|
||||||
PyErr_SetString(PyExc_TypeError, "OpenCV understands version 3 of the __array_interface__ only");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!PyTuple_Check (shape) || PyTuple_Size (shape) < 2 || PyTuple_Size (shape) > 3)
|
|
||||||
PyErr_SetString(PyExc_TypeError, "arrays must have a shape with 2 or 3 dimensions");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rows = PyInt_AsLong (PyTuple_GetItem (shape, 0));
|
|
||||||
cols = PyInt_AsLong (PyTuple_GetItem (shape, 1));
|
|
||||||
channels = PyTuple_Size (shape) < 3 ? 1 : PyInt_AsLong (PyTuple_GetItem (shape, 2));
|
|
||||||
|
|
||||||
if (rows < 1 || cols < 1 || channels < 1 || channels > 4)
|
|
||||||
PyErr_SetString(PyExc_TypeError, "rows and columns must be positive, channels from 1 to 4");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// fprintf (stderr, "rows: %ld, cols: %ld, channels %ld\n", rows, cols, channels); fflush (stderr);
|
|
||||||
|
|
||||||
if (! PyTuple_Check (data) || PyTuple_Size (data) != 2 ||
|
|
||||||
!(PyInt_Check (PyTuple_GetItem (data,0)) || PyLong_Check (PyTuple_GetItem (data,0))) ||
|
|
||||||
!(PyBool_Check (PyTuple_GetItem (data,1)) && !PyInt_AsLong (PyTuple_GetItem (data,1))))
|
|
||||||
PyErr_SetString (PyExc_TypeError, "arrays must have a pointer to writeable data");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
raw_data = PyLong_AsVoidPtr (PyTuple_GetItem (data,0));
|
|
||||||
// fprintf(stderr, "raw_data: %p\n", raw_data); fflush (stderr);
|
|
||||||
|
|
||||||
char * format_str = NULL;
|
|
||||||
Py_ssize_t len = 0;
|
|
||||||
|
|
||||||
if (!PyString_Check (typestr) || PyString_AsStringAndSize (typestr, & format_str, &len) == -1 || len !=3)
|
|
||||||
PyErr_SetString(PyExc_TypeError, "there is something wrong with the format string");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// fprintf(stderr, "format: %c %c\n", format_str[1], format_str[2]); fflush (stderr);
|
|
||||||
|
|
||||||
if (format_str[1] == 'u' && format_str[2] == '1')
|
|
||||||
{
|
|
||||||
element_size = 1;
|
|
||||||
mat_type = CV_MAKETYPE(CV_8U, channels);
|
|
||||||
}
|
|
||||||
else if (format_str[1] == 'i' && format_str[2] == '1')
|
|
||||||
{
|
|
||||||
element_size = 1;
|
|
||||||
mat_type = CV_MAKETYPE(CV_8S, channels);
|
|
||||||
}
|
|
||||||
else if (format_str[1] == 'u' && format_str[2] == '2')
|
|
||||||
{
|
|
||||||
element_size = 2;
|
|
||||||
mat_type = CV_MAKETYPE(CV_16U, channels);
|
|
||||||
}
|
|
||||||
else if (format_str[1] == 'i' && format_str[2] == '2')
|
|
||||||
{
|
|
||||||
element_size = 2;
|
|
||||||
mat_type = CV_MAKETYPE(CV_16S, channels);
|
|
||||||
}
|
|
||||||
else if (format_str[1] == 'i' && format_str[2] == '4')
|
|
||||||
{
|
|
||||||
element_size = 4;
|
|
||||||
mat_type = CV_MAKETYPE(CV_32S, channels);
|
|
||||||
}
|
|
||||||
else if (format_str[1] == 'f' && format_str[2] == '4')
|
|
||||||
{
|
|
||||||
element_size = 4;
|
|
||||||
mat_type = CV_MAKETYPE(CV_32F, channels);
|
|
||||||
}
|
|
||||||
else if (format_str[1] == 'f' && format_str[2] == '8')
|
|
||||||
{
|
|
||||||
element_size = 8;
|
|
||||||
mat_type = CV_MAKETYPE(CV_64F, channels);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PyErr_SetString(PyExc_TypeError, "unknown or unhandled element format");
|
|
||||||
mat_type = CV_USRTYPE1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// handle strides if given
|
|
||||||
// TODO: implement stride handling
|
|
||||||
step = cols * channels * element_size;
|
|
||||||
if (PyMapping_HasKeyString (interface, (char*)"strides"))
|
|
||||||
{
|
|
||||||
PyObject * strides = PyMapping_GetItemString (interface, (char*)"strides");
|
|
||||||
|
|
||||||
if (strides != Py_None)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "we have strides ... not handled!\n"); fflush (stderr);
|
|
||||||
PyErr_SetString(PyExc_TypeError, "arrays with strides not handled yet");
|
|
||||||
mat_type = CV_USRTYPE1; // use this to denote, we've got an error
|
|
||||||
}
|
|
||||||
|
|
||||||
Py_DECREF (strides);
|
|
||||||
}
|
|
||||||
|
|
||||||
// create matrix header if everything is okay
|
|
||||||
if (mat_type != CV_USRTYPE1)
|
|
||||||
{
|
|
||||||
CvMat * temp_matrix = cvCreateMatHeader (rows, cols, mat_type);
|
|
||||||
cvSetData (temp_matrix, raw_data, step);
|
|
||||||
cvarr = temp_matrix;
|
|
||||||
|
|
||||||
// fprintf(stderr, "step_size: %ld, type: %ld\n", step, mat_type); fflush (stderr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Py_DECREF (data);
|
|
||||||
Py_DECREF (typestr);
|
|
||||||
Py_DECREF (shape);
|
|
||||||
Py_DECREF (version);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Py_DECREF (interface);
|
|
||||||
|
|
||||||
return cvarr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Convert Python lists to CvMat *
|
|
||||||
CvArr * PySequence_to_CvArr (PyObject * obj)
|
|
||||||
{
|
|
||||||
int dims [CV_MAX_DIM] = { 1, 1, 1};
|
|
||||||
PyObject * container[CV_MAX_DIM+1] = {NULL, NULL, NULL, NULL};
|
|
||||||
int ndim = 0;
|
|
||||||
PyObject * item = Py_None;
|
|
||||||
|
|
||||||
// TODO: implement type detection - currently we create CV_64F only
|
|
||||||
// scan full array to
|
|
||||||
// - figure out dimensions
|
|
||||||
// - check consistency of dimensions
|
|
||||||
// - find appropriate data-type and signedness
|
|
||||||
// enum NEEDED_DATATYPE { NEEDS_CHAR, NEEDS_INTEGER, NEEDS_FLOAT, NEEDS_DOUBLE };
|
|
||||||
// NEEDED_DATATYPE needed_datatype = NEEDS_CHAR;
|
|
||||||
// bool needs_sign = false;
|
|
||||||
|
|
||||||
// scan first entries to find out dimensions
|
|
||||||
for (item = obj, ndim = 0; PySequence_Check (item) && ndim <= CV_MAX_DIM; ndim++)
|
|
||||||
{
|
|
||||||
dims [ndim] = PySequence_Size (item);
|
|
||||||
container [ndim] = PySequence_GetItem (item, 0);
|
|
||||||
item = container[ndim];
|
|
||||||
}
|
|
||||||
|
|
||||||
// in contrast to PyTuple_GetItem, PySequence_GetItame returns a NEW reference
|
|
||||||
if (container[0])
|
|
||||||
{
|
|
||||||
Py_DECREF (container[0]);
|
|
||||||
}
|
|
||||||
if (container[1])
|
|
||||||
{
|
|
||||||
Py_DECREF (container[1]);
|
|
||||||
}
|
|
||||||
if (container[2])
|
|
||||||
{
|
|
||||||
Py_DECREF (container[2]);
|
|
||||||
}
|
|
||||||
if (container[3])
|
|
||||||
{
|
|
||||||
Py_DECREF (container[3]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// it only makes sense to support 2 and 3 dimensional data at this time
|
|
||||||
if (ndim < 2 || ndim > 3)
|
|
||||||
{
|
|
||||||
PyErr_SetString (PyExc_TypeError, "Nested sequences should have 2 or 3 dimensions");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// also, the number of channels should match what's typical for OpenCV
|
|
||||||
if (ndim == 3 && (dims[2] < 1 || dims[2] > 4))
|
|
||||||
{
|
|
||||||
PyErr_SetString (PyExc_TypeError, "Currently, the third dimension of CvMat only supports 1 to 4 channels");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// CvMat
|
|
||||||
CvMat * matrix = cvCreateMat (dims[0], dims[1], CV_MAKETYPE (CV_64F, dims[2]));
|
|
||||||
|
|
||||||
for (int y = 0; y < dims[0]; y++)
|
|
||||||
{
|
|
||||||
PyObject * rowobj = PySequence_GetItem (obj, y);
|
|
||||||
|
|
||||||
// double check size
|
|
||||||
if (PySequence_Check (rowobj) && PySequence_Size (rowobj) == dims[1])
|
|
||||||
{
|
|
||||||
for (int x = 0; x < dims[1]; x++)
|
|
||||||
{
|
|
||||||
PyObject * colobj = PySequence_GetItem (rowobj, x);
|
|
||||||
|
|
||||||
if (dims [2] > 1)
|
|
||||||
{
|
|
||||||
if (PySequence_Check (colobj) && PySequence_Size (colobj) == dims[2])
|
|
||||||
{
|
|
||||||
PyObject * tuple = PySequence_Tuple (colobj);
|
|
||||||
|
|
||||||
double a, b, c, d;
|
|
||||||
if (PyArg_ParseTuple (colobj, "d|d|d|d", &a, &b, &c, &d))
|
|
||||||
{
|
|
||||||
cvSet2D (matrix, y, x, cvScalar (a, b, c, d));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PyErr_SetString (PyExc_TypeError, "OpenCV only accepts numbers that can be converted to float");
|
|
||||||
cvReleaseMat (& matrix);
|
|
||||||
Py_DECREF (tuple);
|
|
||||||
Py_DECREF (colobj);
|
|
||||||
Py_DECREF (rowobj);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
Py_DECREF (tuple);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PyErr_SetString (PyExc_TypeError, "All sub-sequences must have the same number of entries");
|
|
||||||
cvReleaseMat (& matrix);
|
|
||||||
Py_DECREF (colobj);
|
|
||||||
Py_DECREF (rowobj);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (PyFloat_Check (colobj) || PyInt_Check (colobj))
|
|
||||||
{
|
|
||||||
cvmSet (matrix, y, x, PyFloat_AsDouble (colobj));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PyErr_SetString (PyExc_TypeError, "OpenCV only accepts numbers that can be converted to float");
|
|
||||||
cvReleaseMat (& matrix);
|
|
||||||
Py_DECREF (colobj);
|
|
||||||
Py_DECREF (rowobj);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Py_DECREF (colobj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PyErr_SetString (PyExc_TypeError, "All sub-sequences must have the same number of entries");
|
|
||||||
cvReleaseMat (& matrix);
|
|
||||||
Py_DECREF (rowobj);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
Py_DECREF (rowobj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return matrix;
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
#ifndef PYHELPERS_H
|
|
||||||
#define PYHELPERS_H
|
|
||||||
|
|
||||||
#include <Python.h>
|
|
||||||
#include <cxcore.h>
|
|
||||||
#include <cv.h>
|
|
||||||
|
|
||||||
/** convert python index object (tuple, integer, or slice) to CvRect for subsequent cvGetSubMat call */
|
|
||||||
CvRect PySlice_to_CvRect(CvArr * src, PyObject * idx_object);
|
|
||||||
|
|
||||||
/** 1 if rectangle is a subrectangle of [0,0,w,h], 0 otherwise */
|
|
||||||
int CheckSliceBounds(CvRect * rect, int w, int h );
|
|
||||||
|
|
||||||
/// convert object that supports the array protocol to CvMat *
|
|
||||||
CvArr * PyArray_to_CvArr (PyObject * obj);
|
|
||||||
|
|
||||||
/// convert nested sequences to CvMat *
|
|
||||||
CvArr * PySequence_to_CvArr (PyObject * obj);
|
|
||||||
|
|
||||||
/** prints array to stdout
|
|
||||||
* TODO: python __str__ and __repr__ return strings, so this should write to a string
|
|
||||||
*/
|
|
||||||
void cvArrPrint (CvArr * mat);
|
|
||||||
|
|
||||||
/** Convert an integer array to python tuple */
|
|
||||||
PyObject * PyTuple_FromIntArray(int * arr, int len);
|
|
||||||
|
|
||||||
/** If result is not NULL or PyNone, release object and replace it with obj */
|
|
||||||
PyObject * SWIG_SetResult(PyObject * result, PyObject * obj);
|
|
||||||
|
|
||||||
/** helper function to append one or more objects to the swig $result array */
|
|
||||||
PyObject * SWIG_AppendResult(PyObject * result, PyObject ** to_add, int num);
|
|
||||||
|
|
||||||
/** helper function to convert python scalar or sequence to int, float or double arrays */
|
|
||||||
double PyObject_AsDouble(PyObject * obj);
|
|
||||||
long PyObject_AsLong(PyObject * obj);
|
|
||||||
|
|
||||||
int PyObject_AsDoubleArray(PyObject * obj, double * array, int len);
|
|
||||||
int PyObject_AsLongArray( PyObject * obj, int * array, int len);
|
|
||||||
int PyObject_AsFloatArray(PyObject * obj, float * array, int len);
|
|
||||||
|
|
||||||
static inline int cvCvToIplDepth(int type) { return cvIplDepth(type); }
|
|
||||||
|
|
||||||
#endif //PYHELPERS_H
|
|
@ -1,239 +0,0 @@
|
|||||||
/* These functions need the SWIG_* functions defined in the wrapper */
|
|
||||||
%{
|
|
||||||
|
|
||||||
#include "pyhelpers.h"
|
|
||||||
|
|
||||||
static CvArr * PyObject_to_CvArr(PyObject * obj, bool * freearg);
|
|
||||||
|
|
||||||
// convert a python sequence/array/list object into a c-array
|
|
||||||
#define PyObject_AsArrayImpl(func, ctype, ptype) \
|
|
||||||
int func(PyObject * obj, ctype * array, int len){ \
|
|
||||||
void * mat_vptr=NULL; \
|
|
||||||
void * im_vptr=NULL; \
|
|
||||||
if(PyNumber_Check(obj)){ \
|
|
||||||
memset( array, 0, sizeof(ctype)*len ); \
|
|
||||||
array[0] = PyObject_As##ptype( obj ); \
|
|
||||||
} \
|
|
||||||
else if(PyList_Check(obj) || PyTuple_Check(obj)){ \
|
|
||||||
int seqsize = PySequence_Size(obj); \
|
|
||||||
for(int i=0; i<len && i<seqsize; i++){ \
|
|
||||||
if(i<seqsize){ \
|
|
||||||
array[i] = PyObject_As##ptype( PySequence_GetItem(obj, i) ); \
|
|
||||||
} \
|
|
||||||
else{ \
|
|
||||||
array[i] = 0; \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
else if( SWIG_ConvertPtr(obj, &mat_vptr, SWIGTYPE_p_CvMat, 0)!=-1 || \
|
|
||||||
SWIG_ConvertPtr(obj, &im_vptr, SWIGTYPE_p__IplImage, 0)!=-1) \
|
|
||||||
{ \
|
|
||||||
CvMat * mat = (CvMat *) mat_vptr; \
|
|
||||||
CvMat stub; \
|
|
||||||
if(im_vptr) mat = cvGetMat(im_vptr, &stub); \
|
|
||||||
if( mat->rows!=1 && mat->cols!=1 ){ \
|
|
||||||
PyErr_SetString( PyExc_TypeError, \
|
|
||||||
"PyObject_As*Array: CvArr must be row or column vector" ); \
|
|
||||||
return -1; \
|
|
||||||
} \
|
|
||||||
if( mat->rows==1 && mat->cols==1 ){ \
|
|
||||||
CvScalar val; \
|
|
||||||
if( len!=CV_MAT_CN(mat->type) ){ \
|
|
||||||
PyErr_SetString( PyExc_TypeError, \
|
|
||||||
"PyObject_As*Array: CvArr channels != length" ); \
|
|
||||||
return -1; \
|
|
||||||
} \
|
|
||||||
val = cvGet1D(mat, 0); \
|
|
||||||
for(int i=0; i<len; i++){ \
|
|
||||||
array[i] = (ctype) val.val[i]; \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
else{ \
|
|
||||||
mat = cvReshape(mat, &stub, -1, mat->rows*mat->cols); \
|
|
||||||
if( mat->rows != len ){ \
|
|
||||||
PyErr_SetString( PyExc_TypeError, \
|
|
||||||
"PyObject_As*Array: CvArr rows or cols must equal length" ); \
|
|
||||||
return -1; \
|
|
||||||
} \
|
|
||||||
for(int i=0; i<len; i++){ \
|
|
||||||
CvScalar val = cvGet1D(mat, i); \
|
|
||||||
array[i] = (ctype) val.val[0]; \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
else{ \
|
|
||||||
PyErr_SetString( PyExc_TypeError, \
|
|
||||||
"PyObject_As*Array: Expected a number, sequence or CvArr" ); \
|
|
||||||
return -1; \
|
|
||||||
} \
|
|
||||||
return 0; \
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject_AsArrayImpl( PyObject_AsFloatArray, float, Double );
|
|
||||||
PyObject_AsArrayImpl( PyObject_AsDoubleArray, double, Double );
|
|
||||||
PyObject_AsArrayImpl( PyObject_AsLongArray, int, Long );
|
|
||||||
|
|
||||||
static CvPoint PyObject_to_CvPoint(PyObject * obj){
|
|
||||||
CvPoint val;
|
|
||||||
CvPoint *ptr;
|
|
||||||
CvPoint2D32f * ptr2D32f;
|
|
||||||
CvScalar * scalar;
|
|
||||||
|
|
||||||
if( SWIG_ConvertPtr(obj, (void**)&ptr, SWIGTYPE_p_CvPoint, 0) != -1) {
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
if( SWIG_ConvertPtr(obj, (void**)&ptr2D32f, SWIGTYPE_p_CvPoint2D32f, 0) != -1) {
|
|
||||||
return cvPointFrom32f( *ptr2D32f );
|
|
||||||
}
|
|
||||||
if( SWIG_ConvertPtr(obj, (void**)&scalar, SWIGTYPE_p_CvScalar, 0) != -1) {
|
|
||||||
return cvPointFrom32f(cvPoint2D32f( scalar->val[0], scalar->val[1] ));
|
|
||||||
}
|
|
||||||
if(PyObject_AsLongArray(obj, (int *) &val, 2) != -1){
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyErr_SetString( PyExc_TypeError, "could not convert to CvPoint");
|
|
||||||
return cvPoint(0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static CvPoint2D32f PyObject_to_CvPoint2D32f(PyObject * obj){
|
|
||||||
CvPoint2D32f val;
|
|
||||||
CvPoint2D32f *ptr2D32f;
|
|
||||||
CvPoint *ptr;
|
|
||||||
CvScalar * scalar;
|
|
||||||
if( SWIG_ConvertPtr(obj, (void**)&ptr2D32f, SWIGTYPE_p_CvPoint2D32f, 0) != -1) {
|
|
||||||
return *ptr2D32f;
|
|
||||||
}
|
|
||||||
if( SWIG_ConvertPtr(obj, (void**)&ptr, SWIGTYPE_p_CvPoint, 0) != -1) {
|
|
||||||
return cvPointTo32f(*ptr);
|
|
||||||
}
|
|
||||||
if( SWIG_ConvertPtr(obj, (void**)&scalar, SWIGTYPE_p_CvScalar, 0) != -1) {
|
|
||||||
return cvPoint2D32f( scalar->val[0], scalar->val[1] );
|
|
||||||
}
|
|
||||||
if(PyObject_AsFloatArray(obj, (float *) &val, 2) != -1){
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
PyErr_SetString(PyExc_TypeError, "could not convert to CvPoint2D32f");
|
|
||||||
return cvPoint2D32f(0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if this object can be interpreted as a CvScalar */
|
|
||||||
static bool CvScalar_Check(PyObject * obj){
|
|
||||||
void * vptr;
|
|
||||||
CvScalar val;
|
|
||||||
return SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvScalar, 0 ) != -1 ||
|
|
||||||
SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvPoint2D32f, 0 ) != -1 ||
|
|
||||||
SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvPoint, 0 ) != -1 ||
|
|
||||||
PyObject_AsDoubleArray(obj, val.val, 4) !=-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static CvScalar PyObject_to_CvScalar(PyObject * obj){
|
|
||||||
CvScalar val;
|
|
||||||
CvScalar * ptr;
|
|
||||||
CvPoint2D32f *ptr2D32f;
|
|
||||||
CvPoint *pt_ptr;
|
|
||||||
void * vptr;
|
|
||||||
if( SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvScalar, 0 ) != -1)
|
|
||||||
{
|
|
||||||
ptr = (CvScalar *) vptr;
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
if( SWIG_ConvertPtr(obj, (void**)&ptr2D32f, SWIGTYPE_p_CvPoint2D32f, 0) != -1) {
|
|
||||||
return cvScalar(ptr2D32f->x, ptr2D32f->y);
|
|
||||||
}
|
|
||||||
if( SWIG_ConvertPtr(obj, (void**)&pt_ptr, SWIGTYPE_p_CvPoint, 0) != -1) {
|
|
||||||
return cvScalar(pt_ptr->x, pt_ptr->y);
|
|
||||||
}
|
|
||||||
if(PyObject_AsDoubleArray(obj, val.val, 4)!=-1){
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
return cvScalar(-1,-1,-1,-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int CvArr_Check( PyObject * obj )
|
|
||||||
{
|
|
||||||
void *ptr;
|
|
||||||
if( obj == Py_None ||
|
|
||||||
SWIG_IsOK( SWIG_ConvertPtr(obj, &ptr, SWIGTYPE_p_void, 0) ) ||
|
|
||||||
SWIG_IsOK( SWIG_ConvertPtr(obj, &ptr, SWIGTYPE_p_CvMat, 0) ) ||
|
|
||||||
SWIG_IsOK( SWIG_ConvertPtr(obj, &ptr, SWIGTYPE_p_CvSeq, 0) ) ||
|
|
||||||
SWIG_IsOK( SWIG_ConvertPtr(obj, &ptr, SWIGTYPE_p_CvContour, 0) ) ||
|
|
||||||
SWIG_IsOK( SWIG_ConvertPtr(obj, &ptr, SWIGTYPE_p_CvSparseMat, 0) ) ||
|
|
||||||
SWIG_IsOK( SWIG_ConvertPtr(obj, &ptr, SWIGTYPE_p_CvMatND, 0) ) ||
|
|
||||||
PyObject_HasAttrString(obj, "__array_interface__") ||
|
|
||||||
PySequence_Check(obj) )
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
PyErr_Clear();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if python sequence type, convert to CvMat or CvMatND */
|
|
||||||
static CvArr * PyObject_to_CvArr (PyObject * obj, bool * freearg)
|
|
||||||
{
|
|
||||||
CvArr * cvarr = NULL;
|
|
||||||
*freearg = false;
|
|
||||||
|
|
||||||
if ( obj == Py_None )
|
|
||||||
{
|
|
||||||
// Interpret None as NULL pointer
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else if( SWIG_IsOK( SWIG_ConvertPtr(obj, (void **)& cvarr, SWIGTYPE_p_void, 0) ) ||
|
|
||||||
SWIG_IsOK( SWIG_ConvertPtr (obj, (void** )& cvarr, SWIGTYPE_p_CvMat, 0) ) ||
|
|
||||||
SWIG_IsOK( SWIG_ConvertPtr (obj, (void **)& cvarr, SWIGTYPE_p_CvSeq, 0) ) ||
|
|
||||||
SWIG_IsOK( SWIG_ConvertPtr (obj, (void **)& cvarr, SWIGTYPE_p_CvContour, 0) ) ||
|
|
||||||
SWIG_IsOK( SWIG_ConvertPtr (obj, (void **)& cvarr, SWIGTYPE_p_CvSparseMat, 0) ) ||
|
|
||||||
SWIG_IsOK( SWIG_ConvertPtr (obj, (void **)& cvarr, SWIGTYPE_p_CvMatND, 0) ))
|
|
||||||
{
|
|
||||||
// we got a directly wrapped void * pointer, OpenCV array or sequence type
|
|
||||||
return cvarr;
|
|
||||||
}
|
|
||||||
else if (PyObject_HasAttrString (obj, "__array_interface__"))
|
|
||||||
{
|
|
||||||
// if we didn't get our own datatype, let's see if it supports the array protocol
|
|
||||||
// array protocol is great because we just have to create another header but can
|
|
||||||
// use the original data without copying
|
|
||||||
cvarr = PyArray_to_CvArr (obj);
|
|
||||||
*freearg = (cvarr != NULL);
|
|
||||||
}
|
|
||||||
else if (PySequence_Check (obj))
|
|
||||||
{
|
|
||||||
// our next bet is a tuple or list of tuples or lists this has to be copied over, however
|
|
||||||
cvarr = PySequence_to_CvArr (obj);
|
|
||||||
*freearg = (cvarr != NULL);
|
|
||||||
}
|
|
||||||
else if (PyLong_Check (obj) && PyLong_AsLong (obj) == 0)
|
|
||||||
{
|
|
||||||
// Interpret a '0' integer as a NULL pointer
|
|
||||||
* freearg = false;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO, throw an error here
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cvarr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int PyObject_GetElemType(PyObject * obj){
|
|
||||||
void *vptr;
|
|
||||||
if(SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvPoint, 0) != -1) return CV_32SC2;
|
|
||||||
if(SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvSize, 0) != -1) return CV_32SC2;
|
|
||||||
if(SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvRect, 0) != -1) return CV_32SC4;
|
|
||||||
if(SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvSize2D32f, 0) != -1) return CV_32FC2;
|
|
||||||
if(SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvPoint2D32f, 0) != -1) return CV_32FC2;
|
|
||||||
if(SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvPoint3D32f, 0) != -1) return CV_32FC3;
|
|
||||||
if(SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvPoint2D64f, 0) != -1) return CV_64FC2;
|
|
||||||
if(SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvPoint3D64f, 0) != -1) return CV_64FC3;
|
|
||||||
if(SWIG_ConvertPtr(obj, &vptr, SWIGTYPE_p_CvScalar, 0) != -1) return CV_64FC4;
|
|
||||||
if(PyTuple_Check(obj) || PyList_Check(obj)) return CV_MAKE_TYPE(CV_32F, PySequence_Size( obj ));
|
|
||||||
if(PyLong_Check(obj)) return CV_32S;
|
|
||||||
return CV_32F;
|
|
||||||
}
|
|
||||||
|
|
||||||
%}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,120 +0,0 @@
|
|||||||
from distutils.core import setup, Extension
import os
|
|
||||||
opencv_pwrap_dir = r'.'
|
|
||||||
opencv_base_dir = r'../../..'
|
|
||||||
|
|
||||||
def patch_for_win32(filename,outfile,patches,extra_defs):
|
|
||||||
print 'patching '+filename+'...'
|
|
||||||
src = open(filename,'rt')
|
|
||||||
dst = open(outfile, 'wt')
|
|
||||||
for l in src.xreadlines():
|
|
||||||
dl = l
|
|
||||||
for (from_str,to_str) in patches:
|
|
||||||
dl = dl.replace(from_str,to_str)
|
|
||||||
for i in extra_defs:
|
|
||||||
if l.find(i[0]) >= 0:
|
|
||||||
dst.write(i[1])
|
|
||||||
extra_defs.remove(i)
|
|
||||||
dst.write(dl)
|
|
||||||
src.close()
|
|
||||||
dst.close()
|
|
||||||
|
|
||||||
def is_older(a,b):
|
|
||||||
return os.path.getmtime(a)<os.path.getmtime(b)
|
|
||||||
|
|
||||||
if not os.path.exists('_cv_win32.cpp') or is_older('_cv_win32.cpp','_cv.cpp'):
|
|
||||||
patch_for_win32('_cv.cpp', '_cv_win32.cpp',
|
|
||||||
[('unsigned long long','uint64',),('long long','int64'),
|
|
||||||
("char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);",
|
|
||||||
"char *doc = (char*)(((PyCFunctionObject *)obj) -> m_ml -> ml_doc);"),
|
|
||||||
("char *c = methods[i].ml_doc;",
|
|
||||||
"char *c = (char*)methods[i].ml_doc;")],
|
|
||||||
[('PyAPI_FUNC','#undef PyAPI_FUNC\n'), ('cv.h',
|
|
||||||
"""
|
|
||||||
#include "cv.h"
|
|
||||||
|
|
||||||
const signed char icvDepthToType[]=
|
|
||||||
{
|
|
||||||
-1, -1, CV_8U, CV_8S, CV_16U, CV_16S, -1, -1,
|
|
||||||
CV_32F, CV_32S, -1, -1, -1, -1, -1, -1, CV_64F, -1
|
|
||||||
};
|
|
||||||
|
|
||||||
CvModuleInfo* CvModule::first = 0;
|
|
||||||
CvModuleInfo* CvModule::last = 0;
|
|
||||||
CvTypeInfo* CvType::first = 0;
|
|
||||||
CvTypeInfo* CvType::last = 0;
|
|
||||||
|
|
||||||
""")])
|
|
||||||
|
|
||||||
if not os.path.exists('_highgui_win32.cpp') or is_older('_highgui_win32.cpp','_highgui.cpp'):
|
|
||||||
patch_for_win32('_highgui.cpp', '_highgui_win32.cpp',
|
|
||||||
[('unsigned long long','uint64',),('long long','int64'),
|
|
||||||
("char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);",
|
|
||||||
"char *doc = (char*)(((PyCFunctionObject *)obj) -> m_ml -> ml_doc);"),
|
|
||||||
("char *c = methods[i].ml_doc;",
|
|
||||||
"char *c = (char*)methods[i].ml_doc;")],
|
|
||||||
[('PyAPI_FUNC','#undef PyAPI_FUNC\n')])
|
|
||||||
|
|
||||||
if not os.path.exists('_ml_win32.cpp') or is_older('_ml_win32.cpp','_ml.cpp'):
|
|
||||||
patch_for_win32('_ml.cpp', '_ml_win32.cpp',
|
|
||||||
[('unsigned long long','uint64',),('long long','int64'),
|
|
||||||
("char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);",
|
|
||||||
"char *doc = (char*)(((PyCFunctionObject *)obj) -> m_ml -> ml_doc);"),
|
|
||||||
("char *c = methods[i].ml_doc;",
|
|
||||||
"char *c = (char*)methods[i].ml_doc;")],
|
|
||||||
[('PyAPI_FUNC','#undef PyAPI_FUNC\n')])
|
|
||||||
|
|
||||||
|
|
||||||
setup(name='OpenCV Python Wrapper',
|
|
||||||
version='0.0',
|
|
||||||
packages = ['opencv'],
|
|
||||||
package_dir = {'opencv': opencv_pwrap_dir},
|
|
||||||
ext_modules=[Extension('opencv._cv',
|
|
||||||
[os.path.join (opencv_pwrap_dir, '_cv_win32.cpp'),
|
|
||||||
os.path.join (opencv_pwrap_dir, 'error.cpp'),
|
|
||||||
os.path.join (opencv_pwrap_dir, 'cvshadow.cpp'),
|
|
||||||
os.path.join (opencv_pwrap_dir, 'pyhelpers.cpp')],
|
|
||||||
include_dirs = [os.path.join (opencv_base_dir,
|
|
||||||
'cv', 'include'),
|
|
||||||
os.path.join (opencv_base_dir,
|
|
||||||
'cxcore', 'include'),
|
|
||||||
],
|
|
||||||
library_dirs = [os.path.join (opencv_base_dir,
|
|
||||||
'lib')],
|
|
||||||
libraries = ['cv', 'cxcore'],
|
|
||||||
),
|
|
||||||
|
|
||||||
Extension('opencv._ml',
|
|
||||||
[os.path.join (opencv_pwrap_dir, '_ml_win32.cpp'),
|
|
||||||
os.path.join (opencv_pwrap_dir, 'error.cpp'),
|
|
||||||
os.path.join (opencv_pwrap_dir, 'cvshadow.cpp'),
|
|
||||||
os.path.join (opencv_pwrap_dir, 'pyhelpers.cpp')],
|
|
||||||
include_dirs = [os.path.join (opencv_base_dir,
|
|
||||||
'cv', 'include'),
|
|
||||||
os.path.join (opencv_base_dir,
|
|
||||||
'cxcore', 'include'),
|
|
||||||
os.path.join (opencv_base_dir,
|
|
||||||
'ml', 'include'),
|
|
||||||
os.path.join (opencv_base_dir,
|
|
||||||
'otherlibs', 'highgui'),
|
|
||||||
],
|
|
||||||
library_dirs = [os.path.join (opencv_base_dir,
|
|
||||||
'lib')],
|
|
||||||
libraries = ['cv', 'cxcore', 'ml'],
|
|
||||||
),
|
|
||||||
|
|
||||||
Extension('opencv._highgui',
[os.path.join (opencv_pwrap_dir, '_highgui_win32.cpp'),
|
|
||||||
os.path.join (opencv_pwrap_dir, 'error.cpp'),
|
|
||||||
os.path.join (opencv_pwrap_dir, 'cvshadow.cpp'),
|
|
||||||
os.path.join (opencv_pwrap_dir, 'pyhelpers.cpp')],
|
|
||||||
include_dirs = [os.path.join (opencv_base_dir,
|
|
||||||
'otherlibs', 'highgui'),
|
|
||||||
os.path.join (opencv_base_dir,
|
|
||||||
'cxcore', 'include'),
|
|
||||||
os.path.join (opencv_base_dir,
|
|
||||||
'cv', 'include')],
|
|
||||||
library_dirs = [os.path.join (opencv_base_dir,
|
|
||||||
'lib')],
|
|
||||||
libraries = ['highgui', 'cv', 'cxcore'],
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
Loading…
x
Reference in New Issue
Block a user