cam.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:emojivis 作者: JustinShenk 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号