1623 |
1623 |
cvSetData(m->a, (void*)((char*)buffer + m->offset), m->a->step);
|
1624 |
1624 |
assert(cvGetErrStatus() == 0);
|
1625 |
1625 |
*dst = m->a;
|
|
1626 |
Py_DECREF(o);
|
1626 |
1627 |
return 1;
|
1627 |
1628 |
} else {
|
1628 |
1629 |
return failmsg("CvMat argument '%s' has no data", name);
|
... | ... | |
1726 |
1727 |
if (ao != NULL &&
|
1727 |
1728 |
PyCObject_Check(ao) &&
|
1728 |
1729 |
((PyArrayInterface*)PyCObject_AsVoidPtr(ao))->two == 2) {
|
|
1730 |
Py_DECREF(ao);
|
1729 |
1731 |
return 1;
|
1730 |
1732 |
}
|
1731 |
1733 |
}
|
... | ... | |
1734 |
1736 |
}
|
1735 |
1737 |
|
1736 |
1738 |
static int convert_to_cvarrseq(PyObject *o, cvarrseq *dst, const char *name = "no_name")
|
1737 |
|
{
|
|
1739 |
{
|
1738 |
1740 |
if (PyType_IsSubtype(o->ob_type, &cvseq_Type)) {
|
1739 |
1741 |
return convert_to_CvSeq(o, &(dst->seq), name);
|
1740 |
1742 |
} else if (is_convertible_to_mat(o)) {
|
... | ... | |
1749 |
1751 |
// a sequence and that they are all the same size
|
1750 |
1752 |
for (Py_ssize_t i = 0; i < PySequence_Fast_GET_SIZE(fi); i++) {
|
1751 |
1753 |
PyObject *e = PySequence_Fast_GET_ITEM(fi, i);
|
1752 |
|
|
|
1754 |
|
1753 |
1755 |
if (!PySequence_Check(e))
|
1754 |
1756 |
return failmsg("Sequence '%s' must contain sequences", name);
|
1755 |
1757 |
if (i == 0)
|
... | ... | |
2786 |
2788 |
|
2787 |
2789 |
static PyObject *fromarray(PyObject *o, int allowND)
|
2788 |
2790 |
{
|
|
2791 |
|
2789 |
2792 |
PyObject *ao = PyObject_GetAttrString(o, "__array_struct__");
|
2790 |
2793 |
if ((ao == NULL) || !PyCObject_Check(ao)) {
|
2791 |
2794 |
PyErr_SetString(PyExc_TypeError, "object does not have array interface");
|
... | ... | |
2796 |
2799 |
PyErr_SetString(PyExc_TypeError, "object does not have array interface");
|
2797 |
2800 |
return NULL;
|
2798 |
2801 |
}
|
2799 |
|
|
|
2802 |
|
2800 |
2803 |
int type = -1;
|
2801 |
2804 |
|
2802 |
2805 |
switch (pai->typekind) {
|
... | ... | |
2847 |
2850 |
return (PyObject*)failmsg("cv.fromarray array can be 2D or 3D only, see allowND argument");
|
2848 |
2851 |
}
|
2849 |
2852 |
m->a->data.ptr = (uchar*)pai->data;
|
|
2853 |
Py_DECREF(ao);
|
2850 |
2854 |
return pythonize_foreign_CvMat(m);
|
2851 |
2855 |
} else {
|
2852 |
2856 |
int dims[CV_MAX_DIM];
|