I'm familiar with writing DLLs that can be called from LabVIEW, but I'm curious as to what the correct way to pass IMAQ Images to a DLL might be. Here's one way I've found to do it -- I also use a similar mechanism to post IMAQ Image instances from my DLL to an Event Structure.
Note that the nodes that convert the image instances to/from clusters are located at ${LABVIEW_INSTALL_DIR}/vi.lib/vision/DatatypeConversion.llb
, and are named IMAQ Image Datatype to Image Cluster.vi
and IMAQ Image Cluster to Image Datatype.vi
, respectively. The cluster that is created consists of the image name and an integer value that represents the pointer address to an Image*
type in C/C++.
Is this the best way to do this, or is there a better way?
I use a different approach, putting all the image info (pointer, sizes, etc) in a cluster using the following code:
The cluster is then passed to the DLL function, making operations on pixels (no changing the size, of course) and afterward call IMAQ's unmap pixel pointer.
EDIT after discussion:
Your solution relies on having NI Vision, and in this case it's better than mine. However when not having NI Vision mine is the only way to work with IMAQ's pixel data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With