Face Detection Lesson Instructions

HAPPY FACES – Face Detection Program Instructions

To install the software needed for this activity, please follow these abbreviated instructions (a more comprehensive set of instructions with additional support for different systems is available online, at our website, www.tumblehomebooks.org).  Be sure to hit the enter key after typing any commands, to ensure that they run properly.

  1. Install Anaconda (a GUI / Graphical User Interface-based python environment and package managing software) appropriate to your own system. https://www.anaconda.com/products/individual

  2. We suggest that you set up a new programming environment, under the Anaconda environments tab, with Python 3.5 ot 3.6 as the base Python language. Make sure that you open up Anaconda Command Prompt to continue below.   Be sure to activate your environment by typing conda activate newenvname

  3. (replacing newenvname with the environment name you created). Doing this will allow you to isolate these programs and ensure that you keep all the related software for this program in one environment.

  4. Install OpenCV; try to find an appropriate way to install it on your system. Here is one way to do this, using the Anaconda Command Prompt, which is installed with the Anaconda package:  conda install -c conda-forge opencv  The installation program may ask you if you’d like to proceed, please click Y.  You may also need to install another version of OpenCV as well, so it is best to do that via :  pip install opencv-contrib-python

  5. You may also need several additional libraries to run certain parts of this program: Matplotlib and Numpy. The program will prompt you if you need additional libraries, in the warnings and error messages.  If you need these libraries, you can do this by typing: conda install -c conda-forge matplotlib and conda install -c conda-forge numpy

  6. Create a new folder in an easily accessible location, like c:\facedetect by typing the following: mkdir c:\facedetect and then type cd c:\facedetect to switch to it

  7. You will then need to download several Haars Cascade XML files containing a pre-trained model of faces and specific facial features (haarcascade_frontalface_default.xml and haarcascade_eye.xml) and make sure that they are saved into this same directory. Obtain from: https://github.com/opencv/opencv/tree/master/data/haarcascades

  8. You will also need to download the following program to this directory as well: https://tumblehomebooks.org/program-for-a-i-happy-faces-lesson-plan-part-2-code/

  9. Run your program by typing: python facedetect_code2.py (or if you get the program from a class, use “python a.py”)

  10. Try your own face, and a hand-drawn faces (or several), and make observations.

When you run the program, you should see an output that looks something like this (although your version may have different colors, which you can modify in the code):

Record Results  & Observations:

Be sure to retain all hand-drawn images, and write down on the sketch paper whether or not the drawn face worked very well, somewhat well, not well, or if it didn’t work at all.  Students should be asked to think about why a particular face worked or did not work very well, and what might be potential conclusions that can be drawn about the training, weights and any possible system biases.  Also, be sure to try your own face, perhaps with different sources/types of lighting, to see what works and what doesn’t.  Be sure to make notes on all your observations – both good and bad.