SlideShare a Scribd company logo
1 of 31
Face Detection On
RPI2
Steven
Outline
• RaspberryPi Camera
• OpenCV Face Detection
• My Pi2
• Demo
RaspberryPi Camera
Spec
Net price 940 NTW
Still resolution 5 Megapixels
Video modes
1080p30, 720p60 and
640x480p60/90
Picture formats JPEG , JPEG + RAW , GIF , BMP ,
PNG , YUV420 , RGB888
Video formats raw h.264
Applications
• Taking Picture
• Video Stream
• Time lapse video
• Dashcam recorded at 1080p
What Else?Face Detection
Outline
• RaspberryPi Camera
• OpenCV Face Detection
• My Pi2
• Demo
OpenCV Face Detection
• Rapid Object Detection using a Boosted
Cascade of Simple Features
• Haar Feature Cascade Classifier
• Haar feature: Simple rectangular feature
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)
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
Human Face Has Some Features
Adaboost Training Method
Positive
1
Negative
4
Negative
3
Positive
2
Negative
5
p n p
n n
0.2 0.2 0.2 0.2 0.2
HaarFeature 1
Positive
1
Negative
4
Negative
3
Positive
2
Negative
5
p p pn n
0.13 0.3 0.13 0.3 0.13
StrongClassifier(x)=1.5*h1(x)Err rate = 0.4 a1 = (1-err)/err=1.5
HaarFeature 2
StrongClassifier(x)=1.5*h1(x)+2.3*h2(x)Err rate = 0.3 a2 = (1-err)/err=2.3
Positive
1
Negative
4
Negative
3
Positive
2
Negative
5
0.11 0.25 0.40.11 0.11
….
Final Strong Classifier
Cascade of Classifiers
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
OpenCV Pre-Trained Classifiers
• haarcascade_eye_tree_eyeglasses.xml
haarcascade_eye.xml
haarcascade_frontalface_alt2.xml
haarcascade_frontalface_alt_tree.xml
haarcascade_frontalface_alt.xml
haarcascade_frontalface_default.xml
haarcascade_fullbody.xml
haarcascade_lefteye_2splits.xml
haarcascade_profileface.xml
haarcascade_lowerbody.xml
haarcascade_righteye_2splits.xml
haarcascade_mcs_eyepair_big.xml
haarcascade_smile.xml haarcascade_mcs_eyepair_small.xml
haarcascade_upperbody.xml
haarcascade_frontalface_alt.xml
• <_>3 7 14 4 -1.</_>
• <_>x y h w weight</_>
(x,y)
h
w
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.
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
Parameter : minNeighbors
minNeighbors=0
minNeighbors=1
Outline
• RaspberryPi Camera
• OpenCV Face Detection
• My Pi2
• Demo
My RaspberryPi 2
Big Red Buttion
USB WIFI Dangle
RPI 2
Camera
USB Battery
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 ?
python-picamera
• sudo apt-get update
• sudo apt-get install python-picamera
• import picamera
camera = picamera.PiCamera()
camera.start_preview()
sleep(7)
camera.capture(data, format='jpeg')
Compile OpenCV on PI2
Outline
• RaspberryPi Camera
• OpenCV Face Detection
• My Pi2
• Demo
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
JewelryBox
• Box mode
• Send images and comments
Reference
• Rapid Object Detection using a Boosted Cascade of
SimpleFeatures
• http://docs.opencv.org/modules/objdetect/do
c/cascade_classification.html
• https://learn.adafruit.com/raspberry-pi-face-
recognition-treasure-box/overview
Q & A
Thanks

More Related Content

Similar to Facial Detection On

ICCASP Human Skin Detection using RGB, HSV and YCbCr Color Models
ICCASP Human Skin Detection using RGB, HSV and YCbCr Color ModelsICCASP Human Skin Detection using RGB, HSV and YCbCr Color Models
ICCASP Human Skin Detection using RGB, HSV and YCbCr Color ModelsChaitanya Bapat
 
cvpresentation-190812154654 (1).pptx
cvpresentation-190812154654 (1).pptxcvpresentation-190812154654 (1).pptx
cvpresentation-190812154654 (1).pptxPyariMohanJena
 
ppt 20BET1024.pptx
ppt 20BET1024.pptxppt 20BET1024.pptx
ppt 20BET1024.pptxManeetBali
 
DMC NI Week 2014 High Speed Vision
DMC NI Week 2014 High Speed VisionDMC NI Week 2014 High Speed Vision
DMC NI Week 2014 High Speed VisionDMC, Inc.
 
ppt 20BET1024.pptx
ppt 20BET1024.pptxppt 20BET1024.pptx
ppt 20BET1024.pptxManeetBali
 
