Emotion Detection using Python Programming!!

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

Subscribe for more tutorials!!


import cv2
from deepface import DeepFace

face_cascade = +
video_capture = cv2.VideoCapture(0)

while True:
ret, frame = video_capture.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30))

for (x, y, w, h) in faces:
cv2.rectangle(frame, (x, y), (x + w, y + h), (255, 0, 0), 2)
face = frame[y:y + h, x:x + w]
result = DeepFace.analyze(face, actions=['emotion'], enforce_detection=False)

if isinstance(result, list):
for res in result:
dominant_emotion = res['dominant_emotion']
cv2.putText(frame, dominant_emotion, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (255, 0, 0), 2)
print(f'Detected emotion: {dominant_emotion}')
else:
dominant_emotion = result['dominant_emotion']
cv2.putText(frame, dominant_emotion, (x, y - 10), cv2.FONT_HERSHEY_TRIPLEX, 0.9, (255, 0, 0), 2)
print(f'Detected emotion: {dominant_emotion}')

cv2.imshow('Video', frame)

if cv2.waitKey(1) & 0xFF == ord('q'):
break

video_capture.release()
cv2.destroyAllWindows()

programmer-designer
Автор

Coding looks awesome, sadly idk anything about it, whats ur advice if i want start learn it?

tvishaanper
welcome to shbcf.ru