2020 "sad" : "sad_emoji.webp" ,
2121 "angry" : "angry_emoji.jpg" ,
2222 "surprise" : "surprise_emoji.png" ,
23- "neutral" : "neutral_emoji.webp"
23+ "neutral" : "neutral_emoji.webp" ,
2424}
2525
2626while True :
3838 # Use DeepFace to analyze the face in the frame
3939 try :
4040 analysis = DeepFace .analyze (
41- frame ,
42- actions = [' emotion' ],
43- enforce_detection = False # ✅ FIXED: Removed 'model_name'
41+ frame ,
42+ actions = [" emotion" ],
43+ enforce_detection = False , # ✅ FIXED: Removed 'model_name'
4444 )
45- detected_emotion = analysis [0 ][' dominant_emotion' ]
45+ detected_emotion = analysis [0 ][" dominant_emotion" ]
4646
4747 # Add the latest emotion to the queue
4848 emotion_queue .append (detected_emotion )
6363 frame = cv2 .cvtColor (np .array (frame_pil ), cv2 .COLOR_RGB2BGR )
6464
6565 # Display detected emotion text
66- cv2 .putText (frame , detected_emotion .capitalize (), (50 , 180 ),
67- cv2 .FONT_HERSHEY_SIMPLEX , 1 , (0 , 255 , 0 ), 2 )
66+ cv2 .putText (
67+ frame ,
68+ detected_emotion .capitalize (),
69+ (50 , 180 ),
70+ cv2 .FONT_HERSHEY_SIMPLEX ,
71+ 1 ,
72+ (0 , 255 , 0 ),
73+ 2 ,
74+ )
6875
6976 except Exception as e :
7077 print ("Error:" , e )
7380 cv2 .imshow ("Live Emoji Detection" , frame )
7481
7582 # Press 'q' to exit
76- if cv2 .waitKey (1 ) & 0xFF == ord ('q' ):
83+ if cv2 .waitKey (1 ) & 0xFF == ord ("q" ):
7784 break
7885
7986cap .release ()
80- cv2 .destroyAllWindows ()
87+ cv2 .destroyAllWindows ()
0 commit comments