embedding/extending numpy:import_array() problem
Hi guys, I've a C++ code that calls a python script. The python script, in turn, should use C modules to retrieve data (arrays). I'm having some problem with import_array. I've placed the import_array() just after the initialization of the interpreter and after PyInit_module Py_Initialize(); Py_InitModule("py_c_if", PY_C_IF_Methods); import_array(); This are inside a function called main_PYinit,called within the main C function. When I tryed to compile, I got the at the line of import_array the error "function must return a value". If I change the __multiarray_api.h and make import_array() a function with void instead of #define, the compiltion succeed. However, when then I try to use some API function I get problems.In particular I used this code: char *camera_buffer = cam_data; npy_int dim[] = {rows,cols}; /* whatever the size of your data, in C-order */ PyObject *myarray; double *array_buffer; myarray = PyArray_SimpleNew(2, &dim, NPY_INT); Py_INCREF(myarray); array_buffer = (double *)PyArray_DATA(myarray); for (int i=0; i<rows*cols; i++) *array_buffer++ = (double) *camera_buffer++; return PyArray_Return(myarray); And I goit this error: .\EyeSeeMain.cpp(242) : error C2664: 'PyObject *(PyTypeObject *,int,npy_intp *,int,npy_intp *,void *,int,int,PyObject *)' : cannot convert parameter 2 from 'npy_intp *' to 'int' for all the paramters of PyArray_SimpleNew. It seems that the complier did ot see the definition of PyAray_SimpleNew... Any help is grealy appreciated. Cheers L
participants (1)
-
tino