07-24-2015 06:41 PM
The question is simple: How to check whether an image wire carries a valid image? Valid meaning the value on the wire points to a piece of memory that has been properly allocated with IMAQ Create.
In the past I've been using just a comparison to simple image constant. This turns out to go awry whenever a once valid image (carrying a name) has been disposed of by IMAQ Dispose.
After I realized this I turned to use Not A Number/Path/Refnum.This works perfectly so far, as is suggested to behave as such in this discussion from a while ago:
LAVA.org: check-image-input-is-valid/
The following snippet illustrates this behaviour:
In later programming tasks I have come across the problem with "empty array fillers" in 2D-arrays of images - If several different-sized 1D arrays are built into a 2D array, empty filler elements are created in the "shorter" rows. Now - if I want to check, how many valid images are held within one particular row, I thought, well, "Not a Refnum?" works for this - let's use "Not a Refnum Constant" with "Search 1D Array".
But no, images and "Not a Refnum Constant" are not compatible.
I tried TypeCasting the "Not a Refnum" into an image: Broken wire.
I tried TypeCasting the "Not a Refnum" into a string (leaving the type connector empty) - same as when searching for an empty image constant (of course).
Now I use this little function which, however, seems a bit overkill:
Is there an "official" way NI endorses to do what I want. Or is there even a more obvious one I've missed?
Thanks for any enlightenment.
Falk aka comrade
Solved! Go to Solution.
07-28-2015 05:00 AM
Hello Falk,
thank you for your request. The way you solved the issue seems to be well-programmed. Are you experiencing any drawbacks with the 'overkill' function you use at the moment? If it works fine, I would say you found a good solution already.
Best
Martin
07-28-2015 05:08 AM
Alright then. I was just hoping for something similar to the Search 1D Array primitive. Case closed.