From ca599eee40149e8a0b955a9856460738967d6df1 Mon Sep 17 00:00:00 2001 From: Wangyida Date: Sun, 11 Oct 2015 12:12:42 +0800 Subject: [PATCH] python modification for Point3D --- modules/python/src2/cv2.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index cbe2852228..2a8ecfddc3 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -91,6 +91,7 @@ typedef std::vector vector_float; typedef std::vector vector_double; typedef std::vector vector_Point; typedef std::vector vector_Point2f; +typedef std::vector vector_Point3f; typedef std::vector vector_Vec2f; typedef std::vector vector_Vec3f; typedef std::vector vector_Vec4f; @@ -717,6 +718,23 @@ bool pyopencv_to(PyObject* obj, Point2d& p, const char* name) return PyArg_ParseTuple(obj, "dd", &p.x, &p.y) > 0; } +template<> +bool pyopencv_to(PyObject* obj, Point3f& p, const char* name) +{ + (void)name; + if(!obj || obj == Py_None) + return true; + return PyArg_ParseTuple(obj, "fff", &p.x, &p.y, &p.z) > 0; +} + +template<> +bool pyopencv_to(PyObject* obj, Point3d& p, const char* name) +{ + (void)name; + if(!obj || obj == Py_None) + return true; + return PyArg_ParseTuple(obj, "ddd", &p.x, &p.y, &p.z) > 0; +} template<> PyObject* pyopencv_from(const Point& p) @@ -730,6 +748,12 @@ PyObject* pyopencv_from(const Point2f& p) return Py_BuildValue("(dd)", p.x, p.y); } +template<> +PyObject* pyopencv_from(const Point3f& p) +{ + return Py_BuildValue("(ddd)", p.x, p.y, p.z); +} + template<> bool pyopencv_to(PyObject* obj, Vec3d& v, const char* name) { @@ -757,6 +781,12 @@ PyObject* pyopencv_from(const Point2d& p) return Py_BuildValue("(dd)", p.x, p.y); } +template<> +PyObject* pyopencv_from(const Point3d& p) +{ + return Py_BuildValue("(ddd)", p.x, p.y, p.y); +} + template struct pyopencvVecConverter { static bool to(PyObject* obj, std::vector<_Tp>& value, const ArgInfo info)