1 | initial version |
You wanted to count frame by frame?
#!/usr/bin/python3.7
import cv2
cap = cv2.VideoCapture("road.avi")
fps = cap.get(cv2.CAP_PROP_FPS)
Frames = cap.get(cv2.CAP_PROP_FRAME_COUNT)
frame_counter = 0
frame_by_frame=[]
while cap.isOpened():
ret, frame = cap.read()
frame_by_frame.append(frame_counter)
print(f'number of frames: ' + str(len(frame_by_frame)))
cv2.imshow('frame', frame)
if cv2.waitKey(1) == ord('q'):
cap.release()
cv2.destroyAllWindows()
2 | No.2 Revision |
You wanted to count frame by frame?
#!/usr/bin/python3.7
import cv2
cap = cv2.VideoCapture("road.avi")
cv2.VideoCapture('video.wmv')
fps = cap.get(cv2.CAP_PROP_FPS)
Frames = cap.get(cv2.CAP_PROP_FRAME_COUNT)
frame_counter = 0
frame_by_frame=[]
while cap.isOpened():
ret, frame = cap.read()
frame_by_frame.append(frame_counter)
print(f'number of frames: ' + str(len(frame_by_frame)))
cv2.imshow('frame', frame)
if cv2.waitKey(1) == ord('q'):
cap.release()
cv2.destroyAllWindows()
3 | No.3 Revision |
You wanted to count frame by frame?
#!/usr/bin/python3.7
import cv2
cap = cv2.VideoCapture('video.wmv')
fps = cap.get(cv2.CAP_PROP_FPS)
Frames frames = cap.get(cv2.CAP_PROP_FRAME_COUNT)
frame_counter = 0
frame_by_frame=[]
while cap.isOpened():
ret, frame = cap.read()
frame_by_frame.append(frame_counter)
print(f'number of frames: ' + str(len(frame_by_frame)))
cv2.imshow('frame', frame)
if cv2.waitKey(1) == ord('q'):
cap.release()
cv2.destroyAllWindows()