Art and Web Design
Contact me for information about rates and availability.
Facial Recognition Using Python and OpenCV
In this tutorial we will explore basic machine learning concepts by developing a simple facial recognition program in under 22 lines of code, using a webcam, Python 2.7, and the open source library OpenCV v2.
OpenCV is a popular library for computer vision, which was originally written in C/C++, but now provides bindings for Python. This tutorial is based on Shantnu Tiwari's python blog, which can be found at https://realpython.com/blog/python/face-detection-in-python-using-a-webcam/.
In a future tutorial we will build our own cascades in OpenCV and teach it how to recognize other objects such as cars, bananas and toys. The task of recognizing individual faces is surprisingly difficult, but is possible using machine learning algorithms as described here.
Components and Software
For this tutorial you will need a working webcam, OpenCV and a Python editor.
OpenCV, short for Open Source Computer Vision Library, can be found here. OpenCV is released under a BSD license and is free for both academic and commercial use. It has C++, C, Python, Java and MATLAB interfaces and supports Windows, Linux, Mac OS, iOS and Android systems. OpenCV was designed for computational efficiency and with a strong focus on real-time applications.
I use the PyCharm IDE by JetBrains for this project. PyCharm provides smart code completion, code inspections, on-the-fly error highlighting and quick-fixes, along with automated code refactorings and rich navigation capabilities.
Don't forget to add the haarcascade files in the same directory as your python script. The haarcascade files can be found at the Open Source Computer Vision's github repository. To learn more about computer vision using OpenCV and haarcascades, I highly recommend that you visit read Introduction to Computer Vision With OpenCV and Python by Oli Moser.