我有这个循环:
for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
image = frame.array
gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.1, 5)
for (x,y,w,h) in faces:
cv2.rectangle(image,(x,y),(x+w,y+h),(255,0,0),2)
cv2.imshow("Vigilancia", image)
key = cv2.waitKey(1) & 0xFF
rawCapture.truncate(0)
if faces != ():
cv2.imwrite('/home/pi/imagen.jpg',image)
break
elif key == ord("q"):
break
#elif user_input[userid]['Desactivar vigilancia']:
#break
如果用户键入";Desactivear vigancia";。我该怎么做?
如果我没有误解
elif (user_id := input("Enter a user id value:")) == "Desactivar vigilancia":
break
您可以稍后使用";user_id";变量,
重要提示此代码适用于Python 3.8及更高版本。