In your terminal enter: sudo nano /etc/dphys-swapfile
D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \Īfter we successfully install OpenCV, we will return our swapfile to its original state. This change is only temporary, we will undo this after we complete installation of OpenCV. Press Ctrl-X, Y and then Enter to save your changes to dphys-swapfile. Once the file is open, comment out the line CONF_SWAPSIZE=100 and add CONF_SWAPSIZE=2048. To expand the swapfile, we will start by opening dphys-swapfile for editing: sudo nano /etc/dphys-swapfile We’ll take a quick break from installing packages for Raspberry Pi facial recognition to expand the swapfile before running the next set of commands. Sudo apt install python3-dev python3-pip python3-numpy Sudo apt install libatlas-base-dev liblapacke-dev gfortran Sudo apt install libgtk-3-dev libqtgui4 libqtwebkit4 libqt4-test python3-pyqt5 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 Sudo apt install libjpeg-dev libtiff-dev libjasper-dev libpng-dev libwebp-dev libopenexr-dev Sudo apt install cmake build-essential pkg-config git Please refer to Using a Raspberry Pi Camera instead of a USB Webcam section near the bottom of this post. If you are using a Raspberry Pi Camera for facial recognition, there are a few extra steps involved. Plug in your webcam into one of the USB ports of your Raspberry Pi. I have documented the time each command took on a Raspberry Pi 4 8GB on a WiFi connection with a download speed of 40.5 Mbps.ġ. Plan for at least 2 hours to complete this section of the Raspberry Pi facial recognition tutorial.
OpenCV is an open source software library for processing real-time image and video with machine learning capabilities.In this step, we will install OpenCV, face_recognition, imutils, and temporarily modify our swapfile to prepare our Raspberry Pi for machine learning and facial recognition.
Part 1: Install Dependencies for Raspberry Pi Facial Recognition
Power supply/microSD/Keyboard/Mouse/Monitor/HDMI Cable (for your Raspberry Pi).(Raspberry Pi Zero W is not recommended for this project.) What You’ll Need for Raspberry Pi Facial Recognition We expect our users to fully comply with all national, state, and municipal laws applicable. We expect our users to fully disclose and notify when they collect, use, and/or share data. Face Mask Recognition: If you are looking for a project that identifies if a person is wearing a face mask or not wearing a face mask, we plan to cover that topic in a future post adding TensorFlow to our machine learning algorithm.ĭisclaimer: This article is provided with the intent for personal use.