Hi, First I've created a video using
import cv2
import numpy as np
import glob
img_array = []
for filename in glob.glob('C:/Users/mustafa/Downloads/highway/highway/input/*.jpg'):
img = cv2.imread(filename)
height, width, layers = img.shape
size = (width,height)
img_array.append(img)
out = cv2.VideoWriter('project.mp4',cv2.VideoWriter_fourcc(*'DIVX'), 24, size)
for i in range(len(img_array)):
out.write(img_array[i])
out.release()
As you see, I set FPS of video as 24.
Secondly, when I try to use FPS module to measure FPS of video that I've created.
from imutils.video import FPS
import cv2
import numpy as np
cap = cv2.VideoCapture('p.mp4')
fps = FPS().start()
if (cap.isOpened()== False):
print("Error opening video stream or file")
while(cap.isOpened()):
ret, frame = cap.read()
if ret == True:
cv2.imshow('Frame',frame)
fps.update()
if cv2.waitKey(25) & 0xFF == ord('q'):
break
else:
break
cap.release()
fps.stop()
print("[INFO] elapsed time: {:.2f}".format(fps.elapsed()))
print("[INFO] approx. FPS: {:.2f}".format(fps.fps()))
cv2.destroyAllWindows()
I see this output: [INFO] approx. FPS: 38.06 [INFO] elapsed time: 44.67
Also the length of original video is 70 seconds. Why I see different results?