element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Make Life Accessible
  • Challenges & Projects
  • Design Challenges
  • Make Life Accessible
  • More
  • Cancel
Make Life Accessible
Blog EyeLiner - Post 3 - Installing OpenCV
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: amgalbu
  • Date Created: 25 Apr 2016 10:22 AM Date Created
  • Views 782 views
  • Likes 4 likes
  • Comments 2 comments
  • makelifeaccessible
  • make life accessible
  • python
  • eyeliner
  • opencv
  • accessibility_projects
  • make_life_accessible
Related
Recommended

EyeLiner - Post 3 - Installing OpenCV

amgalbu
amgalbu
25 Apr 2016

Previous posts

Post 1 - Introduction

Post 2 - Installing OpenCV - Prerequisites

 

At this point we have all of our prerequisites installed, so let’s grab the 3.1.0  version of OpenCV from the OpenCV repository.

 

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

 

For the full install of OpenCV 3 (which includes features such as SIFT and SURF), be sure to grab the opencv_contrib repo as well.

 

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

 

The first step in setting up Python for our OpenCV compile is to install pip , a Python package manager:

 

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

 

we can install NumPy, an important dependency when compiling the Python bindings for OpenCV. NumPy downloads and installs will take a while...

 

$ pip install numpy

 

We are now ready to compile OpenCV.

 

$ cd ~/opencv-3.1.0
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE \
 -D CMAKE_INSTALL_PREFIX=/usr/local \
 -D INSTALL_C_EXAMPLES=OFF \
 -D INSTALL_PYTHON_EXAMPLES=ON \
 -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules \
 -D BUILD_EXAMPLES=ON ..

 

Now that our build is all setup, we can compile OpenCV:

 

$ make -j4

 

The -j4  switch stands for the number of cores to use when compiling OpenCV. Since we are using a Raspberry Pi 2, we’ll leverage all four cores of the processor for a faster compilation.

However, if your make  command errors out, I would suggest starting the compilation over again and only using one core:

 

$ make clean
$ make

 

Using only one core will take much longer to compile, but can help reduce any type of strange race dependency condition errors when compiling.

Assuming OpenCV compiled without error, all we need to do is install it on our system:

 

$ sudo make install
$ sudo ldconfig

 

Provided build finished without error, OpenCV should now be installed in/usr/local/lib/python2.7/dist-packages :

 

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

 

Let’s verify that your OpenCV installation is working by importing cv2 , the OpenCV + Python bindings:

 

$ python
 >>> import cv2
 >>> cv2.__version__
 '3.1.0'

 

You can see a screenshot of my terminal below, indicating that OpenCV 3 has been successfully installed:

 

image

  • Sign in to reply

Top Comments

  • DAB
    DAB over 9 years ago +1
    Nice detailed post. I will probably try OpenCV on my PC first before trying to use it on my RPi. DAB
  • Workshopshed
    Workshopshed over 9 years ago +1
    Useful tip on the -j4 parameter. That might have been helpful on my dragonboard compile of OpenCV.
  • Workshopshed
    Workshopshed over 9 years ago

    Useful tip on the -j4 parameter. That might have been helpful on my dragonboard compile of OpenCV.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 9 years ago

    Nice detailed post.

     

    I will probably try OpenCV on my PC first before trying to use it on my RPi.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube