PLearn 0.1
Static Public Member Functions
PLearn::ConvertFromPyObject< Mat > Struct Template Reference

#include <PythonObjectWrapper.h>

List of all members.

Static Public Member Functions

static Mat convert (PyObject *, bool print_traceback=true)
static void convert (PyObject *pyobj, Mat &result, bool print_traceback)

Detailed Description

template<>
struct PLearn::ConvertFromPyObject< Mat >

Definition at line 378 of file PythonObjectWrapper.h.


Member Function Documentation

Mat PLearn::ConvertFromPyObject< Mat >::convert ( PyObject *  pyobj,
bool  print_traceback = true 
) [static]

Definition at line 283 of file PythonObjectWrapper.cc.

References m.

{
    Mat m;
    convert(pyobj, m, print_traceback);
    return m;
}
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);
}

Here is the call graph for this function:


The documentation for this struct was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines