วันพุธที่ 22 สิงหาคม พ.ศ. 2561

Raspberry pi Face Recognition






Raspberry pi Face Recognition with OpenCV

Built using dlib's state-of-the-art face recognition built with deep learning. The model has an accuracy of 99.38%

Hardware

  • Raspberry Pi 3B Board with SD card and accessories.

Software and Library

  • Raspbien Stretch OS
  • OpenCV 3.3.0
  • Python 3.x
  • dlib library 19.x


First You must install openCV on your raspberry pi.
If you don't have it see this 


Update and Libraries

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential \
    cmake \
    gfortran \
    git \
    wget \
    curl \
    graphicsmagick \
    libgraphicsmagick1-dev \
    libatlas-dev \
    libavcodec-dev \
    libavformat-dev \
    libboost-all-dev \
    libgtk2.0-dev \
    libjpeg-dev \
    liblapack-dev \
    libswscale-dev \
    pkg-config \
    python3-dev \
    python3-numpy \
    python3-pip \
    zip
sudo apt-get clean


Install Dlib

Before Install dlib. 
Temporary enable a larger swap file size ( For the dlib compile won't fail )


sudo nano /etc/dphys-swapfile

< change CONF_SWAPSIZE=100 to CONF_SWAPSIZE=1024 and save / exit nano >

sudo /etc/init.d/dphys-swapfile restart



Now Install Dlib

git clone https://github.com/davisking/dlib.git

cd dlib


sudo python3 setup.py install --compiler-flags "-mfpu=neon"


Install Face Recognition



sudo pip3 install face_recognition



Reference
https://github.com/ageitgey/face_recognition

http://dlib.net/


My Website

email : info@softpowergroup.net  ,amphancm@gmail.com  Tel .+6681-6452400


Android and Arduino IoT

วันศุกร์ที่ 10 สิงหาคม พ.ศ. 2561

Install OpenCV on Raspberry Pi





Install openCV on Raspberry Pi

In this blog post I demonstrated how to install OpenCV 3 with Python 2.7 and Python 3 on Raspberry pi 3B.

What is OpenCV?
OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. 
https://opencv.org/about.html


Hardware

  • Raspberry Pi 3B Board with SD card and accessories.

Software and Library

  • Raspbien Stretch OS
  • OpenCV 3.3.0



Install OpenCV on Raspberry Pi

Update First.

sudo apt-get update sudo apt-get upgrade sudo rpi-update


Cmake (builder and compiler)

sudo apt-get install build-essential cmake pkg-config git


dependencies  Image และ Video IO

sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev sudo apt-get install libxvidcore-dev libx264-dev

HiGUI 
sudo apt-get install libgtk2.0-dev libgtk-3-dev
sudo apt-get install libatlas-base-dev gfortran


Python Dev
sudo apt-get install python2.7-dev python3-dev



OpenCV source code
wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.3.0.zip
unzip opencv.zip
wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.3.0.zip
unzip opencv_contrib.zip

Build
cd opencv-3.3.0
mkdir build cd build cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D OPENCV_EXTRA_MODULES_PATH=/home/pi/opencv_contrib-3.3.0/modules \ -D BUILD_EXAMPLES=ON \ -D WITH_OPENGL=ON \ -D WITH_V4L=ON ..


Change Some config

sudo /etc/init.d/dphys-swapfile stop
sudo nano /etc/dphys-swapfile 

set CONF_SWAPSIZE 100 (100 MB) to  1024 (1 GB)
then reboot



login again 

sudo /etc/init.d/dphys-swapfile start


MAKE  ( it take 2 hours )
make -j4



sudo make install sudo ldconfig




Test Import OpenCV in python code

python
import cv2
cv2.__version__




Raspberry pi OpenCV Application

Raspberry Pi Car Detection with OpenCV

http://raspberrypi4u.blogspot.com/2018/06/raspberry-pi-car-detection-with-opencv.html














Raspberry Pi Face Detection with OpenCV

http://raspberrypi4u.blogspot.com/2018/06/raspberry-pi-face-detection-opencv.html