so I've been attempting to use the code located here to take and record videos in python for a raspberry pie project. I want to use python because all of the other hardware I'm interacting with is written in Python.
I don't really understand how to stop this script. No amount of typing any combination of characters has ever stopped this script for me. Any advice?
Final code after all suggested corrections (works when the input is typed into the screen showing camera picture):
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
while(True):
#capture frame-by frame
ret,frame = cap.read()
#operations on the frame
gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
#display
cv2.imshow('frame', gray)
key = cv2.waitKey(1000) & 0xFF
print key
if key == 27:
break
cap.release()
cv2.destroyAllWindows()