【发布时间】:2021-07-11 20:19:32
【问题描述】:
我制作了一个深度学习程序,该程序使用网络摄像头识别一个人的情绪、种族和性别。文本显示一个人的特征是彼此内在的。如何将它们移到彼此下方?
代码
while cap.isOpened():
ret, frame = cap.read()
result = DeepFace.analyze(frame, actions=['emotion', "race", "gender"], enforce_detection=False)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = faceCascade.detectMultiScale(gray,1.1,4)
for(x, y, w, h) in faces:
cv2.rectangle(frame, (x, y), (x+w, y+h), (50, 50, 50), 2)
font = cv2.FONT_HERSHEY_DUPLEX
cv2.putText(frame,
result['dominant_emotion'],
(50, 50),
font, 1,
(220, 220, 220),
2,
cv2.LINE_4)
cv2.putText(frame,
result['gender'],
(40, 50),
font, 1,
(220, 220, 220),
2,
cv2.LINE_4)
cv2.putText(frame,
result['dominant_race'],
(30, 50),
font, 1,
(220, 220, 220),
2,
cv2.LINE_4)
cv2.imshow('Facial rec.', frame)
if cv2.waitKey(2) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows
【问题讨论】:
-
你必须手动更改
(50, 50)、(40, 50)、(30, 50)中的y(第二个值)
标签: python opencv artificial-intelligence