Items with no label
3338 Discussions

How can I get the fps value?

idata
Employee
2,267 Views

Hi,

I realized that when I have a high computational cost in my program, the fps reduced its value. I wondered if I can get the fps value instantly.

Thanks in advance!

7 Replies
MartyG
Honored Contributor III
1,049 Views

This article has some downloadable source code that may give you insight about how to monitor the frame rate.

https://software.intel.com/en-us/videos/intel-realsense-unity-5-pro-tip-monitor-the-realsense-frame-rate RealSense - Intel® RealSense™ + Unity* 5 Pro Tip: Monitor the RealSense Frame Rate | Intel® Software

0 Kudos
jb455
Valued Contributor II
1,049 Views

If you just want to check the frame rate for debug purposes, you could put a System.Diagonstics.Stopwatch (assuming C# ) on to time each frame, adding each stopwatch.ElapsedMilliseconds to a List and calling stopwatch.Reset() at the end of each frame. I've used this method for identifying parts of my camera loop which were causing slowdowns and required optimisation. If you want FPS rather than milliseconds, you can do 1000/ElapsedMilliseconds to get the maximum frame rate (eg, if your camera loop takes 50ms, the maximum frame rate would be 1000/50 = 20fps)

idata
Employee
1,049 Views

Thanks jb455, but I'm working in c++. I was asking for some function that get me that value.

Anyway I'm going to try your solution

0 Kudos
jb455
Valued Contributor II
1,049 Views

The C++ Raw Streams sample has an FPS counter along the bottom of the screen - if you look in the source code you should be able to work out how they do it!

0 Kudos
idata
Employee
1,049 Views

Hi MQMQ,

 

 

Do you still need assistance with this thread? Keep us updated on your progress.

 

 

-Sergio A

 

0 Kudos
idata
Employee
1,049 Views

Hi Sergio,

I tried to do the jb455's solution but I'm not was able.

In the RAW example there are some functions and I tried to use one of them but it doesn't work.

My code:

int frame = FaceTrackingFrameRateCalculator::GetFrameRate();

int FaceTrackingFrameRateCalculator::GetFrameRate()

{

isFrameRateReady = false;

return frameRate;

}

0 Kudos
idata
Employee
1,049 Views

Perhaps the answer is on using generic C++ code instead of focusing on the SDK. For example, you can try something similar to what is explained on these guides:

 

 

https://noobtuts.com/cpp/frames-per-second

 

http://www.opengl-tutorial.org/miscellaneous/an-fps-counter/

 

 

Pedro M.
0 Kudos
Reply