From 930611dfa8776e0009242e07810a0224c6c0324e Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Wed, 26 Apr 2017 14:22:14 +0200 Subject: [PATCH] python: move Ptr specializations above generic_vec to allow vector_Ptr_T --- modules/python/src2/cv2.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index 1eb4533812..a64ff50a43 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -394,6 +394,15 @@ bool pyopencv_to(PyObject* o, Mat& m, const char* name) return pyopencv_to(o, m, ArgInfo(name, 0)); } +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); +} + template<> PyObject* pyopencv_from(const Mat& m) { @@ -417,6 +426,14 @@ PyObject* pyopencv_from(const Matx<_Tp, m, n>& matx) return pyopencv_from(Mat(matx)); } +template +PyObject* pyopencv_from(const cv::Ptr& p) +{ + if (!p) + Py_RETURN_NONE; + return pyopencv_from(*p); +} + typedef struct { PyObject_HEAD UMat* um; @@ -1329,23 +1346,6 @@ 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) - Py_RETURN_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); -} - #include "pyopencv_custom_headers.h" static void OnMouse(int event, int x, int y, int flags, void* param)