|
PLearn 0.1
|
#include <PythonObjectWrapper.h>
Static Public Member Functions | |
| static Mat | convert (PyObject *, bool print_traceback=true) |
| static void | convert (PyObject *pyobj, Mat &result, bool print_traceback) |
Definition at line 378 of file PythonObjectWrapper.h.
| Mat PLearn::ConvertFromPyObject< Mat >::convert | ( | PyObject * | pyobj, |
| bool | print_traceback = true |
||
| ) | [static] |
| void PLearn::ConvertFromPyObject< Mat >::convert | ( | PyObject * | pyobj, |
| Mat & | result, | ||
| bool | print_traceback | ||
| ) | [static] |
Definition at line 261 of file PythonObjectWrapper.cc.
References PLearn::TVec< T >::copyFrom(), PL_NPY_REAL, PLASSERT, PLearn::PLPythonConversionError(), PLearn::TMat< T >::resize(), and PLearn::TMat< T >::toVec().
{
PLASSERT( pyobj );
PyObject* pyarr0= PyArray_CheckFromAny(pyobj, NULL,
2, 2, NPY_CARRAY_RO, Py_None);
if(!pyarr0)
PLPythonConversionError("ConvertFromPyObject<Mat>", pyobj,
print_traceback);
PyObject* pyarr=
PyArray_CastToType(reinterpret_cast<PyArrayObject*>(pyarr0),
PyArray_DescrFromType(PL_NPY_REAL), 0);
Py_XDECREF(pyarr0);
if(!pyarr)
PLPythonConversionError("ConvertFromPyObject<Mat>", pyobj,
print_traceback);
m.resize(PyArray_DIM(pyarr,0), PyArray_DIM(pyarr,1));
m.toVec().copyFrom((real*)(PyArray_DATA(pyarr)),
PyArray_DIM(pyarr,0) * PyArray_DIM(pyarr,1));
Py_XDECREF(pyarr);
}

1.7.4