Giter Club home page Giter Club logo

facial_recognition's Introduction

Raspberry Pi 4 Facial Recognition

This repository was originally forked from carolinedunn/facial_recognition, so credit where it's due! She wrote up a great guide on Tom's Hardware, but I found that the process for getting this thing working was a lot simpler (maybe due to the passage of time).

Pi Setup

You need a Raspberry Pi 4 (or CM4) with a Pi Camera or HQ camera attached and working. Look elsewhere for guides setting that up.

I'm currently running this on 32-bit Pi OS, but the process could work on 64-bit Pi OS once camera module support is fully functional there.

The dependencies required can be installed (as of September 2021) like so:

# Install OpenCV dependencies.
$ sudo apt-get install -y libatlas-base-dev

# Install OpenCV and face recognition libraries.
$ sudo pip3 install opencv-python face-recognition imutils

# I had to do this due to a numpy import error with OpenCV.
$ sudo pip3 install --force-reinstall numpy

You can technically set up Python libraries in other ways, including inside isolated environments local to your user account... but blasting everything with sudo is easy and for my particular needs, I'm dedicating one Pi to this task, and it's not even going to operate over the public Internet, or run untrusted code, so I'm okay with a global install.

Training

Grab as many pictures as you want of a particular subject (e.g. you) and stash them inside a folder named "FirstName" inside the dataset folder.

For example, I would create a folder named "Jeff" and then take a number of pictures (10+) that only have my face in them—ideally without a hat and with a non-complex background—and put them inside.

Then run:

$ python3 train_model.py

This takes a couple minutes, and generates an encodings.pickle file that has all the relevant facial recognition information.

Note that you can have multiple people identified inside the dataset folder—just create a unique name for each folder. Like "Jeff", "John", "Sally", etc.

Usage

Once the training is complete, and the encodings.pickle file is present, you can run the facial recognition code with:

$ python3 facial_recognition.py

This Python script will launch a new window after a few seconds, and start identifying faces in the visible frame.

To quit, press "q". At the end, it will output some performance statistics in the terminal. On a normally-clocked Pi 4, expect around 2 FPS performance.

facial_recognition's People

Contributors

geerlingguy avatar carolinedunn avatar v1v3kgithub avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.