Search code examples
androidandroid-cameraframe-rateandroid-camera2

Accurate way to measure fps on Android camera


I've tried 2 different methods to calculate fps:

  1. Find frame time difference by SystemClock.elapsedRealtime() and fps = 1000 / timeDiff
  2. Find time difference since the start divided by the number of frames grabbed.

Observation

  1. Method 1: fps fluctuates like crazy, it can jump from 15 to 40 then down to 20, before jumping to 30, and so on.
  2. It's like more stable( I can see it ~ 30fps ) but it doesn't reflect the latest fps because it's just the long run average fps.

My question is what is the best formula to calculate the fps?

ps: I'm using Camera2 interface.

Thanks.


Solution

  • Do the first method however average over the last 10 frames (or 5 frames, it is a matter of taste, but do not average over a long range). This way it is less prone to fluctuations.

    Method 2 will hide in my opinion many local subtleties and you wind up killing all details by that massive averaging.