mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
python: reduce code size of cv2.cpp
This commit is contained in:
parent
9d14c0b37a
commit
5d96f984b1
@ -134,6 +134,17 @@ private:
|
|||||||
PyGILState_STATE _state;
|
PyGILState_STATE _state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void pyRaiseCVException(const cv::Exception &e)
|
||||||
|
{
|
||||||
|
PyObject_SetAttrString(opencv_error, "file", PyString_FromString(e.file.c_str()));
|
||||||
|
PyObject_SetAttrString(opencv_error, "func", PyString_FromString(e.func.c_str()));
|
||||||
|
PyObject_SetAttrString(opencv_error, "line", PyInt_FromLong(e.line));
|
||||||
|
PyObject_SetAttrString(opencv_error, "code", PyInt_FromLong(e.code));
|
||||||
|
PyObject_SetAttrString(opencv_error, "msg", PyString_FromString(e.msg.c_str()));
|
||||||
|
PyObject_SetAttrString(opencv_error, "err", PyString_FromString(e.err.c_str()));
|
||||||
|
PyErr_SetString(opencv_error, e.what());
|
||||||
|
}
|
||||||
|
|
||||||
#define ERRWRAP2(expr) \
|
#define ERRWRAP2(expr) \
|
||||||
try \
|
try \
|
||||||
{ \
|
{ \
|
||||||
@ -142,13 +153,7 @@ try \
|
|||||||
} \
|
} \
|
||||||
catch (const cv::Exception &e) \
|
catch (const cv::Exception &e) \
|
||||||
{ \
|
{ \
|
||||||
PyObject_SetAttrString(opencv_error, "file", PyString_FromString(e.file.c_str())); \
|
pyRaiseCVException(e); \
|
||||||
PyObject_SetAttrString(opencv_error, "func", PyString_FromString(e.func.c_str())); \
|
|
||||||
PyObject_SetAttrString(opencv_error, "line", PyInt_FromLong(e.line)); \
|
|
||||||
PyObject_SetAttrString(opencv_error, "code", PyInt_FromLong(e.code)); \
|
|
||||||
PyObject_SetAttrString(opencv_error, "msg", PyString_FromString(e.msg.c_str())); \
|
|
||||||
PyObject_SetAttrString(opencv_error, "err", PyString_FromString(e.err.c_str())); \
|
|
||||||
PyErr_SetString(opencv_error, e.what()); \
|
|
||||||
return 0; \
|
return 0; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user