Environment:
- Hardware: Raspberry Pi III Model B, 5MP Camera Board Module
Software: RASPBIAN,OPENCV
Installation dependencies
$ sudo apt-get update $ sudo apt-get upgrade $ sudo rpi-update
Restart the system after installation is complete
$ sudo reboot
Installing OPENCV development Tools
$ sudo apt-get install build-essential git cmake pkg-config
Install OPENCV Image Library and other dependencies
$ sudo apt-get install Libjpeg-dev libtiff5-dev libjasper-dev Libpng12-dev
Install OPENCV load video Image library and other dependencies
$ sudo apt-get install Libavcodec-dev libavformat-dev libswscale-dev libv4l-dev $ sudo apt-get install Libxvidcore-dev l Ibx264-dev
Installing the GTK Dev Library
$ sudo apt-get install Libgtk2.0-dev
Installing OPENCV Additional Dependencies
$ sudo apt-get install Libatlas-base-dev Gfortran
Installing python2.7
$ sudo apt-get install Python2.7-dev
Download Unzip Opencv3.0.0 version
$ cd ~ $ wget-o opencv.zip Https://github.com/Itseez/opencv/archive/3.0.0.zip $ unzip Opencv.zip
For the full install of OpenCV 3 (which includes features such as SIFT and SURF), being sure to grab the opencv_contrib repo as well. (note:make sure your OpenCV and Opencv_contrib versions match up, otherwise you'll run into errors during compilation . For example, if I download v3.0.0 of OpenCV, then I-ll want to download v3.0.0 of Opencv_contrib as well):
$ cd ~ $ wget-o opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.0.0.zip $ unzip opencv_ Contrib.zip
Install Python Package Manager
The first step in setting-Python for we OpenCV compile is-to-install PIP, a Python package Manager:
$ sudo apt-get install Python-itools $ sudo easy install pip
I ' ve discussed both virtualenv and virtualenvwrapper many times on the Pyimagesearch blog before, especially within these Installation tutorials. Installing these packages is certainly not a requirement to get OpenCV and Python up and running on your Raspberry Pi, but I highly recommend that you install them!
Using virtualenv and Virtualenvwrapper allows you-to-create isolated Python environments, separate from your system inst All of Python. This means the can run multiple versions of Python, with different versions of packages installed to each virtual E Nvironment-this solves the "project A depends on version 1.x, but project B needs 4.x" problem this often arises in soft Ware Engineering.
Again, it's standard practice in the Python community-to-use virtual environments, so I highly suggest this you start usin G them if you is not already:
$ sudo pip install virtualenv virtualenvwrapper $ sudo rm-rf ~/.cache/pip
After Virtualenv and Virtualenvwrapper has been installed, we need to update our ~/.profile file and insert the follow ing lines at the bottom of the file:
# virtualenv and Virtualenvwrapper export workon_home= $HOME/.virtualenvs source/usr/local/bin/virtualenvwrapper.sh
Note:you ' ll likely need to run the source ~/.profile command each time your open up a new terminal to ensure your environ ment has been setup correctly.
The next step is to create our Python virtual environment where we are doing our computer vision work:
$ mkvirtualenv CV
Again, it's important to note that the CV Python environment was entirely independent from the default version of Python I ncluded in the download of Raspbian Jesse.
If you ever reboot your system, logout and log on, or open up a new terminal, you'll need to use the Workon command To re-access the CV virtual environment, otherwise you'll be using the system version of Python instead:
$ source ~/.profile $ Workon CV
- Installing the Python Scientific Computing Library
If This is the case, you need to run the source and Workon commands above.
Assuming that is in the CV virtual environment, we can install NumPy, a important dependency when compiling the PYT Hon Bindings for OpenCV. You might want to grab a cups of coffee or go for a walk while NumPy downloads and installs:
$ pip Install NumPy
Enter Workon CV mode before compiling and installing
$ Workon CV
$ cd ~/opencv-3.0.0/$ mkdir Build $ cd build $ cmake-d cmake_build_type=release \ d Cmake_install_prefix=/usr/loca L \-D install_c_examples=on \-D install_python_examples=on \-D Opencv_extra_modules_path=~/opencv_contri B-3.0.0/modules \-D build_examples=on.
$ make $ sudo make install $ sudo ldconfig
Mounting OpenCV 3 on Raspbian Jessie