49#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
51#include <numpy/ndarrayobject.h>
52#include <opencv2/core/core.hpp>
53#include <boost/python.hpp>
60 extern PyObject * opencv_error;
64#define ERRWRAP2(expr) \
67 PyAllowThreads allowThreads; \
70 catch (const cv::Exception &e) \
72 PyErr_SetString(opencv_error, e.what()); \
80 static size_t REFCOUNT_OFFSET = (size_t)&(((PyObject*)0)->ob_refcnt) +
81 (0x12345678 != *(
const size_t*)
"\x78\x56\x34\x12\0\0\0\0\0")*
sizeof(
int);
83 static inline PyObject* pyObjectFromRefcount(
const int* refcount)
85 return (PyObject*)((size_t)refcount - REFCOUNT_OFFSET);
88 static inline int* refcountFromPyObject(
const PyObject* obj)
90 return (
int*)((size_t)obj + REFCOUNT_OFFSET);
97 PyObject* fromMatToNDArray(
const Mat& m);
98 Mat fromNDArrayToMat(PyObject*
o);
101 struct matToNDArrayBoostConverter
103 static PyObject* convert(Mat
const& m);
107 struct matFromNDArrayBoostConverter
109 matFromNDArrayBoostConverter();
112 static void* convertible(PyObject*
object);
115 static void construct(PyObject*
object,
116 boost::python::converter::rvalue_from_python_stage1_data* data);