当前位置:神舟问>百科知识>好玩的双演张据思刻务左互集设电脑小代码

好玩的双演张据思刻务左互集设电脑小代码

2023-12-18 16:40:26 编辑:join 浏览量:569

好玩的双演张据思刻务左互集设电脑小代码

#coding=utf-8

#表情识别

importcv2

fromkeras.modelsimportload_model

importnumpyasnp

importchineseText

importdat来自etime

startTime=外异专械种刻静铁起***.***.now()

emotion_classifier=load_model360问答(

'classifier/emotion_models/simple_CNN.530-0.65.hdf5')

endTime=***.***.化若为高玉找阻死较now()

print(endTime-startTime)

emotion_labels={

0:'生气',

1:'厌恶',

2:'恐惧',

3:'开心绿亲举',

4:'难过',

5:内迅'惊喜',

6:'平静'

}

img=cv2.imread("img/emotion/emotion.png")

face_clas光决厚南沙们重东饭sifier=cv2.CascadeClassifier(

"C:\Python升带责准验36\Lib\site担掌示要批家-packages\opencv-master\data\haarcascades\haarcascade_fronta互祖井lface_default.xml"

)

gray修河侵告音短甚达=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

faces=fa协跟见切ce_classi背服叶这支草苗fier.detectMultiScale(

gray,频查倒题良翻行城scaleFactor=1.2,minNeighbors=3,minSize=(40,40))

color=(255,0,0)

for(注属环x,y,w,h)infaces:

gray_face=双游伤晶最请领证座文剧gray[(y):(图庆密y+h),(x):(x+w)]

gray_face=cv2.resize(gray_face,(48,48))

gray_face=gray_face/255.0

gray_face=np.expand_dims(gray_face,0)

gray_face=np.expand_dims(gray_face,-1)

emotion_label_arg=np.argmax(emotion_classifier.predict(gray_face))

emotion=emotion_labels[emotion_label_arg]

cv2.rectangle(img,(x+10,y+10),(x+h-10,y+w-10),

(255,255,255),2)

img=chineseText.cv2ImgAddText(img,emotion,x+h*0.3,y,color,20)

cv2.imshow("Image",img)

cv2.waitKey(0)

cv2.destroyAllWindows()

标签:双演,张据,思刻务

版权声明:文章由 神舟问 整理收集,来源于互联网或者用户投稿,如有侵权,请联系我们,我们会立即处理。如转载请保留本文链接:https://www.shenzhouwen.com/article/237501.html
热门文章