LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save Sequence Images with a given timing

Solved!
Go to solution

Dear Diane,

 

there is still a minor issue because I think you should punt the indicator of the "images still in queue" out of the loop, as you did with the indicator of "dequeued images", otherwise when I stop the loop the value of "images still in queu"in queue goes back to 0. I tried to put it out and to use the same structure of dequeued images but it doesn't work, we have to do in another way, which i think you may know.

 

In any case, now I can see that the cosnsumer loop time is a little bit higher than the prodcuer loop time: it is about 93.75ms whereas the other one is 62.5 ms. This might be the reason why at the beginning the images in queue are zero, but then the value starts to increase just after a few seconds and grows larger and larger... (when I stop the loop it goes back to 0).

The consumer loop iterations and the dequeued images have the same value.

 

Don't worry, actually programming with labview doesn't seem tedious to me, I like it and this is also part of my research project, therefore if I can understand well how the program works I can also achieve better results. It also very interesting to me to start learning a new way of programming i.e. Data Flow programming. It'll be very useful for my future.

 

I really have to thank you for your support, I don't know how I would have made it otherwise.

Please let me know what you think about this test.

 

 

Emanuele

0 Kudos
Message 51 of 69
(759 Views)

Hi Emanuele,

 

Certainly you can put that indicator outside the loop...I specifically wanted to see if that number grows as you run the program, as indeed it does.  (You can also add another indicator outside the loop, wired to the same terminal of "Get Queue Status".  Did that make sense?)

 

It seems that it's taking the consumer loop approximately twice as long to execute as it takes the producer loop, so you're winding up with a bunch of images left in your queue.  That's annoying, of course, but it's also something that can be handled.  What you need to do now is make sure that your consumer loop doesn't stop executing until all of the images in the queue have been processed.

 

There are lots of ways to do that.  I'll try to put something together as an example for you later today...in the meantime, you can start trying to code it yourself:

 

- When the extraction loop stops executing, the queue is released.  That causes an error to occur in the consumer loop.  You can use the error cluster to trap for that error, and take different actions based on whether it has occurred or not.  (for instance:  no error = dequeue next element.  error = extract all remaining elements from queue)

