Endersqui
Centipat
- Katılım
- 19 Eylül 2023
- Mesajlar
- 102
Daha fazla
- Cinsiyet
- Erkek
Python:
import cv2
from deepface import DeepFace
def yuz_tani(frame):
# Yüz tanıma işlemi
sonuc = DeepFace.analyze(frame, actions=['emotion'])
if sonuc['region'] != (0, 0, 0, 0):
# Yüz tespit edildiğinde sonucu ekrana yazdır
print("Tespit edilen yüz: ", sonuc['dominant_emotion'])
# Yüzü dikdörtgen ile çerçeveleme
x, y, w, h = sonuc['region']
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
return frame
# Webcam başlatma
video_capture = cv2.VideoCapture(0)
while True:
# Webcam'den görüntü yakalama
ret, frame = video_capture.read()
# Yüz tanıma fonksiyonunu çağırma
frame = yuz_tani(frame)
# Sonuçları gösterme
cv2.imshow('Video', frame)
# Çıkış için 'q' tuşuna basma kontrolü
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Webcam kapatma ve pencereleri kapatma
video_capture.release()
cv2.destroyAllWindows()
Bu kodu çalıştırdığımda cannot import name 'LocallyConnected2D' from 'keras.layers' hatası alıyorum.
Son düzenleyen: Moderatör: