Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ndarray_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ template <> struct type_caster<cv::Mat> {
PYBIND11_TYPE_CASTER(cv::Mat, _("numpy.ndarray"));

bool load(handle src, bool /* convert */) {
return NDArrayConverter::toMat(src.ptr(), value);
const bool converted = NDArrayConverter::toMat(src.ptr(), value);
if (!converted) {
// A failed type-caster load asks pybind11 to try the next overload.
// Do not leak the converter's diagnostic exception into a later
// overload that accepts the argument successfully.
PyErr_Clear();
}
return converted;
}

static handle cast(const cv::Mat &m, return_value_policy, handle defval) {
Expand Down