Udemy — Face Detection/Recognition

Kevin Chiu
CodingJourney
Published in
2 min readJul 5, 2020

針對針對臉部偵測/辨識實作以下主題

Course link: https://www.udemy.com/course/computer-vision-face-recognition-quick-starter-in-python/

均使用python face-recognition library

1. Face Detection from Images, 
Face Detection from Real time Videos,
Emotion Detection,
Age-Gender Prediction,
2. Face Recognition from Images,
Face Recognition from Real time Videos,
Face Distance,
Face Landmarks Manipulation,
Face Makeup

Face Detection 臉部偵測

  • Face Detection

使用HOG及openCV的library來偵測臉部並畫框

  • Emotion Detection:

做完1.找到臉部框,再導入kaggle的臉部表情data weight預測出表情,最後輸出預測結果

  • Age-Gender Prediction

當然也可以用跟2.同樣的方式預測出年紀和性別

Face Recognition 臉部辨識

  • Face Recognition
  1. 一樣先找到臉部框

2. 將已知臉部相片導入face_recognition的 encoding function,得到每張圖的encoding(如下圖),並集合成一個known_face_encodings和known_face_index

3. 將欲預測的相片(轉成current_face_encoding之後)導入

face_recognition.compare_faces(known_face_encodings, current_face_encoding)

4. Get the respective index of the matching face

5. 畫出相對框和列出預測,完成臉部辨識

  • Face Distance:更進階的臉部辨識應用
  1. 使用 face_recognition.face_distance function
face_recognition.face_distance(known_face_encodings, image_to_recognize_encoding)

2. For loop in face_distance可以看出image_to_recognize跟每張已知圖的face distance(distance越小符合機率越高)

  • Face Landmarks

Visualizing Face Landmarks from Pillow

導入Face Landmark之後再將各個特徵點連結起來如下圖

  • Face Makeup Using Face Landmarks

從上一個主題(Face Landmarks)針對已知的各個Face features(眼睛,眉毛...等)做make up,最後輸出入下右圖

--

--