我试图检测我的循环何时停止,以便我可以使用 if 语句说:如果“循环已停止”:print(text)
代码:
faces = detector(gray)
for face in faces:
x, y = face.left(), face.top()
x1, y1 = face.right(), face.bottom()
rectangle = cv2.rectangle(frame, (x, y), (x1, y1), (0, 255, 0), 2)
if "the loop has stopped":
cv2.putText(frame, "Asleep", (50, 150), font, 7, (0, 0, 255))
Run Code Online (Sandbox Code Playgroud)