- You know how many items are in the queue because "Get Queue Status" tells you that.  So you know how many more images you need to process after the queue is released.  As each image is processed, you can decrement that number.  When all images have been processed (when you've decremented that number all the way down to 0), stop the loop.

- Look at the help files for the queue functions.  Is there a queue function which will return all of the items currently in the queue?  If so, that might come in useful, don't you think?

 

I'm glad you're enjoying LabVIEW.  I'm pretty fond of it myself.  Smiley Happy

 

Diane

0 Kudos
Message 52 of 69
(755 Views)

Hi Emanuele,

 

Another approach for you to consider:

 

Don't release the queue until all of the images have been dequeued, processed and saved.

 

To do that, you'll need some way of knowing whether the producer loop has stopped or not, since no errors will occur in the consumer loop.

 

Do you know about clusters?  Instead of just enqueueing the image, you could enqueue a cluster which contains both the image and the "stop" status of the producer loop.  A queue will accept any data type.

 

I think this is a simpler and better approach than the one I outlined earlier, but you'll need to learn some more new things.  Are you up for it?  Smiley Happy

Diane

0 Kudos
Message 53 of 69
(753 Views)

Dear Diane,

 

of course I'll try it to code it and I'll post what I'll be able to do tomorrow.

So there is no problem if the time of the two loops is different? Is any buffer overwritten? If so maybe I could also check this with some other functions....

Please let me know, tomorrow in any case I'll code the part of program you suggest doing.

Thank you for your help again.

 

Emanuele

 

0 Kudos
Message 54 of 69
(749 Views)

Hi Emanuele,

 

I'm not 100% sure if I understand your question.

 

Are you asking if there will be problems if the two loops stop at different times?

 

The answer is no, not for the circumstance we're talking about.  It's perfectly ok if your producer loop stops before your consumer loop.  Since the images are contained in the queue, the consumer loop will still have access to them after the producer loop stops -- assuming you don't release your queue reference until the consumer loop finishes.

 

If I misinterpreted your question, please say so!

Diane

0 Kudos
Message 55 of 69
(747 Views)

Hi Emanuele,

 

Have a look at this VI, which illustrates the second approach I posted -- not releasing the queue until all of the images have been processed.  Do your best to understand it by reading help files, etc., then ask questions.

 

I still want to see your attempts to implement this yourself, so post whatever you have.  Smiley Happy

 

Diane

0 Kudos
Message 56 of 69
(746 Views)

Dear Diane,

 

thank you for your new VI. Indeed it would have too difficult for me to find out how to build it without a course... or at least I would have spent a long time to bulld it and to make it work properly. I hope to follow ithe coruse very soon, but I've got so many things to do in this period that I don't know when I can find at least three hours for the course...

 

I've run the VI, but there is still something worng as it doesn't stop after it processes all the images, there is a loop which continues to run maybe... probably it's the producer loop as the indicator never becomes green.I am interested in knowing why it doesn't work, please tell me if you find out.

 

My question was related to the fact that in the circular buffer the program creates like a vector of images and continuosly overwrite images after it finishes to fill it (I think independently on the fact that they are extracted in the loop)... so I was wondering if there is a condition for the buffer size after which I am sure that there is no overwriting and I have all the images without skipping any of them, based on the frame rate that I set and on the time it takes to extract and enqueue one image, which is the producer loop time.Porbably you have already told me but I didn't understand it very well... Could you please explain it to me again?

 

Thank you again.

 

Emanuele

0 Kudos
Message 57 of 69
(737 Views)

Mistake in the sentence, I was meaning the consumer loop maybe doesn't stop...

0 Kudos
Message 58 of 69
(736 Views)

Hi Emanuele,

 

Now I really don't understand your question.  Smiley Happy  Could you rephrase it?

 

Once the data has been enqueued, it remains in the queue until 1) It's dequeued; or 2) the queue reference is released.  It has nothing to do with your IMAQ buffers.  The two are separate.

 

Please take the introduction courses as soon as possible.  Make the time.  I know you say you have a lot of other stuff going on, but make the time.  You shouldn't be too busy to learn how to write your own code!  You're getting too reliant on me to write your code for you.  I realize that's partially my fault since I keep writing code for you...so after this post, I will not write or modify any further VIs for you.  After all, this is your project -- not mine.  Smiley Happy  I've given you a lot of help, and you have been very, very good about saying "thank you" (and I appreciate your excellent manners!).  Now it's time for you to start learning on your own.  You need to understand the code you use, regardless of which one of us wrote it.

 

I did ask you to try to code up the consumer loop "stop" logic yourself, and post what you tried.  I would like to see your effort, so please post it.

 

I know you have been working very hard on this and I commend your effort.  I hope you've learned some things and are excited about LabVIEW!

 

Diane

 

 

0 Kudos
Message 59 of 69
(733 Views)

Dear Diane,

 

The fact is that I didn't understand probably well how a circular buffer works, when I start the acqusition I start filling the circular buffer, i.e. a group of images. When the buffer is full I understood that the program starts to fill the buffer in a circular way, overwriting the images in the buffer, starting from the first one

When I extract the images int the prodecuer loop I have understood that the program takes each time an image from the buffer, starting from the first one: so I think the number of buffer should be set in a way that when the program extracts the n-th of the buffer (say the 50th), this image has not been overwritten... you already explained that, but you didn't tell me how I have to choose the number of buffers, I just would like to know if 100 is enough to avoid loss of data...

 

Please let me know.

Of course I'll try to code the feature by myself.

 

Emanuele

 

 

0 Kudos
Message 60 of 69
(727 Views)