Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
f1ca05c8
Commit
f1ca05c8
authored
6 years ago
by
Hamdi Sahloul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend python exception `cv.error`
to provide `file`, `func`, `line`, `code`, `msg`, and `err` attributes
parent
900df21b
master
4.3.0
4.2.0
4.1.2
4.1.2-openvino
4.1.1
4.1.1-openvino
4.1.0
4.1.0-openvino
4.0.1
4.0.1-openvino
4.0.0
4.0.0-rc
4.0.0-openvino
4.0.0-beta
4.0.0-alpha
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
cv2.cpp
modules/python/src2/cv2.cpp
+16
-2
No files found.
modules/python/src2/cv2.cpp
View file @
f1ca05c8
...
...
@@ -110,7 +110,7 @@ PyObject* pyopencv_from(const TYPE& src)
#include <map>
static
PyObject
*
opencv_error
=
0
;
static
PyObject
*
opencv_error
=
NULL
;
static
int
failmsg
(
const
char
*
fmt
,
...)
{
...
...
@@ -171,6 +171,12 @@ try \
} \
catch (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()); \
return 0; \
}
...
...
@@ -2030,7 +2036,15 @@ void initcv2()
PyDict_SetItemString
(
d
,
"__version__"
,
PyString_FromString
(
CV_VERSION
));
opencv_error
=
PyErr_NewException
((
char
*
)
MODULESTR
".error"
,
NULL
,
NULL
);
PyObject
*
opencv_error_dict
=
PyDict_New
();
PyDict_SetItemString
(
opencv_error_dict
,
"file"
,
Py_None
);
PyDict_SetItemString
(
opencv_error_dict
,
"func"
,
Py_None
);
PyDict_SetItemString
(
opencv_error_dict
,
"line"
,
Py_None
);
PyDict_SetItemString
(
opencv_error_dict
,
"code"
,
Py_None
);
PyDict_SetItemString
(
opencv_error_dict
,
"msg"
,
Py_None
);
PyDict_SetItemString
(
opencv_error_dict
,
"err"
,
Py_None
);
opencv_error
=
PyErr_NewException
((
char
*
)
MODULESTR
".error"
,
NULL
,
opencv_error_dict
);
Py_DECREF
(
opencv_error_dict
);
PyDict_SetItemString
(
d
,
"error"
,
opencv_error
);
//Registering UMatWrapper python class in cv2 module:
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment