diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index 9c28c7070f125c8145c8822a285a13f9491af292..4788ef1b5eaa1f2c66161ba702a614027ae0dc29 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -1271,9 +1271,17 @@ PyObject* pyopencv_from(const Moments& m) "nu30", m.nu30, "nu21", m.nu21, "nu12", m.nu12, "nu03", m.nu03); } +template +PyObject* pyopencv_from(const cv::Ptr& p) +{ + if (!p) return Py_None; + return pyopencv_from(*p); +} + template bool pyopencv_to(PyObject *o, Ptr& p, const char *name) { + if (!o || o == Py_None) return true; p = makePtr(); return pyopencv_to(o, *p, name); }