Problem using external shared library with pointers
Show older comments
Hey there!
I'm trying to control a camera via MatLab. Loading the library and using some of its functions works fine. However I have problems using the functions working with pointers.
In order to save a picture I first have to allocate an image memory by using:
INT is_AllocImageMem (HIDS hCam, INT width, INT height, INT bitspixel, char** ppcImgMem, INT* pid)
The second function which makes the specified image memory the active memory is:
INT is_SetImageMem (HIDS hCam, char* pcImgMem, INT id)
In MatLab my code looks like this:
width=1280;
height=1024;
bitspixel=24;
pcImgMem=libpointer('stringPtrPtr',{char()});
pid=libpointer('int32Ptr',0);
[m,pcImgMem,pid]=calllib('uc480','is_AllocImageMem',hcam,width,height,bitspixel,pcImgMem,pid);
[m,pcImgMem]=calllib('uc480','is_SetImageMem',hcam,pcImgMem,pid);
When I execute it I always either get an "Parameter can not be converted to a string" error for the variable pcImgMem. If I convert pcImgMem with char(...) I get an error message from the function itself.
Can anybody help me with this problem? Or does anybody have a good tutorial for the use of pointers in libraries? I have read the "Working with Pointer Arguments" in the Mathworks Documentation Center from top to bottom and tried to apply it correctly.
But something still seems to be wrong... Thank you for your help!
Accepted Answer
More Answers (0)
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!