bna08 Posted April 19, 2023 Report Share Posted April 19, 2023 (edited) I have an IMAQ image and I obtain the address of its pixels via IMAQ GetImagePixelPtr VI (see below). This address is passed to my .NET DLL which copies the pixel values to memory area starting at this address. Afterwards, I can access the IMAQ image directly in LabVIEW. However, I also want to access the image pixel values for direct processing. This could be achieved by calling IMAQ ImageToArray VI which is unfortunately quite slow (around 5-10ms on my 12-core Xeon CPU). Since we already have the pixel pointer address provided by GetImagePixelPtr VI, is there any way how this address could be cast directly to a LabVIEW array? Basically, I want to be able to convert (cast) this address to a LabVIEW array of UNS16: Is there any way how it could be done? I would like to avoid copying the values in any way which is what IMAQ ImageToArray does. EDIT: I am starting to realize that LabVIEW array is not really just a plain array of bytes/shorts etc. but a more complex data structure (holding the information about the array length etc.). Thus, simple C/C++ array pointer casting to a LabVIEW array is not possible. Am I correct? Edited April 19, 2023 by bna08 Quote Link to comment
dadreamer Posted April 19, 2023 Report Share Posted April 19, 2023 If you are using VDM, you should already have the basic example on how to manipulate the IMAQ image in a shared library: IMAQ GetImagePixelPtr Example Don't know, if you will gain anything in terms of performance, but worth a try at least. Quote Link to comment
bna08 Posted April 19, 2023 Author Report Share Posted April 19, 2023 24 minutes ago, dadreamer said: If you are using VDM, you should already have the basic example on how to manipulate the IMAQ image in a shared library: IMAQ GetImagePixelPtr Example Don't know, if you will gain anything in terms of performance, but worth a try at least. This is what I am actually doing already. The question is if IMAQ Image pixels pointed to by the pointer obtained from IMAQ GetImagePixelPtr can be cast to a LabVIEW array. Quote Link to comment
dadreamer Posted April 19, 2023 Report Share Posted April 19, 2023 I'm afraid, no way around that. I mean, without A LOT of low-level hackery. IMAQ images have borders 3 pixels wide by default, whereas LabVIEW arrays don't have those. And not every VI from the Array palette works in-place, not producing a copy. Of course, you may read/write pixels data by its pointer using MoveBlock. Like this: But I wouldn't expect more than that. You can always move the image processing into your DLL/SO and write everything in pure C/C++, C# et cetera. 1 Quote Link to comment
Rolf Kalbermatter Posted May 1, 2023 Report Share Posted May 1, 2023 On 4/19/2023 at 3:55 PM, bna08 said: This is what I am actually doing already. The question is if IMAQ Image pixels pointed to by the pointer obtained from IMAQ GetImagePixelPtr can be cast to a LabVIEW array. Daddreamer is correct. An IMAQ image is NOT a LabVIEW array, not even by a very very long stretch. There is simply no way to treat it as such without copying the data around anyhow! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.