LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

video acquisition framerate

Solved!
Go to solution

Hello,

I've been trying to acquire images from a camera at 30 fps for time-sensitive image processing. Currently I have a while loop with imaq grab acquire wired to imaq avi write frame. The loop timing is controlled by a wait (ms) function. Obviously the framerate is dictated by the loop timing, which is my main problem. For 30 fps, it is 33.333333 ms per frame which causes a rounding error within the loop timing. Thus, I am getting more frames than I should because it is grabbing frames slightly faster than it should be.

 

I'm sure many others have solved this problem, but the solution is not apparent to me. So does anyone know how to properly control the framerate?

 

Thanks

-TJ

0 Kudos
Message 1 of 4
(3,642 Views)

often you can set the frame rate in the camera settinge, then grab in the loop as fast as the camera is test to grab.  Look in max at the camera properties, the frame rate is usually aq property.  If timimg is super critical I also look at triggered mode and use a clock in for timing (also good for synchronizing.

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 4
(3,636 Views)
The clock in for timing is still millisecond based. This isn't a problem for acquiring short videos but for a movie that needs to be 120 seconds long, the 33.33 ms rounding does not work. In MAX the settings for the camera cannot be adjusted (or atleast my understanding of them, and it states that the camera is capturing at about 59.94 fps). In the LabVIEW help files it states that a 33 ms time delay corresponds to 30 fps. Now do the math: 33 ms per frame X 30 frames = 990 ms. So in less than a second 30 frames have been captured. After a minute of capturing I have 1798 frames and a movie duration of 59.9 s. I'm no expert but I see a gap in the timing and fps.
0 Kudos
Message 3 of 4
(3,613 Views)
Solution
Accepted by topic author TJ_Reed

TJ-

 

It looks like the bind you are in is because the OS (all PCs actually) and the camera only have a 1kHz clock, so you are stuck with 1ms intervals.  In software, there are always many ways so here you go:

 

Hack solution:

Vary the time of your delay loops:  33,33,34,33,33,34,...  This fixes your round off error, but will give you up to 0.6666ms dither in your signals.

 

Better hack solution:

Feedback to vary the time of your delay loops:  run a timer and use that to set the timing to either 33 or 34 depending on where your <1ms rounding error is at that particular time.

 

Expensive, best solution:

Get a camera you can set the timing in hardware.

 

Best solution with what you've got:

Get off of the windows 1ms timer.  The structure to use is a timed loop (under timed structures in the structures panel).  It will default to your Windows 1ms timer, but you can use any hardware timing you have.  One of your boards will likely have a 1MHz timer, which will improve your timing and dither issues by 1000x.  If you still need more, you can then use some of the hacks above.  

 

Ultimately this is a hardware problem and would be 'best' solved in hardware.  However, there are always lots of ways to do it.  In fact, I'm sure the NI gurus can come up with many more.

 

Best of luck.  Play around with these fixes and keep learning,

Casey

 

0 Kudos
Message 4 of 4
(3,608 Views)