AIRLegend / aitrack

6DoF Head tracking software
MIT License
1.04k stars 105 forks source link

Make the framerate for steady by sleeping only for the remaining allowed time #93

Closed Hugal31 closed 3 years ago

Hugal31 commented 3 years ago

Instead of sleeping 1000 / state.video_fpsms (e.g. 33 or 16ms) each frame after the prediction, sleep for the remaining allowed time.

For example, if we are running at 30 fps, the allowed time is approximately 33ms. If the frame fetching takes 2ms, and the prediction takes 10ms, only sleep for 33 - (2 + 10) = 21ms at the end of the loop.

AIRLegend commented 3 years ago

Nice addition. Thanks! :)

One silly thing. Could you change the variable names to snake case in order to maintain consistency with the rest of the file?

Hugal31 commented 3 years ago

Oops! Sure thing, here it is.

AIRLegend commented 3 years ago

Awesome, thanks!