Skip to content

Commit

Permalink
add Rect2d to python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
berak committed Oct 30, 2015
1 parent 37ce3b8 commit 1048b23
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions modules/python/src2/cv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ typedef std::vector<Vec4f> vector_Vec4f;
typedef std::vector<Vec6f> vector_Vec6f;
typedef std::vector<Vec4i> vector_Vec4i;
typedef std::vector<Rect> vector_Rect;
typedef std::vector<Rect2d> vector_Rect2d;
typedef std::vector<KeyPoint> vector_KeyPoint;
typedef std::vector<Mat> vector_Mat;
typedef std::vector<DMatch> vector_DMatch;
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 1048b23

Please sign in to comment.