LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW & MVTec Halcon

Solved!
Go to solution

1. In LabVIEW allocate the array of required size. I assume you know the image format (byte, int2, uint2 etc.), width and height.

2. Pass the array to your library by pointer to the data. You will need to write one additional function for that, say "Read_Back_Image".

3. In the DLL get the pointer to your processed data with get_image_pointer1 for grayscale images or with get_image_pointer3 for RGB images.

4. Copy the image memory from your processed data to LabVIEW array with memcpy or some similar function of your API.

5. Don't forget to dispose your inner objects, which you were using for the processing.

0 Kudos
Message 61 of 63
(2,540 Views)

Hi 

Here is my attached snapshots of dll code and LabVIEW code. 

Please check it and give me suggestions.

0 Kudos
Message 62 of 63
(2,527 Views)

In general it looks not bad but few things seem odd to me...

1) In LV you read the image with IMAQ VIs as unsigned 8-bit grayscale, then you pass it to the DLL as unsigned 32-bit and inside the DLL you convert it to unsigned 8-bit again. Why? Which image format are you working with? If it's U8 then work with it as with unsigned 8-bit ("byte" type in Halcon; look here for other types).

2) You do something strange with the pointer you've got. Why do you need to convert it to a string and allocate additional memory? After you have called get_image_pointer1, you may copy data from the pointer. You don't need to allocate anything. Just read Width*Height*Type (1 for U8/"byte" etc.) bytes into LV array.

3) You return a string from the DLL allocated inside, but then you also need to free that memory somewhere. Where do you plan to do that? And why to return a numeric value as a string? It's much easier to return a number.

There might be another quirks, which I didn't notice. It would be better to post the LV code as a snippet and C code as a plain-text, so other forum members could read it and give some advices. Seems to be told you already.

0 Kudos
Message 63 of 63
(2,521 Views)