LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to pass a IMAQ Image variable to my DLL ?

I can not use the ImageToArray function in my CVS , so I am thinking pass
directly the IMAQ Image as a variable to my DLL, similar to the NIVision.DLL
(you can see this DLL configed data type when you double click the
ImageToArray).

when you assign the data type for the image to adapt to type (like the
NIVision.DLL)
so in the DLL config, the data types like this :
GoMyDLL(long count, long *time, void *aImage)


in my C++ DLL

extern "C" __declspec(dllexport) void GoGoMyDLL( long count, long *time,
void *aImage)
{
}

the thing is :

how can I extract the aImage pixels. I don't know the data format or
structure of the IMAQ image, may be it's in nivision.h or some where,
but I can't find it in my PC.

I tried to extract the b
inary and saved to a file , still can't figure out
the how to get the real image data.

what can I do with this IMAQ image ?

thanks.
0 Kudos
Message 1 of 7
(5,256 Views)
Richard Zhu wrote:

> I can not use the ImageToArray function in my CVS , so I am thinking pass
> directly the IMAQ Image as a variable to my DLL, similar to the NIVision.DLL
> (you can see this DLL configed data type when you double click the
> ImageToArray).
>
> when you assign the data type for the image to adapt to type (like the
> NIVision.DLL)
> so in the DLL config, the data types like this :
> GoMyDLL(long count, long *time, void *aImage)
>
> in my C++ DLL
>
> extern "C" __declspec(dllexport) void GoGoMyDLL( long count, long *time,
> void *aImage)
> {
> }
>
> the thing is :
>
> how can I extract the aImage pixels. I don't know the data format or
> structure of the IMAQ image, may be it's in nivision.h or some where,
> but I can't find it in my PC.

This is a private LabVIEW data structure introduced in LabVIEW 7.0.
Before that IMAQ images where a pointer to a cluster with a string
handle and a 32 bit pointer to a private LabVIEW data structure, now it
is simply a pointer to a structure with private contents. LabVIEW
respectively the niVIsSvc.dll has functions to extract information from
this private pointer but I don't believe NI has intentions to document
them. But you can ask.
Trying to extract them yourself by reverse engineering the structure is
not only illegal in some legislations but also a sure way to version
hell, as NI is free and very likely to modify the layout of this private
structure in every new LabVIEW version. This is one of the reasons they
probably never will document the layout of this structure, to be able to
make modifications to add new features.

> I tried to extract the binary and saved to a file , still can't figure out
> the how to get the real image data.

It is a pointer to a structure with numerics and more pointers to
structures with numerics and even more pointers! Maybe it is even an
object pointer with embedded methods much like a C++ object.

> what can I do with this IMAQ image ?

Nothing other than passing it as an opaque pointer to the documented
IMAQ C functions.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 2 of 7
(5,260 Views)
RolfK wrote:

>> what can I do with this IMAQ image ?
>
> Nothing other than passing it as an opaque pointer to the documented
> IMAQ C functions.

One idea I also just had. Take a look at the IMAQ GetImagePixelPtr VI. I
haven't checked the 7.0 version but the older versions call into
NIvision.dll to retrieve a pointer to the top left pixel of the bitmap
and also return the rowBytes of the image (padding and border bytes).
With this you could access the bitmap bits of the IMAQ image.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 3 of 7
(5,256 Views)
Richard,

I just wanted to clarify that the Image to Array VI should work just fine on your CVS as I mentioned in this thread:

Developer Zone Thread: "can not use IMAQ ImageToArray and IMAQ Rotate on CVS"

Instead of trying to work around the problem that you are running into, I would suggest that you try solve the issue that you are having with using the Image to Array functionality, as this seems like the best long term solution to the problem that you are experiencing.

Regards,
Jed R.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 7
(5,256 Views)
Jed R.
 

Sure, Image to Array VI will work but too slow. If we want do an operation on two input images and output the resulting image, we have to call Image to Array VI twice and Array to Image VI once. Also it consumes more memory space. This is not a good solution for time critical applications.

 

Jiping

 
0 Kudos
Message 5 of 7
(4,831 Views)
I think I run into the same problem as you ,I have tried many times to access the image as a pointer but failed ,the imageToarray is too slow. please give me some tips  how to slove the problem
0 Kudos
Message 6 of 7
(4,467 Views)
I also want to pass a image not a array to my DLL , so did you solve the problem ,give me some tips ,thanks
0 Kudos
Message 7 of 7
(4,442 Views)