8. OpenCV Face Detection
• Rapid Object Detection using a Boosted
Cascade of Simple Features
• Haar Feature Cascade Classifier
• Haar feature: Simple rectangular feature
9. How to Represent Haar Feature
• sum of the pixels which lie within the white
rectangles are subtracted from the sum of
pixels in the black rectangles
– Feature = sum of pixels (white rec) – sum of pixels(black rec)
10. Integral Image
• The integral value for each pixel is the
sum of all the pixels above it and to its left
• The sum within D =4+1-2-3
15. Detection
• There are huge numbers of sub-window of each size
• Resize sub-window to the training size
• Each sub-window goes through the Haar Feature Cascade
Classifier
c
18. OpenCV detectMultiScale
• faces = haar_faces.detectMultiScale(image,
scaleFactor,minNeighbors, minSize)
Parameters:
• image – captured imgae
• scaleFactor – Parameter specifying how much the
image size is reduced at each image scale.
• minNeighbors – Parameter specifying how many
neighbors each candidate rectangle should have to
retain it.
• minSize – Minimum possible object size. Objects
smaller than that are ignored.
19. Parameter : scaleFactor
• detection window has a fixed size defined during training
• detecting large and small faces using the same detection window
• If scaleFactor=1.05 (small step for resizing)
– reducing image size by 5% can increase the chance of a matching fixed size
of detection window. Slow but accurate
• If scaleFactor=1.4 (bigger step fro resizing)
fast but risk of missing some detected faces
scale pyramid
23. Big Red Button GPIO27
echo 27 > /sys/class/gpio/export
f=open(‘sys/class/gpio/gpio27/value’,’r’)
• RPi.GPIO module
GPIO.setmode(GPIO.BCM)
GPIO.setup(27,GPIO.IN)
GPIO.input(27)
No access to /dev/mem. Try running as root!
• GPIO Permission is root
• Using ssh (user permission) to remote rapi can’t control
the gpio (user permission)
• Work around
echo 27 > /sys/class/gpio/export
f=open(‘sys/class/gpio/gpio27/value’,’r’)
Chmod and chown of /dev/mem ?
27. Demo Flow
Press Button
Start Preview
Capture Image
OpenCV face
Classifier
Where to
display the
image ?
Add rectangular line
on detected faces
and output the image
Most of them are rejected at earlier stages,
Some of them require futher stages to process
The later stages the sub-window is going through, the more likely this sub-windows contains the face.