1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-25 13:23:02 +04:00

fix: preserve NumPY writeable flag in output arguments

This commit is contained in:
Vadim Levin
2023-07-19 17:22:10 +03:00
parent 0519e05432
commit 4c568e6ed3
2 changed files with 13 additions and 0 deletions
+7
View File
@@ -101,6 +101,13 @@ bool pyopencv_to(PyObject* o, Mat& m, const ArgInfo& info)
PyArrayObject* oarr = (PyArrayObject*) o;
if (info.outputarg && !PyArray_ISWRITEABLE(oarr))
{
failmsg("%s marked as output argument, but provided NumPy array "
"marked as readonly", info.name);
return false;
}
bool needcopy = false, needcast = false;
int typenum = PyArray_TYPE(oarr), new_typenum = typenum;
int type = typenum == NPY_UBYTE ? CV_8U :