Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
989 B
2
Indexable
Never
# import the opencv library
import cv2
import time
  
# define a video capture object
vid = cv2.VideoCapture("test.mp4")
start_time = time.time()
x = 1 # displays the frame rate every 1 second
counter = 0
while True:
    # Capture the video frame
    # by frame
    start_time2 = time.time()
    ret, frame = vid.read()
    #frame= cv2.resize(frame, (300,300) , interpolation = cv2.INTER_AREA)
    
    print((time.time() - start_time2)*1000)
    counter+=1
    if (time.time() - start_time) > x :
        print("FPS: ", counter / (time.time() - start_time))
        counter = 0
        start_time = time.time()
    # Display the resulting frame
    cv2.imshow('frame', frame)
    # the 'q' button is set as the
    # quitting button you may use any
    # desired button of your choice
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
    
  
# After the loop release the cap object
vid.release()
# Destroy all the windows
cv2.destroyAllWindows()