LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass Image to C++

Solved!
Go to solution

Hi,

I am currently trying to pass a IMAQ Image to a .dll which I want to write in C++.

I am unsing the imaq getImagePIxelPtr. 

However I cannot figure out how I can get an imaq Image back from my Pointer to be able to use 

the function in the nivision.h. 

Or is there a way to directly pass the Image without using the pixelPointer?

I feel like this should be trivial, but I just cannot figure out how it works!

Thanks for your help,

Greetings

0 Kudos
Message 1 of 4
(3,192 Views)

This largely depends on what you want to do with the data, but generally, I would convert the image into an array and then pass that array to your DLL.

 

For some additional help and examples see:

 

https://www.ni.com/docs/en-US/bundle/labview/page/using-arrays-and-strings-in-the-call-library-funct...

0 Kudos
Message 2 of 4
(3,183 Views)

Hi,

thanks a lot for your help!

I have now managed to pass the 2D Array to the dll and managed to individually manipulate pixels, which is what I intended to do.

However C++ does not recognize the Array as being 2D. Instead it says to be a 1D array which has the pixels rowwise. 

(eg. a 5*5Image would be a 1D Array, where what should be [1][0] would be [5])

This is of course not a lot of trouble, I just wondered wether there shouldn't be a 2D array?

 

Thanks again!

0 Kudos
Message 3 of 4
(3,178 Views)
Solution
Accepted by kper

 Because of the way arrays are lined out in memory, all arrays, including 20432-dimensional arrays are simily laid out linearly in memory. This means that to use the array bracket notation for an array with more dimensions than one, the C++ compiler needs more information to access the info. In a 2D array, this more information is called the stride length, or something similar.

 

This is why you can make variables like int myarray [] but int myarray [][] won't compile... you need to stride length: int myarray[stride][]. Then C++ can convert arr[x][y] to to what it really is: arr[stride*x+y]. To my knowledge, there's no way to get that at compile time without knowing the dimensions of the matrix. Of course, you can always just do it by hand (arr[stride*x+y], and you shouldn't be punished by performance too heavily when you do.

0 Kudos
Message 4 of 4
(3,172 Views)