Create a program that checks as to which stage an age is
while True:
frame = vs.read()
frame = imutils.resize(frame, width=400)
results = detect_and_predict_age(frame, faceNet, ageNet,
minConf=args["confidence"])
for r in results:
text = "{}: {:.2f}%".format(r["age"][0], r["age"][1] * 100)
(startX, startY, endX, endY) = r["loc"]
y = startY - 10 if startY - 10 > 10 else startY + 10
cv2.rectangle(frame, (startX, startY), (endX, endY),
(0, 0, 255), 2)
cv2.putText(frame, text, (startX, y),
cv2.FONT_HERSHEY_SIMPLEX, 0.45, (0, 0, 255), 2)
cv2.imshow("Frame", frame)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
cv2.destroyAllWindows()
vs.stop()
Comments
Leave a comment