Image for post
Image for post

Facial Recognition: You Cannot Hide From The Machine

The Rise of AI: Good or Bad?

Introduction

Behavioural biometrics

What is in a face?

Analysing a face with a cognitive engine

Image for post
Image for post
Figure 1: Face mapping
Image for post
Image for post
Figure 2: Face landmark mapping
Image for post
Image for post
Figure 3: Returned values for Microsoft Cognitive Engine

Detecting faces

Image for post
Image for post
Figure 4: Edge and line features in the face
Image for post
Image for post
Figure 5: Detection of eye region
Image for post
Image for post
Figure 6: Face and eye detection
Image for post
Image for post
Figure 7: Face classifier on a cat image
Image for post
Image for post
Figure 8: Face classifier with a cat classifier
import numpy as np
import cv2
import matplotlib.pyplot as plot
import sys
imfile = 'http://img.sxsw.com/2015/films/F52361.jpg'
imfile = 'F52361.jpg'
file='111.jpg'if (len(sys.argv)>1):
imfile=str(sys.argv[1])
if (len(sys.argv)>2):
file=str(sys.argv[2])
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')
img = cv2.imread( imfile)gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)faces = face_cascade.detectMultiScale(gray, 1.3, 5)
for (x,y,w,h) in faces:
cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
roi_gray = gray[y:y+h, x:x+w]
roi_color = img[y:y+h, x:x+w]
eyes = eye_cascade.detectMultiScale(roi_gray)
for (ex,ey,ew,eh) in eyes:
cv2.rectangle(roi_color,(ex,ey),(ex+ew,ey+eh),(0,255,0),2)
file1 = "filename"
cv2.imwrite(file1,img)
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
smile_cascade = cv2.CascadeClassifier('smile.xml')
img = cv2.imread( imfile)gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)faces = face_cascade.detectMultiScale(gray, 1.3, 5)
for (x,y,w,h) in faces:
cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
roi_gray = gray[y:y+h, x:x+w]
roi_color = img[y:y+h, x:x+w]
smile = smile_cascade.detectMultiScale(
roi_gray,
scaleFactor= 1.7,
minNeighbors=22,
minSize=(25, 25)
)
for (ex,ey,ew,eh) in smile:
cv2.rectangle(roi_color,(ex,ey),(ex+ew,ey+eh),(0,0,255),2)

Pitch, yaw and roll

Image for post
Image for post
Figure 9: Normalising to a standard model

Emotion, hair and other features

Image for post
Image for post
Figure 10: Additional features from face recognition
Image for post
Image for post
Figure 10: Cheek Raiser and Lip Corner methods for smile detection [1]

Weaknesses of facial recognition

Facial recognition for good and bad?

Appendix

Written by

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. EU Citizen. Auld Reekie native. Old World Breaker. New World Creator.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store