I am trying to convert some of my MATLAB files to Python. I generated C code using the MATLAB Coder, then compiled everything in a library. I am now trying to make the wrapping for Python.
It looks as follows: data_in
is an image and the output of the makePyramid
function is a structure of length level
with 3 fields img
, gradX
and gradY
.
def TestEmxAPI(data_in):
#class Opaque(ctypes.Structure):
# pass
sz = (data_in.shape)
class Pyr(ctypes.Structure):
_fields_ = [('img', (ctypes.c_double*sz[0])*sz[1]),
('gradX', (ctypes.c_double*sz[0])*sz[1]),
('gradY', (ctypes.c_double*sz[0])*sz[1])]
nrows = ctypes.c_int(sz[0])
ncols = ctypes.c_int(sz[1])
level = 1
blur = -1
win = np.array([10.,10.,10.])
winc = (ctypes.c_double *3)(*win)
pp=Pyr()
in_emx = EMX.emxCreateWrapper_real_T(ctypes.c_int(data_in.ctypes.data),
nrows, ncols)
EMX.emxCreateWrapper_struct0_T.argtypes = (ctypes.POINTER(Pyr),
ctypes.c_int,
ctypes.c_int)
EMX.emxCreateWrapper_struct0_T.restype = ctypes.POINTER(Pyr)
ou_emx = EMX.emxCreateWrapper_struct0_T(pp,sz[0], sz[1])
EMX.makePyramid_2D(in_emx,
ctypes.c_double(level),
ctypes.c_double(blur),
winc,
ou_emx)
return pp
I now get a nasty error:
WindowsError: exception: access violation reading 0x0000000000000014
How can I make this work?