05-21-2008 07:23 AM
Hello Jennifer,
Thank you for helping me with the wrapper code. I shouldn't have any other problems using the camera.
Thanks again for your time,
Omer
05-21-2008 08:08 AM
Hi Omer,
My pleasure. If you do have any more questions about the wrapper function or calling it in LabVIEW, feel free to post back. Good luck with the project!
05-06-2012 05:06 PM
I know this is a very old thread, but I have a quick question that is related that I hope someone can answer.
Jennifer mentions to "Then create a 176x144 array in LabVIEW to pass to the Call Library Function Node for myWrapper, along with the other two parameters." How do you pass SRCAM srCAM from Labview to the Call Library Function Node?
I have a very similar issue. If need be, I will create a new thread describing the issue in details.
Thanks
05-07-2012 03:28 AM
@Jennifer_R wrote:
Hi Omer,
It sounds like memory allocation is being handled properly, which is important.
Creating a wrapper DLL, as you mentioned, is a good approach. You can write code to call SR_GetImage, get a reference to the array, and pass that to LabVIEW.
Based on the details you have given, the function you write would probably look something like this:
void myWrapper (SRCAM srCam, unsigned char idx, double [ ][ ] imageArray)
{
imageArray = SR_GetImage (SRCAM srCam, unsigned char idx);
}Then create a 176x144 array in LabVIEW to pass to the Call Library Function Node for myWrapper, along with the other two parameters. Select Array Data Pointer when configuring the Call Library Function Node. You may also want to try declaring imageArray as a pointer to an array instead of the array itself.
This is an old thread but I would like to make a correction to it. Above will likely not work at all, as the assignment will simply overwrite the array pointer passed in from LabVIEW but LabVIEW will not see it at all, since it is passed in by value (the pointer I mean) so it never can pass back to LabVIEW. Configuring the array pointer to be passed in by reference wouldn't work either as LabVIEW does not allow to configure an array pointer to be passed in by reference and it wouldn't work either as it would just corrupt LabVIEW memory.
There is no trivial solution for this that works always, since it depends on many things, but one possible (and ugly I may add) solution is something like this:
void myWrapper (SRCAM srCam, unsigned char idx, int byteSize, double [ ][ ] imageArray)
{
void *ptr = SR_GetImage (SRCAM srCam, unsigned char idx);
MoveBlock(ptr, imageArray, byteSize);
}
You would have to calculate the the byteSize in LabVIEW from the number of pixels (width * height) multiplied by the number of bytes per pixel that you hopefully know to have in the picture frame. If you get this to small you won't get all the data into LabVIEW, and if it is to big it will cause likely exceptions.
And this above code could actually be even implemented all in LabVIEW, by configuring the return value of the SR-GetImage function to be a pointer sized integer and using a LabVIEW call to the MoveBlock() manager function to copy the pointer contents into a LabVIEW array. Search for MoveBlock in this forum to see many posts about how to do that but unless you are able to do above in C and understand it too, don't expect to do this in the LabVIEW diagram either.
05-07-2012 03:30 AM
@elsayed3 wrote:How do you pass SRCAM srCAM from Labview to the Call Library Function Node?
I have no idea what the SRCAM datatype is, but I expect it to be either an integer that indicates the device number or a handle that you have opened at some point with an API function.