====== Reconnaître des visages dans des flux d'images ====== ===== Un programme très simple en Python pour faire de la détection de visage ===== Sous linux, installer Python pip (le gestionnaire de paquets de python) sudo apt install python3-pip Installer les librairies nécessaires sudo pip3 install face_recognition cv2 Copier coller dans un fichier le code ci-dessous # -*- coding: utf-8 -*- """ Created on Fri Dec 27 16:58:43 2019 @author: vchan """ # import libraries import cv2 import face_recognition # Get a reference to webcam video_capture = cv2.VideoCapture(0) # Initialize variables face_locations = [] while True: # Grab a single frame of video ret, frame = video_capture.read() # Convert the image from BGR color (which OpenCV uses) to RGB color (which face_recognition uses) rgb_frame = frame[:, :, ::-1] # Find all the faces in the current frame of video face_locations = face_recognition.face_locations(rgb_frame) # Display the results for top, right, bottom, left in face_locations: # Draw a box around the face cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2) # Display the resulting image cv2.imshow('Video', frame) # Hit 'q' on the keyboard to quit! if cv2.waitKey(1) & 0xFF == ord('q'): break # Release handle to the webcam video_capture.release() cv2.destroyAllWindows() En vous plaçant dans le répertoire où est enregistré le fichier (dans un navigateur de fichier, vous avez souvent l'option d'ouvrir un terminal là où vous naviguez, sinon il faut utiliser la commande "cd" pour "change directory" eg : cd ~/Bureau vous emmenera sur votre Bureau), lancer ensuite le programme via la ligne de commande python3 webcamface.py * Voir [[https://github.com/ageitgey/face_recognition|d'autres exemples sur ce github]] par exemples