Software for the wheelchair controlled by eyetracker: Now with multicore support for Raspberry Pi 2 B!
Installation of openCV, the Firmata Tools and the corresponding Python bindings
This brief tutorial assumes you have just created an SD-Card for the Raspberry 2B and started it the first time (then the config-tool prompts you to make some adjustments, like expand filesystem; change localisation etc.). Adafruit has a good tutorial on this, e.g.
If you want to use the Pi-Camera, please enable it in the configuration with raspi-config (will start after first boot anyway).
The Debian Image used is the Debian Wheezy (from 2015-05-05; download here: https://www.raspberrypi.org/downloads/) .
The Log in will be user: pi and password: raspberry (mind a different keyboard-layout; e.g. with German keyboard the z and y are exchanged!)
Installing OpenCV with multicore support:
Here I will follow Adrian Rosebrock’s tutorial, except for the virtual environment as is makes things more complicated for this scenario. You can find the tutorial here: http://www.pyimagesearch.com/2015/02/23/install-opencv-and-python-on-your-raspberry-pi-2-and-b/
Type the following commands to get everything updated:
- sudo apt-get update
- sudo apt-get upgrade
- sudo rpi-update
1) Then some developer tools will be installed:
- sudo apt-get install build-essential cmake pkg-config
2) … and then some software for loading and handling images and some GUI tools
- sudo apt-get install libjpeg8-dev libtiff4-dev libjasper-dev libpng12-dev
- sudo apt-get install libgtk2.0-dev
4) After that software for video-processing is required:
- sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
5) The next step is to install libraries used within openCV
- sudo apt-get install libatlas-base-dev gfortran
Then in step 6 you will install pip, a tool to easily install other packages
- wget https://bootstrap.pypa.io/get-pip.py
- sudo python get-pip.py
I drop step 7 of Adrian’s tutorial (virtual environment) and continue with step 8…
Step 8 is to install/compile Python. Please mind the „-j4“ option in the make command. It will compile on all 4 cores making this step much faster (suggestions from discussion in Adrian’s tutorial):
- sudo apt-get install python2.7-dev
Then we need support for arrays in python:
- sudo pip install numpy –upgrade
Step 9 is getting source of openCV and install/compile it
- wget -O opencv-2.4.10.zip http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.10/opencv-2.4.10.zip/download
- unzip opencv-2.4.10.zip
- cd opencv-2.4.10
- mkdir build
- $ cd build
- cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON ..
- make -j4
This takes some time! Only for Raspi 2B: “-j4” makes it much faster, using 4 cores for compiling!
then do a
- sudo make install
- sudo ldconfig
NOW you have opencv 2.4.10 installed 🙂
Next step: Pyfirmata for controlling the Arduino over USB from your Raspberry:
- sudo pip install pyfirmata
(Pyfirmata was short, wasn’t it?)
This should give you OpenCV 2.4.10 with quadcore support 🙂 Now the tracker runs much faster! I haven’t found any improvements with Pi Camera, but I will try this again soon…