Skip to content

Commit 930611d

Browse files
committed
python: move Ptr specializations above generic_vec to allow vector_Ptr_T
1 parent 41d55c5 commit 930611d

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

modules/python/src2/cv2.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,15 @@ bool pyopencv_to(PyObject* o, Mat& m, const char* name)
394394
return pyopencv_to(o, m, ArgInfo(name, 0));
395395
}
396396

397+
template <typename T>
398+
bool pyopencv_to(PyObject *o, Ptr<T>& p, const char *name)
399+
{
400+
if (!o || o == Py_None)
401+
return true;
402+
p = makePtr<T>();
403+
return pyopencv_to(o, *p, name);
404+
}
405+
397406
template<>
398407
PyObject* pyopencv_from(const Mat& m)
399408
{
@@ -417,6 +426,14 @@ PyObject* pyopencv_from(const Matx<_Tp, m, n>& matx)
417426
return pyopencv_from(Mat(matx));
418427
}
419428

429+
template<typename T>
430+
PyObject* pyopencv_from(const cv::Ptr<T>& p)
431+
{
432+
if (!p)
433+
Py_RETURN_NONE;
434+
return pyopencv_from(*p);
435+
}
436+
420437
typedef struct {
421438
PyObject_HEAD
422439
UMat* um;
@@ -1329,23 +1346,6 @@ PyObject* pyopencv_from(const Moments& m)
13291346
"nu30", m.nu30, "nu21", m.nu21, "nu12", m.nu12, "nu03", m.nu03);
13301347
}
13311348

1332-
template<typename T>
1333-
PyObject* pyopencv_from(const cv::Ptr<T>& p)
1334-
{
1335-
if (!p)
1336-
Py_RETURN_NONE;
1337-
return pyopencv_from(*p);
1338-
}
1339-
1340-
template <typename T>
1341-
bool pyopencv_to(PyObject *o, Ptr<T>& p, const char *name)
1342-
{
1343-
if (!o || o == Py_None)
1344-
return true;
1345-
p = makePtr<T>();
1346-
return pyopencv_to(o, *p, name);
1347-
}
1348-
13491349
#include "pyopencv_custom_headers.h"
13501350

13511351
static void OnMouse(int event, int x, int y, int flags, void* param)

0 commit comments

Comments
 (0)