Sample projects

There is a new module that has been developed to simplify computer vision and face recognition using USB cameras on the Raspberry Pi 400. There is a video tutorial here, but there are parts that are hard to follow due to the fuzzy screen resolution on the video. The following instructions will help you install it on your system.

Step 1. There are three python files that you'll need to use. Download them and save them in the directory with your other python files.

(a) face_shot.py

(b) train_model.py

(c) face_rec.py

Next, you'll have to run the following scripts from the command line:

Step 2. pip3 install imutils
Step 3. pip3 install face-recognition

Step 4. The steps to install OpenCV are detailed and must be followed exactly! The entire process will take about 90 minutes, but most of it can execute in the background while you use your computer for other things. The details an be found here

Once all files are installed, you'll run the programs that you downloaded above. First, run face_shot.py to capture about twenty differennt images of your face looking into the camera. You'll press the space key on the keyboard to take each picture,

Next, train your model by running train_model.py. This needs no interaction from the user, and will use the pictures you shot to train the model for your (and others' if you want) faces.

Finally, run face_rec.py to identify the faces of people who look into your camera. It will only recognize people who you've trained the system for, but you can add more people to your database by following the previous two steps.


pip3 install opencv-python
pip3 install opencv-contrib-python

pip3 install numpy==1.20.3


sudo apt install cmake build-essential pkg-config git
a few seconds

sudo apt install libjpeg-dev libtiff-dev libjasper-dev libpng-dev libwebp-dev libopenexr-dev
a few seconds

sudo apt install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libdc1394-22-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev
4 minutes

sudo apt install libgtk-3-dev libqtgui4 libqtwebkit4 libqt4-test python3-pyqt5
4.5 minutes

sudo apt install libatlas-base-dev liblapacke-dev gfortran
1 minute

sudo apt install libhdf5-dev libhdf5-103
1 minute

sudo apt install python3-dev python3-pip python3-numpy
a few seconds

Face recognition is a fascinating topic. There is a very detailed discussion of techniques and history on the subject here. Highly recommended!