Script to test OpenCV API for face detection using Camera(Raspberry PI 3)
To connect PI camera to Raspberry PI Ubuntu Mate follow the steps below:
A. Prepare
- Install Ubuntu-Mate
- Then open a terminal on Ubuntu-Mate
- sudo apt-get update
- sudo apt-get upgrade
- sudo apt-get install build-essential cmake pkg-config
- sudo apt-get install build-essential
- sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
- sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
B. Clone Package from Git
- cd /opt
- git clone https://github.com/Itseez/opencv.git
- git clone https://github.com/Itseez/opencv_contrib.git
- cd opencv
- git checkout 3.1.0
- cd /opt/opencv_contrib
- git checkout 3.1.0
- cd /opt/opencv
C. Pre-Build
- cd /opt/opencv
- mkdir release
- cd release
- cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=/opt/opencv_contrib/modules /opt/opencv/
D. Make and Install(It will take like 1 hour and half, take a good break while making process)
- sudo make
- sudo make install
- Check the version by type: pkg-config --modversion opencv
Run the code:
- Paste the code into the Desktop of your Ubuntu system
- Open terminal
- cd Desktop
- python face_detect.py
You would be able to see the camera screen and detected output on screen streaming and terminal Frame Rate is about 10-12 frames per second.