Вы находитесь на странице: 1из 3

Updated installation setup for opencv:

This pdf contains the currently updated and completely working installation process for opencv 3.1.0. The process that is explained in the video is very similar and it worked during it’s making time. It might still work in some Raspberry Pi but we suggest you to follow this method so you can have an error free and latest environment.

1. The first step is to update and upgrade any existing packages:

$ sudo apt-get update

$ sudo apt-get upgrade

2. Install cmake developer tools:

$ sudo apt-get install build-essential cmake pkg-config

3. Install some image I/O packages:

$ sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev

4. We also need to install video I/O packages:

$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev

$ sudo apt-get install libxvidcore-dev libx264-dev

5. Install the GTK development library:

$ sudo apt-get install libgtk2.0-dev

6. Install some extra dependencies:

$ sudo apt-get install libatlas-base-dev gfortran

7. Install python 2.7 header files

sudo apt-get install python2.7-dev

8. Download the OpenCV source code:

$ cd ~

$ wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.1.0.zip

$ unzip opencv.zip

9. We also need to grab the opencv_contrib repository as well:

$ wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.1.0.zip

$ unzip opencv_contrib.zip

10. Before we can start compiling OpenCV on our Raspberry Pi 3, we first need to install pip , a Python package manager:

$ wget https://bootstrap.pypa.io/get-pip.py

$ sudo python get-pip.py

11. It’s not necessary to use a virtual environment but I highly recommend it because the packages we install will not interfere with other works we might do in the future.

$export WORKON_HOME=$HOME/.virtualenvs $source /usr/local/bin/virtualenvwrapper.sh

12. update the ~/.profile

$ echo -e "\n# virtualenv and virtualenvwrapper" >> ~/.profile

$ echo "export WORKON_HOME=$HOME/.virtualenvs" >> ~/.profile

$ echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.profile

13. Reload the /.profile

$ source ~/.profile

14. Create your Python virtual environment:

$ mkvirtualenv cv -p python2

15. Install numpy

$ pip install numpy

16. Compile and Install OpenCV

$ cd ~/opencv-3.1.0/

$ mkdir build

$ cd build

$ cmake -D CMAKE_BUILD_TYPE=RELEASE \

-D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules \ -D BUILD_EXAMPLES=ON

17. Compile OpenCV:

$ make -j4

18. OpenCV should now be installed in and You can verify this using the ls command:

$ ls -l /usr/local/lib/python2.7/site-packages/

The final step is to link the cv.so file to the directory where we will
The final step is to link the cv.so file to the directory

The final step is to link the cv.so file to the directory

The final step is to link the cv.so file to the directory where we will be
where we will be running our python bindings.

where we will be running our python bindings.

19.

$ cd ~/.virtualenvs/cv/lib/python2.7/site-packages/

$ ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so

20. You can test your opencv now by opening a python compiler

$ python

>import python

>

>>> cv2

version

This will show up the version of the cv installed.

Note : As a result of our update the source codes previously given in

the upcoming lectures will throw some errors. So please refer to the

alternate code that has been uploaded if you have followed the

 

installation process given in this pdf.