From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Text Overlay on AVI while keeping high frame rate issues

Hello,

 

I have a program where a small portion of it records images and saves them as an AVI. We have added a text overlay of "elapsed cycles" to the AVI to be able to correlate the images with other data we are collecting. This works fine, except our frames which we are saving per second has decreased drastically. Before we added the text overlay we were getting 12-15 fps, and now with the text overlay we only get 2-3. I need to be able to do the text overlay but keep the high frame rate. I have also attempted to do a producer consumer loop, but it made it worse. I have attached screenshots of both implementations. Unfortunately this snippet is part of a larger project and cannot be posted. 

 

Any help would be greatly appreciated! 

Download All
0 Kudos
Message 1 of 7
(2,415 Views)

If rendering the overlay takes so much time, couldn't you just display the overlay text in an extra string indicator underneath the .AVI display?

0 Kudos
Message 2 of 7
(2,382 Views)

As I'm sure you know, the current set of AVI VIs, called AVI2, released with LabVIEW 2012 SP1, do not support bundling text data with images.  However, the legacy AVI functions are still available, along with at least one Example program shipping with LabVIEW 2018.

 

My recommendation would be to create a small, stand-alone program to write a short (10 second) AVI file that incorporates text.  Whether or not you are successful, reply to this stream, attaching all of the LabVIEW Code you used to create your example, and the resulting AVI (if you were successful).  You should include timing information (put some Millisecond Clocks in your code so we can see how long it takes to actually write the AVI and get an accurate count of the frame rate).  Finally, provide some of the particulars of your camera and Image, including frame rate, image format (RGB?  8-bit Grey?), and pixel size.  Please do not reply without providing us with something to work with!

 

Bob Schor

0 Kudos
Message 3 of 7
(2,375 Views)

Hello, So here I have attached a stand alone working version of my camera with text overlay setup. The only difference is that normally the text being overlayed is a variable being changed and incremented elsewhere in the larger application. We are using a Grasshopper 3 camera, model # Gs3-U3-28S4M-C. It records at a frame rate of 26fps. 

 

I am just looking for a way to overlay text on the recorded frames saved to .AVI with a high frame rate. Thanks. 

0 Kudos
Message 4 of 7
(2,363 Views)

I need the text on the saved .AVI and I don't think this would do that?

0 Kudos
Message 5 of 7
(2,362 Views)

If rendering the overlay takes so much time, couldn't you just display the overlay text in an extra string indicator underneath the .AVI display?

 
wrote:

I need the text on the saved .AVI and I don't think this would do that?


sorry, I must have over-read that.

 

 

 

 

0 Kudos
Message 6 of 7
(2,353 Views)

Thank you for attaching your VI.  I now see that I mis-understood what you were trying to do, and was wrong in my earlier statement.  I haven't used Merge Overlays, but I have some ideas I'll test and if I'm wrong, I'll come back and correct them!

 

The main problem that you have is that you have two processes that need to take place in parallel -- getting images from a Camera (which happens at the frame rate of the Camera) and saving those Images, with additional Overlays, to an AVI file.  You want two loops -- one only taking images and saving them in the Camera's buffer (more on that in a moment) and the other taking those images, adding the overlay, and writing the AVI to disk.

 

The "ordinary" Producer/Consumer loop uses a Queue to pass data from the Producer to the Consumer.  However, you are working with LabVIEW Video (IMAQdx), and its concept of Images and Buffers and all those things.

 

You used the generic Configure Grab.  You probably don't know this, but you configured the IMAQdx Driver to allocate 5 image buffers and told it to acquire images continuously, using the 5 buffers inside the driver as "temporary storage".  Successive images go into Buffers 0, 1, 2, 3, 4, 0, 1, 2, 3 ..., so 5 frames later, the first Image has been overwritten.

 

So what do you need to put in the Queue?  Only the Buffer Number that the Camera uses (it counts 0, 1, 2, 3, 4, 5, 6, 7, "silently" overwriting old images stored in its finite set of buffers).  The Camera says "I just put an Image in Buffer 123, better get it before I overwrite it", and the Consumer processing the Image grabs the contents of Buffer 123 and does its overlay/AVI thing.

 

Given an Image (have you told us the size of the Image, and the type, e.g. RGB, 8-bit GreyScale, etc.?), it will take a bit of time to make the Overlay and Merge it (you might have slightly mis-wired the Merge VI).  Can you do this in 30-40 msec?  Don't know, depends on your Image parameters and the speed of your PC.  There's also writing the Image to disk, of course ...

 

So, there's some Good News, this is probably possible.  You'll want to use a Producer/Consumer Design to allow Image Processing to overlap with Image Acquisition, and may need more buffers (how long a Video are you taking, and at what Frame Rate?  In other words, how many total Frames are you processing at once?).  There's some Bad News, you need to learn more about IMAQdx and cameras, and the knowledge is a little hard to come by.

 

Bob Schor

0 Kudos
Message 7 of 7
(2,336 Views)