Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Raspberry Pi Zero W Wireless Projects

You're reading from   Raspberry Pi Zero W Wireless Projects Go mobile with the world's most popular microprocessor

Arrow left icon
Product type Paperback
Published in Aug 2017
Publisher Packt
ISBN-13 9781788290524
Length 240 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Vasilis Tzivaras Vasilis Tzivaras
Author Profile Icon Vasilis Tzivaras
Vasilis Tzivaras
Arrow right icon
View More author details
Toc

Face recognition

Assuming that you have successfully installed OpenCV, we can test this out by simply importing cv with Python. Open up a Terminal and type python to start the shell and then, type the following command:

    import cv2  

If everything goes OK and there are no errors on the screen, you should be fine. Else, go back and reinstall OpenCV as described previously. Now, let's break down the actual code, which you can find and download from the following link:

https://github.com/shantnu/FaceDetect/

In the face_detect.py script, the abba.png image, and the haarcascade_frontalface_default.xml are the following. When executing the file, you have to pass these two arguments:

 # Get user supplied values
imagePath = sys.argv[1]
cascPath = sys.argv[2]

As a result, you first pass in the image and then, cascade names. In the following example, we will use the Abba image...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image