LearnOpenCV
learnopencv.com › home › find frame rate (frames per second-fps) in opencv (python/c++)
Find frame rate (frames per second-fps) in OpenCV (Python/C++)
July 31, 2026 - The documentation says that get(CAP_PROP_FPS) gives the frames per second. Now that is true for video files, but not for webcams. For webcams and many other connected cameras, you have to calculate the frames per second manually.
GeeksforGeeks
geeksforgeeks.org › python › python-displaying-real-time-fps-at-which-webcam-video-file-is-processed-using-opencv
Python - Displaying real time FPS at which webcam/video file is processed using OpenCV - GeeksforGeeks
July 15, 2025 - import numpy as np import cv2 import time # creating the videocapture object # and reading from the input file # Change it to 0 if reading from webcam cap = cv2.VideoCapture('vid.mp4') # used to record the time when we processed last frame prev_frame_time = 0 # used to record the time at which we processed current frame new_frame_time = 0 # Reading the video file until finished while(cap.isOpened()): # Capture frame-by-frame ret, frame = cap.read() # if video finished or no Video Input if not ret: break # Our operations on the frame come here gray = frame # resizing the frame size according to
Top Tech Boy
toptechboy.com › calculating-frames-per-second-fps-in-opencv-and-overlay-on-frame
Calculating Frames Per Second (FPS) In OpenCV and Overlay on Frame | Technology Tutorials
January 26, 2023 - In this lesson we show how to instrument our code to calculate the Frames Per Second (FPS) we are achieving with our camera and OpenCV. We show how to display the FPS as an overlay on our video frame. Python · Accessibility Statement ·
Learning About Electronics
learningaboutelectronics.com › Articles › How-to-find-the-frames-per-second-of-a-video-Python-OpenCV.php
How to Find the Frames Per Second in a Video in Python using OpenCV
In order to make a video human watchable, we need to introduce time delay to slow it down. To know the time delay needed, we calculate it based off the FPS, which can be found according to the formula, T= 1/f. That's why all of this is important. And this is how we can find the frames per second ...
YouTube
youtube.com › watch
Calculate FPS and Average FPS from live video using OpenCV python - YouTube
This is a shorter video of mine on how to calculate the fps of a video using math and opencv and later show it on the frame.
Published: January 4, 2023
YouTube
youtube.com › zubayer hossain
Calculate FPS from live video. Python OpenCV - YouTube
In this video, I show you a simple script to calculate the frames per second of your video feed. Also, I show you how to connect with your webcam if it is a ...
Published: September 2, 2021
Views: 6K
Top answer 1 of 5
58
Here is a very simple way to print your program's frame rate at each frame (no counter needed) :
import time while True: start_time = time.time() # start time of the loop ######################## # your fancy code here # ######################## print("FPS: ", 1.0 / (time.time() - start_time)) # FPS = 1 / time to process loopIf you want the average frame rate over x seconds, you can do like so (counter needed) :
import time start_time = time.time() x = 1 # displays the frame rate every 1 second counter = 0 while True: ######################## # your fancy code here # ######################## counter+=1 if (time.time() - start_time) > x : print("FPS: ", counter / (time.time() - start_time)) counter = 0 start_time = time.time()
Hope it helps!
2 of 5
7
Works like a charm
import time
import collections
class FPS:
def __init__(self,avarageof=50):
self.frametimestamps = collections.deque(maxlen=avarageof)
def __call__(self):
self.frametimestamps.append(time.time())
if(len(self.frametimestamps) > 1):
return len(self.frametimestamps)/(self.frametimestamps[-1]-self.frametimestamps[0])
else:
return 0.0
fps = FPS()
for i in range(100):
time.sleep(0.1)
print(fps())
Make sure fps is called once per frame
SunFounder
docs.sunfounder.com › projects › raphael-kit › en › latest › python_video › video_47_fps.html
Video 47: Calculating Frames Per Second (FPS) In OpenCV and Overlay on Frame — SunFounder Ulimate Raphael Kit for Raspberry Pi documentation
FPS Calculation: Demonstrating how to measure frame processing time to calculate FPS. Camera Parameter Setting: Using OpenCV to set camera parameters such as resolution and FPS.
YouTube
youtube.com › watch
How to add FPS to video and live in Opencv Python | Calculate frames per second - YouTube
How to calculate and add FPS to video in opencv python is shown#opencv
Published: October 21, 2022
OpenCV Q&A Forum
answers.opencv.org › question › 145530 › fps-how-to-divide-count-by-time-function-to-determine-fps
fps - how to divide count by time function to determine fps [closed] - OpenCV Q&A Forum
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 ...
ProgramCreek
programcreek.com › python › example › 89372 › cv2.CAP_PROP_FPS
Python Examples of cv2.CAP_PROP_FPS
def clahe(filename): os.chdir(os.path.dirname(filename)) print('Applying CLAHE, this might take awhile...') currentVideo = os.path.basename(filename) fileName, fileEnding = currentVideo.split('.',2) saveName = str('CLAHE_') + str(fileName) + str('.avi') cap = cv2.VideoCapture(currentVideo) imageWidth = int(cap.get(3)) imageHeight = int(cap.get(4)) fps = cap.get(cv2.CAP_PROP_FPS) fourcc = cv2.VideoWriter_fourcc(*'XVID') out = cv2.VideoWriter(saveName, fourcc, fps, (imageWidth, imageHeight), 0) try: while True: ret, image = cap.read() if ret == True: im = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
GitHub
gist.github.com › barisx › 34f58b4010b0d86b3afe577f458e4788
Detect video fps with OpenCV - Python · GitHub
Detect video fps with OpenCV - Python · Raw · get_fps.py · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
YouTube
youtube.com › data magic (by sunny kusawa)
How to check FPS using OpenCV | Frames Per Seconds | Video FPS | Machine Learning | Data Magic - YouTube
Hello Friends, In this vide, I will quickly show, How to check Frames Per Second(FPS) of any Video or Live stream using OpenCV.GitHub: https://github.com/dat...
Published: June 3, 2022
Views: 3K
GitHub
gist.github.com › Nannigalaxy › 0fbe211b11950d49c2085c8d8e79eb3f
Simple Webcam Video Streaming with FPS count using OpenCV Python 3 · GitHub
Simple Webcam Video Streaming with FPS count using OpenCV Python 3 - opencv_webcam.py
OpenGenus
iq.opengenus.org › number-of-frames-in-video-using-opencv
Calculate Number of frames in video using OpenCV
May 24, 2022 - Import OpenCV as we will use it to get the number of frames in a video: ... The property CAP_PROP_FRAME_COUNT in OpenCV stores the number of frames in a video. Fetching this value will give us the total number of frames in the video: number_of_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) ...
Blogger
kieleth.blogspot.com › 2014 › 03 › opencv-calculate-average-fps-in-python.html
Kieleth: OpenCv, calculate average fps in python
March 30, 2014 - def circular_counter(max): """helper function that creates an eternal counter till a max value""" x = 0 while True: if x == max: x = 0 x += 1 yield x class CvTimer(object): def __init__(self): self.tick_frequency = cv2.getTickFrequency() self.tick_at_init = cv2.getTickCount() self.last_tick = self.tick_at_init self.fps_len = 100 self.l_fps_history = [ 10 for x in range(self.fps_len)] self.fps_counter = circular_counter(self.fps_len) def reset(self): self.last_tick = cv2.getTickCount() def get_tick_now(self): return cv2.getTickCount() @property def fps(self): fps = self.tick_frequency / (self.get_tick_now() - self.last_tick) self.l_fps_history[self.fps_counter.next() - 1] = fps return fps @property def avg_fps(self): return sum(self.l_fps_history) / float(self.fps_len) In your frame-by-frame while loop: