LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with For Loop

Hi everyone,

 

In my research group, we're using a Firewire camera to collect large numbers of images. We have found that the example VI "Grab and Attributes Setup.vi" that came with IMAQ to does exactly what we need for our camera in terms of controlling our camera attributes. However, we want to take the image generate from that vi and sum a large series of those up to generate a total image. We have a small vi that does that. Our problem is that when we try to drop our image summing code into the "Grab and Attributes Setup.vi" the for loop that we're using in our image summing code never closes. Essentially, it keeps running and we need it to stop after it reaches the number of images that we specify.

 

I've tried changing the for loop to having a conditional terminal and so that the loop stops when the iteration number matches the number of images to collect, but that doesn't seem to be working either. I've also tried placing the image summing code in various places myself inside of the "Grab and Attributes Setup.vi" but that hasn't lead to much success for me either.

 

If anyone could help with this, it'd be greatly apperciated.

Download All
0 Kudos
Message 1 of 6
(2,177 Views)

You may have to wait a while for someone with LabVIEW 2011 to look at this.  Many of us are still using older versions and can't open your file. 

You could 'Save for Previous..." and post a LV2010 version for quicker response...

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 2 of 6
(2,161 Views)

Can you be a bit more clear about what's going wrong?  In your "imagesumming.vi" you have an indicator on the for loop iteration terminal.  Does that keep increasing after the specified number of images?  Does the for loop stop, but the VI keeps running?  What happens if you turn on "execution highlighting" after you expect it to have stopped - can you see it still executing?

 

Is it possible that the problem is that you have wired "Number of Images" to both the Count for the for loop, and to the "Number of Images" input of the Vision Acquisition express VI?  You're acquiring 100 x 100 images, because the for loop executes 100 times and each time the Vision Acquisition function acquires 100 images.

0 Kudos
Message 3 of 6
(2,142 Views)

Hey there cmpruitt2,

 

Just like what nathand was saying, it seems that there is a little confusion as to how many times you're trying to run the For Loop. You have 100 wired into your count terminal and 100 wired into the number of images input of the Vision Acquisition express VI. This would mean you're gathering a total of 10,000 images!

 

My guess is that you are trying to run the For Loop 100 times and with each iteration of the loop acquire 1 image? If so, then you'd want to switch the input to your number of images to 1.

 

You also mentioned that you tried to use conditional terminals to stop the VI. This is not a simple thing to do with For Loops and it's not recommended. That kind behavior lends itself to While Loops. As a good rule of thumb, use For Loops when you know how many times you want to run a loop, and While Loops when you are not sure!

 

Have fun working on your project!

Tim A.
0 Kudos
Message 4 of 6
(2,105 Views)

Hello everyone,

 

Thanks for your replies! So, I've been working on this more myself and I've basically got the program doing everything we need except for one thing.

 

We would like to be able to see the total image build up as the live image is acquired. We've tried placing this inside the while loop, but that doesn't seem to work. Basically, is there a way to get data out of an event structure (inside a while loop) when the while loop is still running?

 

I've attached a version of our VI saved for LV2010.

 

Thank you for your help and replies.

 

CJ

0 Kudos
Message 5 of 6
(2,071 Views)

@cmpruitt2 wrote:

 

We would like to be able to see the total image build up as the live image is acquired. We've tried placing this inside the while loop, but that doesn't seem to work. Basically, is there a way to get data out of an event structure (inside a while loop) when the while loop is still running?


I don't quite understand what you're doing here, and it would help to see your attempt at putting the logic inside the while loop.  You're summing the same image - the last image captured - over and over again in the for loop at the end.  Instead of putting a shift register in the for loop, put it in the while loop, and move the logic from the for loop into the "Frame Done" event case.  Wire the shift register through all the other cases (you can do this easily by right-clicking on the tunnel and creating a linked input tunnel).

 

Alternatively, you could use a queue to pass the image data out of the event structure to a separate loop that handles the processing.  You may eventually need to do this if your program continues to grow.

0 Kudos
Message 6 of 6
(2,061 Views)