Everytime I run the following code on jupyter notebook the macbook camera works well but when i press "q" to quit it freezes and crashes
cap = cv2.VideoCapture(0)
while cap.isOpened():
ret, frame = cap.read()
cv2.imshow("Image Collection", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
#Release the webcam
cap.release()
#Close the image show frame
cv2.destroyAllWindows()
Any advice? Thank you very much!!
Python: 3.9
I tried to intent it better and to change it using other ways but I still got the same problem