Introduction: RasPi + OpenCV = Face Tracking
This instructable will teach you everything you need to know about installing your new RasPi Camera to your Raspberry Pi and implement OpenCV's Face tracking libraries. The tutorial will not assume that you know how to program or understand the inner workings of a Raspberry Pi. Intermediate users can easily use the tutorial. Beginners should be able to use this tutorial but may run into problems along the way. The time to complete is approximately 10hrs due to the slow processing power of the Raspberry Pi and the size of OpenCV. It will be easier if you use a usb webcam to start out then go back and install the necessary libraries for the Raspi Camera. By the end of the tutorial you will have a fully functioning OpenCV installation on your Raspberry Pi capable of face tracking and much much more.
- Raspberry Pi
- SD Card
- RasPi Camera Module
- Micro USB Charger
- Ethernet cord
- HDMI cord
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Install Operating System to SD Card
Step 2: Connect Raspberry Pi
- Connect Ethernet cord to port
- Connect Keyboard and Mouse to USB ports
- Insert SD card
- Connect HDMI cord to monitor
- Connect HDMI cord to Raspberry Pi
- Power on device by connecting micro USB
Step 3: First Time Setup
Connect the Camera module to the CSI port on the Raspberry Pi computer. Configure the Raspberry Pi computer On first boot, you will be presented with the ‘raspi-config’ menu.
- Type the Following into the terminal
- sudo apt-get update
- sudo apt-get upgrade -y
- sudo reboot
- sudo apt-get update
default credentials are pi with the password raspberry
Step 4: (Optional) Connect to Raspberry Pi Over Local Internet
This will allow you to use your Raspberry Pi from another computer.
Step 5: Install OpenCv and Required Libraries
- Open a terminal and type the following lines. We are installing some python libraries this step should take approx 3 minutes.
- sudo apt-get install python-pygame python-scipy python-numpy
- sudo apt-get install python-pip
- sudo pip install --upgrade pip
- Click "Menu" in top right corner
- Click "Shutdown" at the bottom of list
- Select log out
- Log back in by typing "stratx" followed by the return key
- sudo pip install virtualenvwrapper
- vi ~/.bashrc
- type "i" to enter insert mode
- paste the following on any line without quotes "source /usr/local/bin/virtualenvwrapper.sh"
- . .bashrc
- mkvirtualenv --system-site-packages env
- wget https://raw.github.com/jayrambhia/Install-OpenCV/master/Ubuntu/2.4/opencv2_4_5.sh
- chmod +x opencv2_4_5.sh
- wget -O OpenCV-2.4.11.zip http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.11/opencv-2.4.11.zip/download
- unzip OpenCv-2.4.11.zip
- cd opencv-2.4.11
- mkdir build
- cd build
- cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
- make -j4
- sudo make install
- sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
- sudo ldconfig
- apt-get remove libopencv-core2.3
- export PYTHONPATH=/usr/local/lib/python2.7/site-packages/
- export LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so
Step 6: (Optional) - Install SimpleCv
- Installation approx 5 minutes
- sudo apt-get install git
- git clone git://github.com/sightmachine/SimpleCV.git
- cd SimpleCV
- sudo python setup.py install
- camera = Camera()
Step 7: Face Tracking
Once everything is installed you may run the OpenCV sample code provided in the directory you installed to.
To run python scripts you must type python then the name of the script.
After all your hard work and patience you should backup your operating system so you won't need to spend 10hrs reinstalling if something goes wrong.
Further projects and information can be found at http://docs.opencv.org/doc/tutorials/tutorials.htm...