LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to save every image with high fps

Hi everyone!

I want to use LabVIEW to acquire and save images from my Basler camera. 

The problem now is I need to acquire images with a high fps (say 50 fps), and save every acquired frame. But when I start saving images, the actual fps would be much lower than the fps I needed. The attachment is my VI. Does anyone have some good solutions to this problem?

0 Kudos
Message 1 of 22
(6,135 Views)
I can't look at your code right now, but if you are acquiring data at a higher rate than you can process on the fly, you need to be looking at buffering. How long do you need to be acquiring data at a high frame rate?

Also, what kind of image? On the whole 50 fps doesn't strike me as being that high.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 22
(6,124 Views)

Hi Mike,

The acquiring time could be around 10 secs, and the image format is PNG. I'm now looking at the answer of "Save Sequence Images with a given timing" and hope it could help.

Thank you

 

0 Kudos
Message 3 of 22
(6,114 Views)

I had a look at your VI. You use a producer/consumer pattern, which is good. However, I can see several possible problems, and one of them might be the cause of the problem what you see.

So I try to list what I see as problems/design flaws:

 

  1. Using the "Not OR" logical operation with a combination of the "Continue if True" WHILE loop setting is a kind of funny. Just use a Stop button plus the error wire bundled with a logical OR operation, connected to the normal "Stop if True" conditional terminal of the WHILE loop, as you did in the bottom loop.
  2. Use the error wire info coming out from the "Dequeue Element" to stop the bottom loop, and not the error from the File write function. A better stopping mechanism would be better (like using a command+data cluster in the Queue), but for first step it is ok in this way...
  3. The part which I think causes slow acquisition: I never used IMAQ, but as I see, you have the "IMAQdx Start Acquisition.vi" inside the top while loop. I guess it does some initialisation on your HW, so the big problem here is that, you initialise your hardware at EVERY loop iteration. This can cause slow performance. Remove this function from inside the loop, and put it BEFORE the loop, initialise only once.
0 Kudos
Message 4 of 22
(6,098 Views)

Another thing to think about is how many Camera Buffers you have.  You need enough so that the Camera can fill the "next buffer" while you are trying to access the "last buffer".  I've not tried writing multiple PNGs at 50 fps, but I've successfully saved AVIs at 30 fps from 24 cameras more-or-less simultaneously (I saved 10 second short videos when "interesting events" happened, which occurred asynchronously among the 24 stations.  It was probably not the case that all 24 "fired" at once, but certainly all cameras were capturing video at 30 fps, and undoubtedly 2-4 video streams were being saved simultaneously).

 

Bob Schor

0 Kudos
Message 5 of 22
(6,053 Views)

It will probably be a little faster if you don't display the image. What resolution are your images?

 

On your acquisition VI you have "Release previous" set to TRUE. If you are queuing up images to be saved, you probably want to set that to false. The biggest one will probably be to move the "begin acquisition" before the loop as suggested before.

 

Have you streamed this camera at 50fps in LabVIEW before, or is that just a goal?

0 Kudos
Message 6 of 22
(6,050 Views)

I would say streaming to video file is faster than writing to PNGs. It does not require creating additional file on every step, also quality / size of images should be better. Is there a reason to work with PNGs, not video?

Message 7 of 22
(6,027 Views)

So the last two posts raise the question of how fast can one write PNGs.  I'd also thought "Why not AVIs", but I didn't know if "information" was lost in going from PNGs to AVIs (like compression losses).

 

So I did a test.  I opened a PNG as a U8, then (in a For loop) wrote 100 new PNGs called Test000 through Test099.  Took 1.09 seconds, or about 90 frames/second.  So, yes, it should be possible to save PNGs at 50 fps ...

 

Bob Schor

0 Kudos
Message 8 of 22
(6,013 Views)

Thank you Blokk,

I have accepted your advices and now I have moved the Release the Queue VI to the outside of the consumer loop, so that I can save every buffered image even after I close the camera. The frame rate now could achieve the highest of the camera and I can save all the images.

But now the problem is I can't find a suitable way to stop the consumer loop (I want the loop to stop by itself after all the buffered images have been saved).

 

0 Kudos
Message 9 of 22
(5,971 Views)

Thank you Alexander,

I saved to PNG file is because I want to deal with the images frame by frame. Is it possible to save as video file and then I can extract images from the video without losing any frame and the quality wont be degraded?

0 Kudos
Message 10 of 22
(5,961 Views)