LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VisionDevMod: Checking for a valid image

Solved!
Go to solution

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:

InvalidImageCheck.png

 

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:

InvalidImageCheck2.png

 

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

 

 

0 Kudos
Message 1 of 3
(4,838 Views)
Solution
Accepted by comrade

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

Message 2 of 3
(4,616 Views)

Alright then. I was just hoping for something similar to the Search 1D Array primitive. Case closed.

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