Merge pull request #5592 from berak:python_rect2d

This commit is contained in:
Vadim Pisarevsky 2015-11-02 11:36:03 +00:00
commit 39346f3204

View File

@ -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;
@ -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)
{