LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

'Replace Array Element' replaces ALL the elements, not just indexed

Solved!
Go to solution

Hey LabView Masters,

 

Pretty new to Labview and I'm trying to sort out how to create an array of images. I know the total number of images I want in my 'buffer' (not LabView's buffer), so I'm initializing an array of that size. Then I bring that array into a For Loop with a Shift register, and I'd like to continually grab images and write them into the buffe array (A Comment: I'm making a circular buffer, but I don't want to implement LabView's because it has a lot of stuff I don't need and I will eventually need the process to be as lean as possible).

 

Here's the problem (I assume an implementation, not broken LabView): 

I'm Expecting:

ONE element of array, in position indicated by the loop index [i], is replaced by newly grabbed image

I'm Getting:

ALL elements of the array become the newly grabbed image. 

(I can tell because I sub-sample the array, grabbing a single image from a constant index 'Check Array' - Could be 7, for example. But my index value for the loop [i] is at 13, and the sub-sample still becomes the newly grabbed image. 

 

What ridiculous thing am I doing wrong?

Any help would be greatly appreciated.

 

Image Array.png

 

 

0 Kudos
Message 1 of 5
(2,642 Views)

The input to the IMAQ acquisition VI is always the same REFERENCE.  Since IMAQ works on REFERENCES and not really the usual data-flow of LAbVIEW, this leads to the situation where ALL of your aray elements are the same reference.  All of the references in your array will be the same, but at different times in the loop they will all point to different images.

 

Instead of inputting always the same reference to the acquisition, first index your array (array element i) and input THAT to the acquisition instead.  After the acquisition you feed it back into the array at the same position (This step is actually unneccessary, but for LV terminology I'd still recommend doing it).

 

Shane.

Message 2 of 5
(2,635 Views)

Hello NMREC1,

 

The issue here is that an IMAQ image isn't actually a stored image, rather it's a pointer to an image in memory.  This means that all branches or copies with the same image name are actually pointers to the same image, and that image is getting overwritten on each iteration of your main loop.  I haven't tested this (I don't have the VDM installed on this machine), but I think all you should need to do is initialize an array of IMAQ images with different names and then write to a different one of these images in each iteration of your loop, rather than overwriting the single image named Ring Buffer Picture each iteration.  Be aware that this is going to require quite a bit more memory than your current configuration.

 

Regards,

Tom L.
Message 3 of 5
(2,630 Views)
Solution
Accepted by topic author NNMREC1

Ah, I just noticed something.  You initialise an array of references at the start of your program, but it's an array full OF THE SAME REFERENCE:  You need to call the IMAQ Create in a loop so that you actually get unique references in your array.  You then need to have a different NAME for each image.

Message 4 of 5
(2,624 Views)

Thanks Tom and Share! Really helpful! I wondered if something like that might be the case, but couldn't quite figure out how LabView was treating the images. Thanks for the explanation.

I'll keep in mind the memory problem. I might end up using [Get Image Data], store that in an array, and then use [ArraytoImage] to monitor the data stream. 

 

Appreciate the help,

-Trevor

0 Kudos
Message 5 of 5
(2,586 Views)