|
|
|
@ -37,9 +37,22 @@ static int failmsg(const char *fmt, ...) |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class PyAllowThreads |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
PyAllowThreads() : _state(PyEval_SaveThread()) {} |
|
|
|
|
~PyAllowThreads()
|
|
|
|
|
{ |
|
|
|
|
PyEval_RestoreThread(_state); |
|
|
|
|
} |
|
|
|
|
private: |
|
|
|
|
PyThreadState* _state; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
#define ERRWRAP2(expr) \ |
|
|
|
|
try \
|
|
|
|
|
{ \
|
|
|
|
|
PyAllowThreads allowThreads; \
|
|
|
|
|
expr; \
|
|
|
|
|
} \
|
|
|
|
|
catch (const cv::Exception &e) \
|
|
|
|
@ -105,22 +118,6 @@ static inline int* refcountFromPyObject(const PyObject* obj) |
|
|
|
|
return (int*)((size_t)obj + REFCOUNT_OFFSET); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class PyAllowThreads |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
PyAllowThreads() : _state(PyEval_SaveThread())
|
|
|
|
|
{ |
|
|
|
|
//printf("+GIL\n");
|
|
|
|
|
} |
|
|
|
|
~PyAllowThreads() |
|
|
|
|
{ |
|
|
|
|
PyEval_RestoreThread(_state); |
|
|
|
|
//printf("-GIL\n");
|
|
|
|
|
} |
|
|
|
|
private: |
|
|
|
|
PyThreadState* _state; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class NumpyAllocator : public MatAllocator |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|