Ask Your Question

fps - how to divide count by time function to determine fps [closed]

asked 2017-05-03 08:03:50 -0500

Sinjon gravatar image


I have a counter working that counts every frame. what I want to do is divide this by time to determine the FPS of my program. But I'm not sure how to perform operations on timing functions within python.

I've tried initializing time as

fps_time = time.time 
fps_time = float(time.time)
fps_time = np.float(time.time)
fps_time = time()

Then for calculating the fps,

FPS = (counter / fps_time)
FPS = float(counter / fps_time)
FPS = float(counter (fps_time))

But errors I'm getting are object is not callable or unsupported operand for /: 'int' and 'buildin functions'

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2017-05-03 08:07:50.573219



definitely NOT an opencv problem. you're just bad at python in general.

and it's: seconds = time.time()

berak gravatar imageberak ( 2017-05-03 08:08:57 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-05-03 08:19:24 -0500

pi-null-mezon gravatar image

To get an fps you should divide the so called tick-frequency (how many ticks processor makes at a second) on the task tick-count (how many ticks processor has spended to mske a particualr task).

In C++ API it will be:

 unsigned long tickmark = cv::getTickCount(); // update current tick count 
   while(true) {
      fps = cv::getTickFrequency()/(cv::getTickCount() - tickmark); // fps in Hz (1/s)
      tickmark = cv::getTickFrequency(); 
edit flag offensive delete link more


tickmark = cv::getTickCount();

berak gravatar imageberak ( 2017-05-03 08:39:00 -0500 )edit

Sweet thanks! I changed it for python and got the following results which dont seem correct to me...

tickmark = cv2.getTickCount()


And for
tickmark = cv2.getTickFrequency()


Sinjon gravatar imageSinjon ( 2017-05-03 10:03:53 -0500 )edit

Question Tools

1 follower


Asked: 2017-05-03 08:03:50 -0500

Seen: 521 times

Last updated: May 03 '17