OpenCV
- Install Raspberry Pi updates:
- sudo apt-get update
- sudo apt-get upgrade
- sudo rpi-update
- Reboot:
- Install webpy:
- cd ~
- wget http://webpy.org/static/web.py-0.37.tar.gz
- gzip -d -r web.py-0.37.tar.gz
- tar -xvf web.py-0.37.tar
- cd ./web.py-0.37
- sudo python setup.py install
- Install OpenCV requirements:
- sudo apt-get install build-essential cmake pkg-config
- sudo apt-get install libgtk2.0-dev
- sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
- sudo apt-get install libatlas-base-dev gfortran
- wget https://bootstrap.pypa.io/get-pip.py
- sudo python get-pip.py
- sudo pip install virtualenv virtualenvwrapper
- sudo rm -rf ~/.cache/pip
- Then, update your ~/.profile file to include the following 3 lines:
- # virtualenv and virtualenvwrapper
- export WORKON_HOME=$HOME/.virtualenvs
- source /usr/local/bin/virtualenvwrapper.sh
- Reload profile:
- source ~/.profile
- mkvirtualenv cv
- sudo apt-get install python2.7-dev
- pip install numpy (zzz... 45min)
- Download and Install OpenCV:
- wget -O opencv-2.4.10.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 BUILD_NEW_PYTHON_SUPPORT=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON ..
- ???this or the last one??? 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 ..
- Compile OpenCV:
- make (zzz... 9h)
- sudo make install
- sudo ldconfig
- Check if installtion is ok:
- ls /usr/local/lib/python2.7/dist-packages
- But in order to utilize OpenCV within our cv virtual environment, we first need to sym-link:
- cd ~/.virtualenvs/cv/lib/python2.7/dist-packages/
- ln -s /usr/local/lib/python2.7/dist-packages/cv2.so cv2.so
- ln -s /usr/local/lib/python2.7/dist-packages/cv.py cv.py
Links: