def analyze_emotions(im, landmarks):
for landmark in landmarks:
# Observe eyebrow height for surprise
standheight = np.absolute(landmark[27, 1] - landmark[30, 1])
eyebrowheight = np.absolute(landmark[27, 1] - landmark[19, 1])
if standheight == 0:
standheight += 0.01
eyedist = float(eyebrowheight) / float(standheight)
mouthheight = np.absolute(landmark[50, 1] - landmark[57, 1])
if float(mouthheight) / float(standheight) > 30:
cv2.putText(im, "mouthheight: " + str(mouthheight), (screenwidth - 80, 10),
fontFace=cv2.FONT_HERSHEY_SIMPLEX,
fontScale=0.4,
color=(0, 0, 255),
thickness=2)
eyedist += mouthheight / 30
mouthwidth = np.absolute(landmark[48, 0] - landmark[50, 0])
nosewidth = np.absolute(landmark[31, 0] - landmark[35, 0])
mouthdist = float(mouthwidth) / nosewidth
im = score_emotions(im, eyedist, mouthdist)
return im
评论列表
文章目录