From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

LV DLL in c++ throws "Not an Image" error

Hi,

I need to export my labview inspection to dll. After building the dll, I tried to run it in c++ but it failed with "Not an Image" error. I simplified it to following code:

Image* img = imaqCreateImage(ImageType::IMAQ_IMAGE_U8, 0);
imaqReadFile2(img, "C:/Users/irt/Pictures/5_p_47356.jpg",NULL, NULL, NULL);
auto err = NI_Vision_Development_Module_IMAQInverse((uintptr_t*)img);

It fails with the same error.

 

What i'm doing wrong?

0 Kudos
Message 1 of 3
(1,794 Views)

I'm not sure if I have ever tried what you are doing, or if it is even expected to work. Under the hood, the LV image type is sort of a super-set of the C API image type (it adds a layer of the LV refnum and a name). You should be able to transparently pass a LV image to the Vision C API functions, and when the refnum is cast into a pointer-sized integer on the LV diagram, it should be the same type as an Image* (as far as I recall). Going the other direction seems tricky, since any place the image needs to be translated back to a refnum, it won't have an associated LV data structure allocated.

 

Have you tried creating the images from LV first, then passing them to your DLL (moving IMAQ Create out of your DLL and onto the LV diagram)? 


Eric

0 Kudos
Message 2 of 3
(1,731 Views)

We solved it by wrapping the inspection SubVI by an adapter. C++ gives a pointer to image data, height, width and stride to LV (see VIs below). 

 

Download All
0 Kudos
Message 3 of 3
(1,707 Views)