Skip to content

Commit c75b589

Browse files
committed
Wraps smart pointers properly
1 parent e4377e7 commit c75b589

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

modules/python/src2/cv2.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,9 +1271,17 @@ PyObject* pyopencv_from(const Moments& m)
12711271
"nu30", m.nu30, "nu21", m.nu21, "nu12", m.nu12, "nu03", m.nu03);
12721272
}
12731273

1274+
template<typename T>
1275+
PyObject* pyopencv_from(const cv::Ptr<T>& p)
1276+
{
1277+
if (!p) return Py_None;
1278+
return pyopencv_from(*p);
1279+
}
1280+
12741281
template <typename T>
12751282
bool pyopencv_to(PyObject *o, Ptr<T>& p, const char *name)
12761283
{
1284+
if (!o || o == Py_None) return true;
12771285
p = makePtr<T>();
12781286
return pyopencv_to(o, *p, name);
12791287
}

0 commit comments

Comments
 (0)