06-25-2009 06:32 PM
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
Solved! Go to Solution.
06-25-2009 07:31 PM
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.
06-26-2009 07:03 PM
06-26-2009 07:56 PM
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