I have the following code in which I am reading data from folder, I want to limit the number of frame rate to 5fps, 10fps,15fps,20fps,25fps being read from a folder. When I run below code my code is hanged and I doubt the below approach I am using is not correct.
filenames = [img for img in glob.glob("video-frames/*.jpg")]
fps = 5
#calculate the interval between frame.
interval = int(1000/fps)
filenames = sorted(filenames, key=os.path.getctime) or filenames.sort(key=os.path.getctime)
images = []
for img in filenames:
n= cv2.imread(img)
time.sleep(interval)
images.append(n)
print(img)
Help is highly appreciated if someone would help me in this regard.