-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathFPS.py
More file actions
24 lines (20 loc) · 697 Bytes
/
Copy pathFPS.py
File metadata and controls
24 lines (20 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import time
import cv2
class FPS: # To measure the number of frame per second
def __init__(self):
self.nbf=0
self.fps=0
self.start=0
def update(self):
if self.nbf%10==0:
if self.start != 0:
self.stop=time.time()
self.fps=10/(self.stop-self.start)
self.start=self.stop
else :
self.start=time.time()
self.nbf+=1
def get(self):
return self.fps
def display(self, win, orig=(10,30), font=cv2.FONT_HERSHEY_PLAIN, size=2, color=(0,255,0), thickness=2):
cv2.putText(win,f"FPS={self.get():.2f}",orig,font,size,color,thickness)