LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ImageToArray function sometimes reports valid input as "not an image"

Solved!
Go to solution
ImageToArray function sometimes reports valid input as "not an image"
 
image is displayed, then immediately piped into the ImageToArray function. most of the time, there is no error. occasionally, ImageToArray will report a "not an image" error and halt program execution Even though the image displays properly and contains valid values!
 
What the heck?

global variables make robots angry


0 Kudos
Message 1 of 8
(3,230 Views)
I don't use IMAQ, but it sounds to me like you might have a race conditions. I know that an IMAQ image wire is actually a pointer, so I'm guessing that the image is not there when the VI runs but is there when the indicator needs to be updated. Can you post an image of your code or the actual VI itself?

___________________
Try to take over the world!
0 Kudos
Message 2 of 8
(3,218 Views)

Hi,

tst is right, race conditions can certainly cause such errors, especially the ones that you see only sporadically. Is there a chance that you are destroying the image buffer in parallel? Make sure that you dont have an IMAQ Dispose VI that might be reached before the Image to Array VI.

Jaidev

 

Senior Product Manager
National Instruments
0 Kudos
Message 3 of 8
(3,194 Views)
image is not being deleted out of turn, here is a picture of the vi: [URL=http://allyoucanupload.webshots.com/v/2000660280820369453][IMG]http://aycu10.webshots.com/image/37929/2000660280820369453_th.jpg[/IMG][/URL] the data should arrive at the "before" output and the IMAQ array to image function at the 'same' time. the image can always be displayed properly. it contains valid values, but every once in a while "array to image" tells me it's not an image! If we assume this is a race condition, how do I solve the problem?

global variables make robots angry


0 Kudos
Message 4 of 8
(3,186 Views)
Your image wasn't accessible. You can just attach it to your post.

___________________
Try to take over the world!
0 Kudos
Message 5 of 8
(3,183 Views)

global variables make robots angry


0 Kudos
Message 6 of 8
(3,176 Views)
Solution
Accepted by topic author Root_Canal
There is nothing in that image that gurantees that the Image to Array VI will run before the close VI. It may look to you like it requires a lot more code, so you would expect that it would run first, but apparently, the VI which releases the reference runs before the Image to Array VI. Again, you should note the image wire does not hold the image itself - it is a pointer to the image, so destroying the image means you can't access it anymore.

If the Image to Array VI has error I/O, use that to force it to execute before the close VI. If it does not, you can use a flat sequence structure.

___________________
Try to take over the world!
Message 7 of 8
(3,173 Views)
thanks.

global variables make robots angry


0 Kudos
Message 8 of 8
(3,170 Views)