426 Lecture5: AR Registration
426 Lecture5: AR Registration426 Lecture5: AR Registration
426 Lecture5: AR RegistrationMark Billinghurst
 
Pragmatic deep learning for image labelling
Pragmatic deep learning for image labellingPragmatic deep learning for image labelling
Pragmatic deep learning for image labellingPierre Gutierrez
 
Rpi 8 mp camera v2
Rpi 8 mp camera v2 Rpi 8 mp camera v2
Rpi 8 mp camera v2 완규 주
 
Information from pixels
Information from pixelsInformation from pixels
Information from pixelsDave Snowdon
 
Computer Vision - Real Time Face Recognition using Open CV and Python
Computer Vision - Real Time Face Recognition using Open CV and PythonComputer Vision - Real Time Face Recognition using Open CV and Python
Computer Vision - Real Time Face Recognition using Open CV and PythonAkash Satamkar
 
ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)Hasitha Ediriweera
 
Automated Face Detection System
Automated Face Detection SystemAutomated Face Detection System
Automated Face Detection SystemAbhiroop Ghatak
 
Seeing is Not Believing: Camouflage Attacks on Image Scaling Algorithms Review
Seeing is Not Believing: Camouflage Attacks on Image Scaling Algorithms ReviewSeeing is Not Believing: Camouflage Attacks on Image Scaling Algorithms Review
Seeing is Not Believing: Camouflage Attacks on Image Scaling Algorithms ReviewJunyaup Kim
 
Computer vision for transportation
Computer vision for transportationComputer vision for transportation
Computer vision for transportationWanjin Yu
 
Open CV - 電腦怎麼看世界
Open CV - 電腦怎麼看世界Open CV - 電腦怎麼看世界
Open CV - 電腦怎麼看世界Tech Podcast Night
 
Perspective Multiscale Detection and Tracking of Persons
Perspective Multiscale Detection and Tracking of PersonsPerspective Multiscale Detection and Tracking of Persons
Perspective Multiscale Detection and Tracking of PersonsMarcos Nieto
 
"Multiple Uses of Pipelined Video Pre-Processor Hardware in Vision Applicatio...
"Multiple Uses of Pipelined Video Pre-Processor Hardware in Vision Applicatio..."Multiple Uses of Pipelined Video Pre-Processor Hardware in Vision Applicatio...
"Multiple Uses of Pipelined Video Pre-Processor Hardware in Vision Applicatio...Edge AI and Vision Alliance
 
HiPEAC 2019 Workshop - Use Cases
HiPEAC 2019 Workshop - Use CasesHiPEAC 2019 Workshop - Use Cases
HiPEAC 2019 Workshop - Use CasesTulipp. Eu
 

Similar to Facial Detection On (20)

ICCASP Human Skin Detection using RGB, HSV and YCbCr Color Models
ICCASP Human Skin Detection using RGB, HSV and YCbCr Color ModelsICCASP Human Skin Detection using RGB, HSV and YCbCr Color Models
ICCASP Human Skin Detection using RGB, HSV and YCbCr Color Models
 
cvpresentation-190812154654 (1).pptx
cvpresentation-190812154654 (1).pptxcvpresentation-190812154654 (1).pptx
cvpresentation-190812154654 (1).pptx
 
ppt 20BET1024.pptx
ppt 20BET1024.pptxppt 20BET1024.pptx
ppt 20BET1024.pptx
 
DMC NI Week 2014 High Speed Vision
DMC NI Week 2014 High Speed VisionDMC NI Week 2014 High Speed Vision
DMC NI Week 2014 High Speed Vision
 
ppt 20BET1024.pptx
ppt 20BET1024.pptxppt 20BET1024.pptx
ppt 20BET1024.pptx
 
426 Lecture5: AR Registration
426 Lecture5: AR Registration426 Lecture5: AR Registration
426 Lecture5: AR Registration
 
PPT s06-machine vision-s2
PPT s06-machine vision-s2PPT s06-machine vision-s2
PPT s06-machine vision-s2
 
Pragmatic deep learning for image labelling
Pragmatic deep learning for image labellingPragmatic deep learning for image labelling
Pragmatic deep learning for image labelling
 
Rpi 8 mp camera v2
Rpi 8 mp camera v2 Rpi 8 mp camera v2
Rpi 8 mp camera v2
 
Information from pixels
Information from pixelsInformation from pixels
Information from pixels
 
Computer Vision - Real Time Face Recognition using Open CV and Python
Computer Vision - Real Time Face Recognition using Open CV and PythonComputer Vision - Real Time Face Recognition using Open CV and Python
Computer Vision - Real Time Face Recognition using Open CV and Python
 
ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)
 
Automated Face Detection System
Automated Face Detection SystemAutomated Face Detection System
Automated Face Detection System
 
