Step 0: Again, IÕm going to assume that you have just unboxed your Raspberry Pi 2/B+. Open up a terminal and weÕll start by updating and upgrading installedÊpackages, followed by updating the Raspberry Pi firmware: $ sudo apt-get update $ sudo apt-get upgrade $ sudo rpi-update Step 1: Install the required developer tools and packages: $ sudo apt-get install build-essential cmake pkg-config Both build-essentialÊÊand pkg-configÊÊare likely already installed, but just in case they are not, be sure to include them in your apt-getÊÊcommand. Step 2: Install the necessary image I/O packages. These packages allow you to load various image file formats such as JPEG, PNG, TIFF, etc. $ sudo apt-get install libjpeg8-dev libtiff4-dev libjasper-dev libpng12-dev Step 3: Install the GTK development library. This library is used to buildÊGraphical User Interfaces (GUIs) and is requiredÊfor the highguiÊÊlibrary of OpenCV which allows you to view images on your screen: $ sudo apt-get install libgtk2.0-dev Step 4: Install the necessary video I/O packages. These packages are used to load video files using OpenCV: $ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev Step 5: Install libraries that are used to optimize various operations within OpenCV: $ sudo apt-get install libatlas-base-dev gfortran Step 6: Install pipÊ: $ wget https://bootstrap.pypa.io/get-pip.py $ sudo python get-pip.py Step 7: InstallÊ virtualenvÊÊand virtualenvwrapperÊ: $ sudo pip install virtualenv virtualenvwrapper $ sudo rm -rf ~/.cache/pip Then, update your ~/.profileÊÊfile to include the following lines: # virtualenv and virtualenvwrapper export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh Reload your .profileÊÊfile: $ source ~/.profile Create yourÊcomputer vision virtual environment: $ mkvirtualenv cv Step 8: Now we can install the Python 2.7 development tools: $ sudo apt-get install python2.7-dev Note:ÊYes, we are going to use Python 2.7. OpenCV 2.4.X does not yet support Python 3 and OpenCV 3.0 is still in beta. ItÕs also unclear when the Python bindings for OpenCV 3.0 will be complete so I advise to stick with OpenCV 2.4.X for the time being. We also need to install NumPy since the OpenCV Python bindings representÊimages as multi-dimensional NumPy arrays: $ pip install numpy Step 9: Download OpenCV and unpack 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 Setup the build: $ 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 .. Compile OpenCV: $ make Important:ÊMake sure youÕre in theÊ cvÊÊvirtual environment so OpenCV is compiled against the virtual environment Python and NumPy. Otherwise, OpenCV will be compiled against the system Python and NumPy which can lead to problems down the line. Finally, we can install OpenCV: $ sudo make install $ sudo ldconfig Step 10: If youÕve gotten this far in the guide, OpenCV should now be installed inÊ/usr/local/lib/python2.7/site-packages But in order to utilize OpenCV within our cvÊÊvirtual environment, we first need to sym-link OpenCV into our site-packagesÊÊdirectory: $ cd ~/.virtualenvs/cv/lib/python2.7/site-packages/ $ ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so $ ln -s /usr/local/lib/python2.7/site-packages/cv.py cv.py Step 11: Finally, we can give our OpenCV and Python installation a test drive: $ workon cv $ python >>> import cv2 >>> cv2.__version__ '2.4.10' OpenCV and Python is now successfully installed on your Raspberry Pi!