اذهب إلى المحتوى
  • 0

اي الخطاء فيه الكود ده

Ali Ahmed6

السؤال

السلام عليكم

# face-recognition
import face_recognition
import numpy
from PIL import Image , ImageDraw
# David Malan
# تحميل الصوره

david = face_recognition.load_image_file("David.png")
harvard = face_recognition.load_image_file("Harvard.jpg")
# locations and encodins face

david_encoding = face_recognition.face_encodings(david)[0]
harvard_locations = face_recognition.face_locations(harvard)
harvard_encoding = face_recognition.face_encodings(harvard , harvard_locations)

# draw in Image

pil_image = Image.fromarray(harvard)
draw = ImageDraw.Draw(pil_image)

# for loop

for (top , right , bottom , left) , face_encodeing in zip(harvard_locations , harvard_encoding):

    matches = face_recognition.compare_faces([david_encoding] , face_encodeing)
    best_match_index = numpy.argmin(matches)

    if matches[best_match_index]:
        box_color = "green"
    else:
         box_color = "red"

    draw.rectangle(((left,top) , (right,bottom)), outline=box_color , width=5)

     if matches[best_match_index]:
        text = "David Malan"
     else:
         text = "Unknown"


     draw.text((left,top - 20), text, fill=box_color, font=None)


pil_image.save("harvard.jpg"

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...