Seeing is Not Believing: Camouflage Attacks on Image Scaling Algorithms Review
Seeing is Not Believing: Camouflage Attacks on Image Scaling Algorithms ReviewSeeing is Not Believing: Camouflage Attacks on Image Scaling Algorithms Review
Seeing is Not Believing: Camouflage Attacks on Image Scaling Algorithms Review
 
Computer vision for transportation
Computer vision for transportationComputer vision for transportation
Computer vision for transportation
 
Open CV - 電腦怎麼看世界
Open CV - 電腦怎麼看世界Open CV - 電腦怎麼看世界
Open CV - 電腦怎麼看世界
 
Perspective Multiscale Detection and Tracking of Persons
Perspective Multiscale Detection and Tracking of PersonsPerspective Multiscale Detection and Tracking of Persons
Perspective Multiscale Detection and Tracking of Persons
 
Chapter1 8
Chapter1 8Chapter1 8
Chapter1 8
 
"Multiple Uses of Pipelined Video Pre-Processor Hardware in Vision Applicatio...
"Multiple Uses of Pipelined Video Pre-Processor Hardware in Vision Applicatio..."Multiple Uses of Pipelined Video Pre-Processor Hardware in Vision Applicatio...
"Multiple Uses of Pipelined Video Pre-Processor Hardware in Vision Applicatio...
 
HiPEAC 2019 Workshop - Use Cases
HiPEAC 2019 Workshop - Use CasesHiPEAC 2019 Workshop - Use Cases
HiPEAC 2019 Workshop - Use Cases
 

Facial Detection On

  • 2. Outline • RaspberryPi Camera • OpenCV Face Detection • My Pi2 • Demo
  • 4. Spec Net price 940 NTW Still resolution 5 Megapixels Video modes 1080p30, 720p60 and 640x480p60/90 Picture formats JPEG , JPEG + RAW , GIF , BMP , PNG , YUV420 , RGB888 Video formats raw h.264
  • 5. Applications • Taking Picture • Video Stream • Time lapse video • Dashcam recorded at 1080p
  • 7. Outline • RaspberryPi Camera • OpenCV Face Detection • My Pi2 • Demo
  • 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
  • 11. Human Face Has Some Features
  • 12. Adaboost Training Method Positive 1 Negative 4 Negative 3 Positive 2 Negative 5 p n p n n 0.2 0.2 0.2 0.2 0.2 HaarFeature 1 Positive 1 Negative 4 Negative 3 Positive 2 Negative 5 p p pn n 0.13 0.3 0.13 0.3 0.13 StrongClassifier(x)=1.5*h1(x)Err rate = 0.4 a1 = (1-err)/err=1.5 HaarFeature 2 StrongClassifier(x)=1.5*h1(x)+2.3*h2(x)Err rate = 0.3 a2 = (1-err)/err=2.3 Positive 1 Negative 4 Negative 3 Positive 2 Negative 5 0.11 0.25 0.40.11 0.11 ….
  • 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
  • 16. OpenCV Pre-Trained Classifiers • haarcascade_eye_tree_eyeglasses.xml haarcascade_eye.xml haarcascade_frontalface_alt2.xml haarcascade_frontalface_alt_tree.xml haarcascade_frontalface_alt.xml haarcascade_frontalface_default.xml haarcascade_fullbody.xml haarcascade_lefteye_2splits.xml haarcascade_profileface.xml haarcascade_lowerbody.xml haarcascade_righteye_2splits.xml haarcascade_mcs_eyepair_big.xml haarcascade_smile.xml haarcascade_mcs_eyepair_small.xml haarcascade_upperbody.xml
  • 17. haarcascade_frontalface_alt.xml • <_>3 7 14 4 -1.</_> • <_>x y h w weight</_> (x,y) h w
  • 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
  • 21. Outline • RaspberryPi Camera • OpenCV Face Detection • My Pi2 • Demo
  • 22. My RaspberryPi 2 Big Red Buttion USB WIFI Dangle RPI 2 Camera USB Battery
  • 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 ?
  • 24. python-picamera • sudo apt-get update • sudo apt-get install python-picamera • import picamera camera = picamera.PiCamera() camera.start_preview() sleep(7) camera.capture(data, format='jpeg')
  • 26. Outline • RaspberryPi Camera • OpenCV Face Detection • My Pi2 • Demo
  • 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
  • 28. JewelryBox • Box mode • Send images and comments
  • 29. Reference • Rapid Object Detection using a Boosted Cascade of SimpleFeatures • http://docs.opencv.org/modules/objdetect/do c/cascade_classification.html • https://learn.adafruit.com/raspberry-pi-face- recognition-treasure-box/overview
  • 30. Q & A

Editor's Notes

  1. 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.