NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Handling IMAQ Images in the TestStand Opeator Interface

I'm modifying the LabVIEW Operator Interface to display images from IMAQ VIs on the front panel. I've got it to work a number of ways, but never if I compile the interface into an executable.

I've tried using the "IMAQ Image Cluter to Image Dataype" and "IMAQ Image Datatype to Image Cluster" vi's to store and pass references to the Operator Inteface. It works in development mode but not when built. I understand this won't work as the reference is local to the adapter you are using so I abandoned that.

I've tried storing the Image into a global VI and then reading that global VI in the interface for display. I've made sure to call the Global VI dynamically in the operator interface so I'm using the same VI and not one compiled into the executable. It works in development mode but not compiled. Don't know why.

Another method I tried was to use the "Flatten To String" and "Unflatten From String" functions to store the image in a local string (as a binary string) in the sequence. I then tried accessing the local with the "ProperyObject" Method "GetValString" in the Operator Interface VI. When I try this I get an error and the development system shuts down. I know I'm access the local correctly as I have accessed other locals from the sequence in this manner.

Any ideas why one or both of the last two methods are not working for me? Is there any other methods that would work? How about sending the image to a common dll? Can you store an image or image reference in a dll so any platform could access it?

Thanks,
Dave
0 Kudos
Message 1 of 20
(4,447 Views)

Hello Dave,

Thanks for using our discussion forums.  When you mention using “flatten to string” are you using the actual “IMAQ flatten to string” vi?  This vi actually returns the string representation of the image.  You can then use the basic “unflatten from string” to get the image back as long as you specify the type.  

If you want to use the basic “flatten to string”, here is an example which converts the image to an array, compresses, uncompresses, and converts the array back to image, but the amount of data it sends across the network is the full size of the image.

http://zone.ni.com/devzone/cda/epd/p/id/3314

Hope this helps.


Regards,
Vu D
Applications Engineer

0 Kudos
Message 2 of 20
(4,407 Views)

I'm using the "Flatten to String" vi. I've looked for "IMAQ flatten to string" in LabVIEW and the help files but haven't found it. Where is it located?

As a test I flattened the image to a string then stored it in a TestStand local variable. I then send the string to another vi which takes the string, unflattened it and displays it in an external window. Works fine. But when I try and retrieve that string in the Operator Interface using VI server property, invoke node and "Unfatten from String" there, the operator interface crashes.

I put together a VI that shows what I'm doing in the Operator Interface. This has worked reading other locals from the sequence, so I don't understand why it doesn't work for this. Is it possible the "GetValString" property doesn't work for a binary string?

 

0 Kudos
Message 3 of 20
(4,395 Views)
Hi Dave,

If you are using NI-IMAQ Driver/Vision Acquisition Software the "IMAQ Flatten to String" is located under the Vision Utilities->Image Management palette.  If you are still not able to see this function then we can try using "Image to Array" (which is under Vision Utilities -> Pixel Manipulation) and then flatten that array to string.   This is used in the example I mentioned above.   Using the "flatten to string" directly does not flatten the image data.  Instead it will only flatten the pointer reference to the image.   Please let us know if you still need any other assistance. 

Regards,
Vu
0 Kudos
Message 4 of 20
(4,376 Views)

I updated my Vision Acquition and now use "IMAQ Flatten to String" instead of "Flatten to String". However I get the same result. It works fine in the sequence but if I pull the flattened data into the operator interface and try to unflatten it there, LabVIEW crashes.

Attached is how I do it in the Operator Interface.

Dave

0 Kudos
Message 5 of 20
(4,375 Views)
Hi Dave,

I do not think you attached the Operator Interface to your last post.  Could you please try it again?  Also, have you tried flattening a different data type such as an array to see if you get the same behavior?  This will help us isolate if the issue is with the Vision functions or with your executable in general.  Thanks.

Vu
0 Kudos
Message 6 of 20
(4,317 Views)
Hello,

I think I'll need to pass images from an execution to the OI sometime in the near future. Are you saying that one cannot pass an IMAQ image handle from one process, TestStand and LabVIEW, to another, LabVIEW OI? What you are talking about with the flattened strings is copying the image from the execution to the OI VI, right? Isn't there some sort of workaround you could do in CVI or something where the OI could access (share) the memory where the image already is?
0 Kudos
Message 7 of 20
(4,303 Views)
Thanks for the tip about trying another data type. I tried an numeric array and it did not work as well. But now I could see what is happening. When the GetValString reads the local it does not interpret the escape code '\'. i.e. if the string contains '\00' it ends up as '5C 30 30'. The Unflatten From String vi is expecting hex 00 and an error occures.

I wrote a crude VI to look for the escape code and convert what follows to pure hex. It first converts the string to byte array, interprets each byte, creates a new hex array then converts it back to a string. The good news is that it works for numeric arrays, and I was able to read the array values in the Operator Interface by reading the flattened data from the sequence. However, when I applied the VI to the Image Flattened data, the array was 2,295,879 elements long and my VI was way too slow to convert the whote image.

Is there a fast way of converting the string to pure hex values?

Don't know why my VI didn't show up. I'm now trying to attach an image of the block diagram.
0 Kudos
Message 8 of 20
(4,269 Views)

@dowNow wrote:
Hello,



I think I'll need to pass images from an execution to the OI sometime
in the near future. Are you saying that one cannot pass an IMAQ image
handle from one process, TestStand and LabVIEW, to another, LabVIEW OI?
What you are talking about with the flattened strings is copying the
image from the execution to the OI VI, right? Isn't there some sort of
workaround you could do in CVI or something where the OI could access (share)
the memory where the image already is?




dowNow,

I haven't done much CVI programming but I would guess that that approach would work. I'll probably try that next if I can't use the flattened data approach.

Do you have experience in this sort of thing?
0 Kudos
Message 9 of 20
(4,266 Views)
Ha ha, no I do not have experience with sharing an image handle across processes, I saw your post and thought I would join the question because I need to do this too and I don't want to pass/copy the image as a big string of bytes.

I will say, however about the escape characters, if you are passing the string from a LabVIEW code module up to Locals, there is a setting in the Specify Module dialog that allows you to set a LabVIEW string control entry in the table to ASCII or binary, that might help getting it into the Local correctly.

Another approach would be to pop open a floating LabVIEW window from within your seqeunce/execution and display the image there and not on the front panel of the OI.
0 Kudos
Message 10 of 20
(4,268 Views)