So I've got a program where I assign different keypresses to different functions. I'm using cv2.waitKey(0) to go through frames one by one. However, when a key that isn't assigned a function is pressed, the next frame is still loaded. How do I prevent a non-assigned keypress from loading the next frame in my loop?
Thanks!
while (cap.isOpened()):
frameclick = cv2.waitKey(0)
ret, frame = cap.read()
cv2.imshow('frame',frame)
if frameclick == ord('a'):
swingTag()
elif frameclick == ord('r'):
rewindFrames()
elif frameclick == ord('s'):
stanceTag()
elif frameclick == ord('d'):
unsureTag()
elif frameclick == ord('q'):
with open((selectedvideostring + '.txt'), 'w') as textfile:
for item in framevalues:
textfile.write("{}\n".format(item))
break
else: continuethat catches all other clicks and continues to the next round of your while loop.