Commit 8be541ee authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

removed obsolete swig-based python & octave wrappers

parent 1c347f48
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()
if(PYTHONLIBS_FOUND AND BUILD_SWIG_PYTHON_SUPPORT)
add_subdirectory(python)
endif()
if(OCTAVE_FOUND AND BUILD_OCTAVE_SUPPORT)
add_subdirectory(octave)
endif()
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.
This diff is collapsed.
This diff is collapsed.
/*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"
This diff is collapsed.
/*//////////////////////////////////////////////////////////////////////////////////////////////////
// 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);
/*//////////////////////////////////////////////////////////////////////////////////////////////////
// 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;
}
/*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;
};
/*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); } }
/*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;
/* wrappers to be able to use cv.sizeof_XXX instead of size () */
%include "cmalloc.i"
%sizeof (CvContour)
%sizeof (CvPoint)
%sizeof (CvSeq)
/*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
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.
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
see the online documentation
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;
This diff is collapsed.
/*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());
%}
This diff is collapsed.
/*
%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
%}
*/
This diff is collapsed.
/*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]
%}
*/
}
#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;
}
#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
/*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);
*/
/*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"
This diff is collapsed.
/*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;
};
/*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"
This diff is collapsed.
/*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
/*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;
}
/*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();
This diff is collapsed.
#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
This diff is collapsed.
This diff is collapsed.
build
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment