From 1048b235bfa0cfbdca58f62927de46ad2be39648 Mon Sep 17 00:00:00 2001 From: berak Date: Fri, 30 Oct 2015 10:02:33 +0100 Subject: [PATCH] add Rect2d to python bindings --- modules/python/src2/cv2.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index 82f1c8b9f..8d58bcc17 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -97,6 +97,7 @@ typedef std::vector vector_Vec4f; typedef std::vector vector_Vec6f; typedef std::vector vector_Vec4i; typedef std::vector vector_Rect; +typedef std::vector vector_Rect2d; typedef std::vector vector_KeyPoint; typedef std::vector vector_Mat; typedef std::vector vector_DMatch; @@ -649,6 +650,21 @@ PyObject* pyopencv_from(const Rect& r) return Py_BuildValue("(iiii)", r.x, r.y, r.width, r.height); } +template<> +bool pyopencv_to(PyObject* obj, Rect2d& r, const char* name) +{ + (void)name; + if(!obj || obj == Py_None) + return true; + return PyArg_ParseTuple(obj, "dddd", &r.x, &r.y, &r.width, &r.height) > 0; +} + +template<> +PyObject* pyopencv_from(const Rect2d& r) +{ + return Py_BuildValue("(dddd)", r.x, r.y, r.width, r.height); +} + template<> bool pyopencv_to(PyObject* obj, Range& r, const char* name) {