diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index b40c65710..0f9c530db 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -354,7 +354,7 @@ static inline bool pyopencv_to(PyObject* obj, Size& sz, const char* name = " 0; + return PyArg_ParseTuple(obj, "ii", &sz.width, &sz.height) > 0; } static inline PyObject* pyopencv_from(const Size& sz) @@ -366,7 +366,7 @@ static inline bool pyopencv_to(PyObject* obj, Rect& r, const char* name = " 0; + return PyArg_ParseTuple(obj, "iiii", &r.x, &r.y, &r.width, &r.height) > 0; } static inline PyObject* pyopencv_from(const Rect& r) @@ -383,7 +383,7 @@ static inline bool pyopencv_to(PyObject* obj, Range& r, const char* name = " 0; + return PyArg_ParseTuple(obj, "ii", &r.start, &r.end) > 0; } static inline PyObject* pyopencv_from(const Range& r) @@ -400,7 +400,7 @@ static inline bool pyopencv_to(PyObject* obj, CvSlice& r, const char* name = " 0; + return PyArg_ParseTuple(obj, "ii", &r.start_index, &r.end_index) > 0; } static inline PyObject* pyopencv_from(const CvSlice& r) @@ -419,7 +419,7 @@ static inline bool pyopencv_to(PyObject* obj, Point& p, const char* name = "(c.imag); return true; } - return PyArg_Parse(obj, "ii", &p.x, &p.y) > 0; + return PyArg_ParseTuple(obj, "ii", &p.x, &p.y) > 0; } static inline bool pyopencv_to(PyObject* obj, Point2f& p, const char* name = "") @@ -433,7 +433,7 @@ static inline bool pyopencv_to(PyObject* obj, Point2f& p, const char* name = "(c.imag); return true; } - return PyArg_Parse(obj, "ff", &p.x, &p.y) > 0; + return PyArg_ParseTuple(obj, "ff", &p.x, &p.y) > 0; } static inline PyObject* pyopencv_from(const Point& p) @@ -450,7 +450,7 @@ static inline bool pyopencv_to(PyObject* obj, Vec3d& v, const char* name = " 0; + return PyArg_ParseTuple(obj, "ddd", &v[0], &v[1], &v[2]) > 0; } static inline PyObject* pyopencv_from(const Vec3d& v) diff --git a/modules/python/src2/gen2.py b/modules/python/src2/gen2.py index e7d3f4b07..5e2e0b1d5 100644 --- a/modules/python/src2/gen2.py +++ b/modules/python/src2/gen2.py @@ -571,7 +571,7 @@ class FuncInfo(object): parse_arglist = ", ".join(["&" + all_cargs[argno][1] for aname, argno in v.py_arglist]), code_cvt = " &&\n ".join(code_cvt_list)) else: - code_parse = "if(PyObject_Size(args) == 0 && PyObject_Size(kw) == 0)" + code_parse = "if(PyObject_Size(args) == 0 && (kw == NULL || PyObject_Size(kw) == 0))" if len(v.py_outlist) == 0: code_ret = "Py_RETURN_NONE"