LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to save every image with high fps

Hi gregoryj,

The resolution of my images is 659X494, I think the resolution is quite low.

As I'm a new user of LabVIEW, I'm not quite familiar with setting the image acquisitions. How can I set the "Release Previous" to be false?

Now I have achieved the desired frame rate and managed to save the buffered images using the Producer/Consumer Loops. A small change is that I release the queue outside the Consumer Loop so that I can save the images after the camera is closed.

The attachment is my renewed VI, maybe you are interested in it.

0 Kudos
Message 11 of 22
(2,141 Views)

I have accepted your advices and now I have moved the Release the Queue VI to the outside of the consumer loop,

 

I did not tell you to do this, I think you got confused a bit 🙂 You should really go through some learning material 🙂 I think you wanted to write not "Release Queue", but the "Start Acquisition"?

 

The "Release Queue" function was never inside the consumer loop, at least not in your first attached VI 🙂

You do this in the wrong way.

  • Put the "Release Queue" back to the top loop, but after the loop. When you stop the top loop, you Release the Queue reference, which will create an error in the bottom loop, and stop its running.
  • Delete the "Get Queue Status" function, you do not need it.
  • you can also put a case structure around the PNG save function, so when you get the Queue error, you do not save false data (but this is not clear, i do not have imaq)
  • Move the Image indicator ("Image Out 2") from the Producer loop to the bottom, to the Consumer loop!

Do something like this:

 

Test_ContinuousImage_v1-1.png

 

 

 

 

 

 

 

 

0 Kudos
Message 12 of 22
(2,129 Views)

Thank you Bob,

I don't know whether I can extract the images from AVI file without losing frames or the quality. Maybe I can try streaming to a video file and see the difference.

 

0 Kudos
Message 13 of 22
(2,125 Views)

Ok, here are some comments.  Don't take them too badly -- when I first started doing things with IMAQdx, I was totally confused on the concept of an "Image" (due, largely, to the lack of documentation -- even now, the best I've seen is a book written more than a decade ago, before IMAQdx was released ...).

 

First, you want to sample for 10 seconds at 50 frames/sec.  You allocate a buffer of 1000 images, which is enough for your entire record.  Therefore you do not need to worry about Producer/Consumer -- simply pass all of the Images from the Extract Image function to an Indexing Tunnel.  When you stop the Camera, take all of those images into a For loop and write them, one at a time, to a PNG file.  Very simple.

 

If you want to take advantage of LabVIEW's parallelism and use Producer/Consumer to do acquisition and saving at the same time, you can use your present formulation, but drastically reduce the number of buffers (I'd guess you would need no more than 50, 1 seconds worth, to handle start up lags).

 

The question of image quality between PNG and AVI is an interesting one -- certainly, the AVI cannot have a higher image quality, but it can probably save images faster (but that's not a problem you have).

 

Your Consumer loop has a Queue Status function that isn't doing anything.  There is also no obvious way to stop the Consumer loop.  Something that you might consider -- as you've configured it, both loops start at the same time, and you end the Producer loop, which means that the Consumer will (eventually) run out of things to "consume".  Wire a 100 msec timeout into the Consumer's Dequeue function.  Put the rest of the code inside the False limb of a Case statement (so you only make a PNG if the Dequeue did not time out), and set the True limb to generate a True wired to the loop's Stop indicator.  This will cause the Consumer loop to run as long as the Producer is sending images, and when it stops, the Consumer will exit (after 100 msec), destroy the Queue (which is no longer needed) and you are done.

 

Bob Schor

0 Kudos
Message 14 of 22
(2,111 Views)

Hi Blokk,

The problem is that if I put the "Release Queue" VI on the top loop, then the queue will be released right after I close the camera, and there would be some elements in the queue which haven't been saved. But if I put the "Release Queue" VI on the bottom loop, then I can save the whole queued images after I stop acquisition. Will it cause problems if I release the queue on the bottom loop?

0 Kudos
Message 15 of 22
(2,108 Views)

Your IMAQdx Extract Image.vi has the bottom input "Release Previous". But if you are getting all the images, then perhaps you don't have to wire a False a constant to this.

 

I actually prefer the Release Queue wired from the bottom loop, but you have to have some kind of case structure to determine when to stop the loop. My queue data is often a cluster of a string and a variant, which is very flexible and I make the string value "Exit" with a corresponding shutdown case in the consumer loop. Also, the Get Queue Status is not doing anything down in the consumer loop. The way you have it now, the consumer loop should never stop.

0 Kudos
Message 16 of 22
(2,100 Views)

read the post from Bob_Schor.

A more elegant way to send a stop command with the Queue, use a cluster with a string/enum command beside the data elements.

0 Kudos
Message 17 of 22
(2,091 Views)

I meant to ask -- I see that your code asks the camera for its frame rate, but I don't see where you (programmably) set it.  Have you manually configured the camera for 50 fps?  Is that the rate that it actually seems to use?

 

Bob Schor

0 Kudos
Message 18 of 22
(2,083 Views)

Well, we all seem to agree that you need some way to "nicely" stop the Consumer loop, unless, of course, you take my first suggestion and simply use all of your buffers and change from a parallel to a serial format, acquire all the images, then save them all.

 

BS

0 Kudos
Message 19 of 22
(2,081 Views)

Thank you Bob,

I now know that it's a better way for me change the format to a serial pattern because I don't need to acquire and save the images simultaneously. 

The attachment is the VI I changedSmiley Happy

 

0 Kudos
Message 20 of 22
(2,062 Views)