filmov
tv
Raspberry Pi: Face mask detection with OpenCV and Tensorflow

Показать описание
Raspberry Pi: Face mask detection with OpenCV and Tensorflow
If you find this content useful, please send me "Super Thanks"
Step by step installation
Preparation :
1. Raspberry Pi 4, python minimum 3.7
2. Webcam or PiCamera
3. Monitor
4. Mouse and keyboard
Steps:
1. Expand File System and enable camera:
$ sudo raspi-config
- Select A1. Expand File System
- Select enable Camera
2. Delete libreoffice (for get more space):
$ sudo apt-get purge wolfram-engine
$ sudo apt-get purge libreoffice*
$ sudo apt-get clean
$ sudo apt-get autoremove
3. OpenCV preparation:
$ sudo apt install cmake build-essential pkg-config git
$ sudo apt install libjpeg-dev libtiff-dev libjasper-dev libpng-dev libwebp-dev libopenexr-dev
$ 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 libgtk-3-dev libqtgui4 libqtwebkit4 libqt4-test python3-pyqt5
$ sudo apt install libatlas-base-dev liblapacke-dev gfortran
$ sudo apt install libhdf5-dev libhdf5-103
$ sudo apt install python3-dev python3-pip python3-numpy
4. Expand the swapfile, we will start by opening dphys-swapfile for editing
$ sudo nano /etc/dphys-swapfile
Change CONF_SWAPSIZE=100 become CONF_SWAPSIZE=2048
$ sudo systemctl restart dphys-swapfile
5. OpenCV Installation:
$ mkdir ~/opencv/build
$ cd ~/opencv/build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
D ENABLE_NEON=ON \
-D ENABLE_VFPV3=ON \
-D BUILD_TESTS=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D CMAKE_SHARED_LINKER_FLAGS=-latomic \
-D BUILD_EXAMPLES=OFF ..
$ make -j$(nproc)
$ sudo make install
$ sudo ldconfig
6. Return our swapfile
$ sudo nano /etc/dphys-swapfile
Return value CONF_SWAPSIZE=100
$ sudo systemctl restart dphys-swapfile
7. Install Tensorflow:
8. Install imutils
$ sudo pip3 install imutils
9. Download source code face mask detector
10. Running application
$ cd face_mask_detection
if you are using USB webcam :
If you are using PiCamera:
Problem :
...
AttributeError: 'str' object has no attribute 'decode'
File location: /usr/local/lib/python3.7/dist-packages/tensorflow_core/python/keras/saving
Delete " .decode('utf8')" in line 166, 180, 651, and 655
If you find this content useful, please send me "Super Thanks"
Step by step installation
Preparation :
1. Raspberry Pi 4, python minimum 3.7
2. Webcam or PiCamera
3. Monitor
4. Mouse and keyboard
Steps:
1. Expand File System and enable camera:
$ sudo raspi-config
- Select A1. Expand File System
- Select enable Camera
2. Delete libreoffice (for get more space):
$ sudo apt-get purge wolfram-engine
$ sudo apt-get purge libreoffice*
$ sudo apt-get clean
$ sudo apt-get autoremove
3. OpenCV preparation:
$ sudo apt install cmake build-essential pkg-config git
$ sudo apt install libjpeg-dev libtiff-dev libjasper-dev libpng-dev libwebp-dev libopenexr-dev
$ 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 libgtk-3-dev libqtgui4 libqtwebkit4 libqt4-test python3-pyqt5
$ sudo apt install libatlas-base-dev liblapacke-dev gfortran
$ sudo apt install libhdf5-dev libhdf5-103
$ sudo apt install python3-dev python3-pip python3-numpy
4. Expand the swapfile, we will start by opening dphys-swapfile for editing
$ sudo nano /etc/dphys-swapfile
Change CONF_SWAPSIZE=100 become CONF_SWAPSIZE=2048
$ sudo systemctl restart dphys-swapfile
5. OpenCV Installation:
$ mkdir ~/opencv/build
$ cd ~/opencv/build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
D ENABLE_NEON=ON \
-D ENABLE_VFPV3=ON \
-D BUILD_TESTS=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D CMAKE_SHARED_LINKER_FLAGS=-latomic \
-D BUILD_EXAMPLES=OFF ..
$ make -j$(nproc)
$ sudo make install
$ sudo ldconfig
6. Return our swapfile
$ sudo nano /etc/dphys-swapfile
Return value CONF_SWAPSIZE=100
$ sudo systemctl restart dphys-swapfile
7. Install Tensorflow:
8. Install imutils
$ sudo pip3 install imutils
9. Download source code face mask detector
10. Running application
$ cd face_mask_detection
if you are using USB webcam :
If you are using PiCamera:
Problem :
...
AttributeError: 'str' object has no attribute 'decode'
File location: /usr/local/lib/python3.7/dist-packages/tensorflow_core/python/keras/saving
Delete " .decode('utf8')" in line 166, 180, 651, and 655
Комментарии