i using loadlibrary interface dll returns image data in struct containing info size of image , field actual image data stored:
struct imagestruct { // vertical size of image [pixel] int imageheight; // horizontal size of image [pixel] int imagewidth; // image data size [byte] int imagesize; // pointer image data char * imagebuffer; }; matlab turns following statement in proto file:
structs.imagestruct.members=struct('imageheight', 'int32', 'imagewidth', 'int32', 'imagesize', 'int32', 'imagebuffer', 'cstring'); i instantiate such struct using str = libstruct('imagestruct',[]) % default initialized , pass it, through calllib c function takes pointer such struct , fills image data. problem image data can contain zeros. matlab automatically turns char* member char array, stopping @ first 0 encounters. means image data gets truncated. know how many values there are, returned in imagesize member. how access whole array?
i have found 1 solution, changing type of imagebuffer member in proto file uint8ptr , telling matlab number of elements should read pointer:
str.imagebuffer.setdatatype(str.imagebuffer.datatype,1,str.imagesize); is there better solution?
Comments
Post a Comment