SafeDriving
Detect eyes->Count time(when eyes closed)->if the count up to 3->alarm
RasberryPi, opencv, webcam
🌼 How to install openCV in your RasberryPi
- Check your RasberryPi OS version
$ cat /etc/*release*
- Update any existing packages
$ sudo apt-get update
- Install some developer tools
$ sudo apt-get install build-essential cmake pkg-config
$ 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
$ sudo apt-get install libgtk2.0-dev
$ sudo apt-get install libatlas-base-dev gfortran
$ sudo apt-get install python2.7-dev python3-dev
- Download the openCV source code
$ cd ~
$ wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.1.0.zip
$ unzip opencv.zip
$ wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.1.0.zip
$ unzip opencv_contrib.zip
Make sure the opencv_contrib and opencv file's version are the same
So I just download the opencv file in window, and I import it by USB.
- Install pip
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py
- Install numpy
$ pip install numpy
- Setup build using CMake
$ cd ~/opencv-3.1.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=~/opencv_contrib-3.1.0/modules \
-D BUILD_EXAMPLES=ON ..
- Build
$ make -j4
- Install openCV
$ sudo make install
$ sudo ldconfig
- Finish
🌼 Install several Libraries
- Install dlib prerequisites
$ sudo apt-get update
$ sudo apt-get install build-essential cmake
$ sudo apt-get install libgtk-3-dev
$ sudo apt-get install libboost-all-dev
- Use pip to install dlib with Python bindings
$ pip install scipy
$ pip install dlib
🌼 To run the code
python pi_detect_drowsiness.py --cascade haarcascade_frontalface_default.xml \
--shape-predictor shape_predictor_68_face_landmarks.dat