I have several video and I want to go through them frame by frame, and annotate some of them by pressing a keyboard key (which depends on the frame). For many of the frames I won't press any key. Here is what I have so far:
import numpy as np
import cv2
cap = cv2.VideoCapture('video.mp4')
frame_number = []
annotation_list = []
i = 0
while(True):
# Read one frame.
ret, frame = cap.read()
# Show one frame.
cv2.imshow('frame', frame)
# Set the time between frames in miliseconds
c = cv2.waitKey(500)
i = i + 1
try:
annotation_list = annotation_list + [chr(c)]
frame_number = frame_number + [i]
except:
continue
So this is showing each frame for 0.5 seconds, and associates to each frame where I press a button, the given letter. What I need now is an option such that for a given frame I can stop the video at that frame for as long as I need, by pressing "Space" for example, in order to think about how to annotate it, then press "Space" again to continue the video, once I decide how to annotate. How can I add this pause/continue option? Thank you!