here is a code snippet im running in VS 'cap = cv2.VideoCapture(0) while cap.isOpened():
ret, frame = cap.read()
cv2.imshow('OpenCV feed', frame)
#breaks for a while
if cv2.waitKey(10) & 0xFF == ord('e'):
break
cap.release()
cv2.destroyAllWindows()`
but it closes immediately it runs, what did i do wrong??
CodePudding user response:
Because break cannot be used to break out of an if - it can only break out of loops.
Perhaps you should use sys.exit()
or return
instead?
CodePudding user response:
Try this:
if cv2.waitKey(10) & 0xFF == ord('e'):
cv2.destroyAllWindows()
break