LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to enforce a camera to run at CONSTANT FPS?

Dear users:
 
I am using the IMAQ: The Grab and Attributes Setup example VI for acquiring an uncompressed AVI movie with a frame rate of 30 fps. As far as I can tell I am obtaining 30 fps. However, the frame rate indicator on the front panel fluctuates between 28-31 frames per second. My question is now how do i enforce my camera to have EXACTLY 30 fps so I do not loose any frames. Is there a setting i can adjust on my camera in the VI that enforces this restriction?
 
Does this have to do anything with the CalculateFPS.vi. The update interval in that VI is by default 1000. Does it help if I set it to 0?
 
The camera I am utilizing is DMx 21BF04 camera from the Imaging Source (Mono8 at 30 fps, 640 x 480). Please note that I want to make the mentioned task entirely in IMAQ and not utilize the VIs given by the company.
 
Thanks
0 Kudos
Message 1 of 11
(6,530 Views)
Hi,

If you open up the CalculateFPS vi you will see that it is based on time stamp in software.  So it is not going to be exactly when the image was acquired in hardware.  But there are several ways to set a framerate.  Several cameras will let you set the frame rate in the camerafile.  What camera are you using?  Also what frame grabber are you using with it? 
Another way to control when the rate at which images are acquired is to do triggered acquistion.  This enables you to select when each image is going to be acquired.  If you are setting up all of your acquisiton in software then it won't be as accurate, because an image will be acquired as soon as the software is ready for the next image. You may want to consider using the LL ring example that collects images

But there aren't any Vi's that allow you to set a certain framerate in software.  I hope this helps.

Have a good day,

GG
0 Kudos
Message 2 of 11
(6,505 Views)

Hi,

 

I am trying to develop a VI that will acquire video from a usb 2 webcam. The camera is used via directshow. I am using IMAQdx VI's. I would like to save the videos in AVI files. I tried the code at the beginning saving 3-5 seconds of videos. The camera is set up to sample video at 30 FPS.

 

I would like to check what is the actual frame rate. How can I do that? I need to synch the videos with some analog data and I was to make sure the videos are sampled properly.

 

Also, when I increased the duration of the videos to 30 s. the saving time increased tremendeously. Is there a way that I can save chuncks of video periodically without losing any frame?

 

Can anyone please advise?

 

Thank you, Massimo.

0 Kudos
Message 3 of 11
(5,627 Views)

Hi Massimo,

 

You could use a producer consumer architecture to acquire and save your images. This will acquire images in one loop and save the images in another loop, eliminating the worry about the time to save to an AVI file. Please check out the example below, I believe it may help.

 

NI-Vision Image Processing with Producer/Consumer Loops
http://zone.ni.com/devzone/cda/epd/p/id/5859

 

Tim O

Applications Engineer
National Instruments
0 Kudos
Message 4 of 11
(5,606 Views)

Hi Tim,

 

thank you! That code is very cool. I have seen something similar elsewhere, in another post but some people have argued about the queing approach, which in the solution you suggested to me is used much more effectively. It runs fine but in my application I need to ensure consistent frame rate and any solution I came across so far doesn't guarantee that. I have an idea that I need to try out and test. I have tried so many version that I think I have a good grasp (at least I think) of what are the pros and cons of the different solutions I have tried. I really like the way the saving as AVI is implemented in the solution you sent me and I will definitely steal it and put it in my final version.

 

If it is not to much to ask, I will post my tentative final solution so that maybe you can see what I did to ensure constant frame rate.

 

I will post something very soon.

 

Thank you again,

best, Massi.

0 Kudos
Message 5 of 11
(5,598 Views)

Hi Massi,

 

To ensure exact frame rates from a camera you would need to use triggering. DirectShow (the USB driver) does not support triggering; you would have to uses a different interface to ensure exact timing. I am not saying you cannot achieve a steady frame rate, I am just letting you know your timing will ultimate be dependent by Windows and the DirectShow driver.


Choosing the Right Camera Bus
http://www.ni.com/white-paper/5386/en

 

Tim O

Applications Engineer
National Instruments
Message 6 of 11
(5,582 Views)

Hi everyone,

 

I've got the same problem.

I am using a code based on LL Grab example, and even if I set a frame rate for the camera with an external trigger, the indicator reutrns values which are always smaller than the one I set.

So I would like to ask you two questions:

 

1) how can I estimate the actual frae rate at which the camera is acquiring images

2) do you have any particular advice to enforce a frame rate?

 

Thank you for your time. If you solved the problem, you might already have these answers.

Regards,

 

Emanuele

0 Kudos
Message 7 of 11
(5,563 Views)

Hello,

Did you checked that the exposure time of your camera is lower than the trigger interval.

By selecting a shorter exposure time, your camera will be able to reach higher fps. But depending on the camera specs, you are limited by the physical fps of your camera.

Then, for some cameras you can find with a property node some parameters that allows you to set constant frame rate CFR.

 

Regards

 

0 Kudos
Message 8 of 11
(5,560 Views)

Yes I checked it, my exposure time is about 33ms whereas my set frame rate is 100ms, therefore it should work, but if I for example grab images using the VI example HL grab, I don't get the requested frame rate! Why is it so? Is it because the frame rate computation inisde HL grab is based on a time stamp software? How can I check it otherwise?

0 Kudos
Message 9 of 11
(5,547 Views)

I have used as the fram rate the value which is reported on the indicator in HL grab

0 Kudos
Message 10 of 11
(5,546 Views)