06-12-2017 11:21 AM
I'm working in LabView. I have a .Net dll that expects a VisionImage as an input parameter. All the LabView VIs use IMAQImage. Is there a way to convert from on to another?
06-13-2017 09:43 AM
What does your DLL consider a "VisionImage"? If it is just an array of pixel values you can use the IMAQ ImageToArray function to break that out of the IMAQImage data type.
----
Aaron F.
National Instruments
06-13-2017 10:10 AM
.Net implementation of the NI Vision libraries uses the VisionImage class (NationalInstruments.Vision.VisionImage). If you expose a function from a .Net dll, you must pass it a VisionImage. This is different from the IMAQImage that is used in Labview. I have an existing VI that someone else created that outputs an IMAQImage. I need to pass that image into my dll for further processing. But, as I said, the two types are not the same. I don't want to have to do an extra conversion if I don't have to (i.e. convert from IMAQImage to bitmap then from bitmap to VisionImage, etc...) I just thought there would be an existing VI or method to do this conversion. But, if there is, I can't find it.
06-14-2017 06:29 AM
Still haven't found what I would call a simple and/or elegant solution. The same image information is in each type somewhere. I’m assuming I’ll have to do the conversion using some combination of the various array operations for each type.
06-14-2017 02:19 PM
Hi JohnW
Is it possible to post your code? I was looking into this question and I was not able to find the .NET Object that you have on your block diagram.
Also, just a thought, if you are calling NI vision functions into LabVIEW. Why not recreate all the code in LabVIEW and standardize on the common language.
----
Aaron F.
National Instruments
06-15-2017 06:20 AM
Finding and creating some .Net objects in LabView is not always straight forward…They are buried a little deeper in the structure than one would think.
To create a VisionImage:
Connectivity->.Net->Constructor
Select NationalInstruments.Vision.Common(xx.x.xx.xx)
In the Objects window, click the ‘+’ to the left of NationalInstruments.Vision
Scroll down to VisionImage
Then select the constructor you want. (See attached images)
Like I said, I have a few solutions. But don't really like either.
One is to use the imaqImageToClipboard, then the Algorithms.ClipboardToImage.
This works, but is very clunky and not really safe if someone is working on the desktop while it is running.
The other is to use arrays as you suggested. Again, this works but just seems like a lot of manual work.
I just thought NI (or someone) would have made a VI to do this already.
As far a recreating everything in LabView...The reason I'm spending time doing this in the first place is to eliminate doing just that.
The .Net code I have is substantial. I've been working with the NI .Net Vision libraries for many years and have lots of tried and true algorithms.
I don't have the time or desire to recreate them again in Labview just for the sake of having them as native LabView.
06-15-2017 04:29 PM
Thanks for explaining your process there. That makes a lot of sense!
I believe you are right, because I wasn't able to find anything that was pre-made. I do think that it would be something that is useful to the community so if you ever wanted to suggest having that feature you could do so on the Idea Exchange! R&D reviews that forum and will evaluate and implement some community suggestions from those threads.
---
Aaron F.
National Instruments
06-19-2017 07:29 AM
At any rate, here is a simple .dll and VI to show how it is done.
It is unlikely many people will find themselves in the peculiar situation I am in.
But, if so, maybe this will be helpful.