|
|
|
@ -819,6 +819,40 @@ bool pyopencv_to(PyObject* obj, Range& r, const char* name) |
|
|
|
|
CV_UNUSED(name); |
|
|
|
|
if(!obj || obj == Py_None) |
|
|
|
|
return true; |
|
|
|
|
while (PySequence_Check(obj)) |
|
|
|
|
{ |
|
|
|
|
PyObject *fi = PySequence_Fast(obj, name); |
|
|
|
|
if (fi == NULL) |
|
|
|
|
break; |
|
|
|
|
if (2 != PySequence_Fast_GET_SIZE(fi)) |
|
|
|
|
{ |
|
|
|
|
failmsg("Range value for argument '%s' is longer than 2", name); |
|
|
|
|
Py_DECREF(fi); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
PyObject *item = PySequence_Fast_GET_ITEM(fi, 0); |
|
|
|
|
if (PyInt_Check(item)) { |
|
|
|
|
r.start = (int)PyInt_AsLong(item); |
|
|
|
|
} else { |
|
|
|
|
failmsg("Range.start value for argument '%s' is not integer", name); |
|
|
|
|
Py_DECREF(fi); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
PyObject *item = PySequence_Fast_GET_ITEM(fi, 1); |
|
|
|
|
if (PyInt_Check(item)) { |
|
|
|
|
r.end = (int)PyInt_AsLong(item); |
|
|
|
|
} else { |
|
|
|
|
failmsg("Range.end value for argument '%s' is not integer", name); |
|
|
|
|
Py_DECREF(fi); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Py_DECREF(fi); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
if(PyObject_Size(obj) == 0) |
|
|
|
|
{ |
|
|
|
|
r = Range::all(); |
|
|
|
|