LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Addition doesn't work until both inputs are initialized?

I'm using a Logitech web camera to take pictures. I want to operate in either of two modes:
1) Overwrite - each picture taken replaces the previous one
2) Accumulate - each picture taken is added to the previous one (pixel by pixel)
The attached .doc shows a simplified version of the VI

It's working fine except for one thing ... I can't start out in "accumulate" mode. I have to take one picture in "overwrite" mode before "accumulate" mode will begin to work. If I try to begin in "accumulate" mode, the display just sits there blank regardless of how many pictures I take, until I take one in "overwrite" mode.

Does this must mean that the addition function doesn't work until both inputs are initialized? If I initialized the shift register to an array of zeros would that fix it? I tried it and it didn't seem to help, but maybe I need to make sure the initialization array is the same size as the picture array?

Thanks
Eric Coppock
ecoppock@ball.com
Ball Aerospace & Technology Corp
0 Kudos
Message 1 of 3
(2,601 Views)
"make sure the initialization array is the same size as the picture array"

Exactly.

In LV nodes do not execute until all inputs have data. For unitialized shift registers the data is the default value for the datatype. For an array that may be an empty array. (I did not look it up or try it.)

It makes some sens that you cannot accumulate until you have something to add to. You could use the Is First Call? function or i=0? to detect the first pass and do some sort of initialization.

Lynn
0 Kudos
Message 2 of 3
(2,590 Views)
Look up the rules for addition and you will find that when you add two arrays, you can only add elements that exist(in both arrays). Otherwise, there is nothing to add. If your shift register is uninitialized, then that's your problem.

Two solutions:

1... If you know the size ahead of time, then initialize an array of that size with zeroes, and wire that to the outside of your shift reg.
2... You could detect I = 0, and replace the array with your new data on the 0th iteration, regardless of the mode switch. In other words do not perform an ADD if there's nothing there yet.

Either one of these is preferable to using the data from an uninitialized Shift reg. The data might not exist, or it might be leftover from your last run an hour ago.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 3 of 3
(2,579 Views)