I have a GetImageData function in a DLL:
int GetImageData ( const char * name , int ID , const char * strLibPath , int Lvl , int rbeg , int rend , int cbeg , int cend , int ZLayer , unsigned char * ImgBuffer );
in Python I import this DLL and establish the variables:
import ctypes,numpy
from ctypes import *
Wlib = ctypes.WinDLL('C:\\...\\Wsl.dll')
GetImage=Wlib["GetImage"]
name =c_char_p(fname)
ID =c_int(0)
strLibPath=c_char_p(LibPath)
Lvl =c_int(0)
rbeg =c_int(100)
rend =c_int(1099)
cbeg =c_int(5500)
cend =c_int(6499)
ZLayer =c_int(0)
nBpp=24
nch = nBpp/8
roiW = 6499-5500+1
roiH = 1099-100+1
In MATLAB an array and pointer are defined:
img = uint8(zeros([roiW,roiH,nch]));
ptr = libpointer('uint8Ptr',img);
In PYTHON I think this is how it should be done for the Matlab equivalent, but this does not work and kills Python:
img = numpy.zeros([roiW,roiH,nch],dtype=ctypes.c_int8)
ptr=img.ctypes.data_as(ctypes.POINTER(ctypes.c_int8))
[status, fname, fpath, img]=GetImage(name,ID,strLibPath,Lvl,rbeg,rend,cbeg,cend,ZLayer, ptr)
How do I correctly create an array and pointer than can be fed to my DLL?
[status, fname, fpath, img]
? – bdforbes Feb 11 '14 at 1:42[status, fname, fpath, img] = calllib('WholeImg','GetImage', name, ID, strLibPath, Lvl, rbeg, rend,cbeg,cend,Zlayer,ptr)
– AcejrAZ Feb 11 '14 at 16:33