Move the sources to trunk
[opencv] / interfaces / swig / python / pyhelpers.h
1 #ifndef PYHELPERS_H
2 #define PYHELPERS_H
3
4 #include <Python.h>
5 #include <cxcore.h>
6 #include <cv.h>
7
8 /** convert python index object (tuple, integer, or slice) to CvRect for subsequent cvGetSubMat call */
9 CvRect PySlice_to_CvRect(CvArr * src, PyObject * idx_object);
10
11 /** prints array to stdout 
12  *  TODO: python __str__ and __repr__ return strings, so this should write to a string 
13  */
14 void cvArrPrint( CvArr * mat );
15
16 /** Convert an integer array to python tuple */
17 PyObject * PyTuple_FromIntArray(int * arr, int len);
18         
19 /** If result is not NULL or PyNone, release object and replace it with obj */
20 PyObject * SWIG_SetResult(PyObject * result, PyObject * obj);
21         
22 /** helper function to append one or more objects to the swig $result array */
23 PyObject * SWIG_AppendResult(PyObject * result, PyObject ** to_add, int num);
24
25 /** helper function to convert python scalar or sequence to int, float or double arrays */
26 double PyObject_AsDouble(PyObject * obj);
27 long PyObject_AsLong(PyObject * obj);
28
29 int PyObject_AsDoubleArray(PyObject * obj, double * array, int len);
30 int PyObject_AsLongArray(  PyObject * obj, int * array, int len);
31 int PyObject_AsFloatArray(PyObject * obj, float * array, int len);
32
33 #endif //PYHELPERS_H