Install OpenCV: ~10 min!


Disclaimers

  1. Tested on: Windows 7, Windows 10
  2. There could be other ways to get Open CV working on your Windows computer

Before installation

  1. Find you OS architecture
  2. Decide the Python version (e.g. 2.7 or 3.x)
  3. Install Anaconda, open terminal as administrator and , launch “python” and type “import numpy as np”, to test your installation
  4. Decide the version of Open CV you want to install, from the list of available versions
  5. Upgrade pip (use pip3 if using Python 3.x)

Find your OS architecture by issuing following command:

systeminfo | findstr /I type:

Install or Upgrade pip (or pip3 for Python 3.x):

python get-pip.py
python -m pip install --upgrade pip

Installation

You can install Open CV using pip or manually. Installing Anaconda should already have taken care of dependencies for Open CV.

To find the list of available versions of Open CV through pip (or pip3) I use following:

pip install opencv_python==

Which prints an informative error message as following

Collecting opencv_python==
Could not find a version that satisfies the requirement opencv_python== (from versions: 3.1.0.0, 3.1.0.1, 3.1.0.2, 3.1.0.3, 3.1.0.4, 3.1.0.5, 3.2.0.6, 3.2.0.7, 3.2.0.8, 3.3.0.9, 3.3.0.10)
No matching distribution found for opencv_python==

If your version is in the list …
{

pip install 'opencv_python==x.x.x.x...'

… and done! Skip ahead to verification.

}
else If you want to install using (Ana)conda …
{

In Anaconda command prompt

conda install -c menpo opencv

// alternatives:

source: Anaconda, Stackoverflow

}
else
{

But if you need to install a version(e.g. 2.4.9) that is not available through pip, you need to download that version, extract the files.

  • Let’s say you extracted your files to C:\opencv folder, on a 64 bit operating Windows OS and you are using Python 2.7. Navigate to C:\opencv\build\python\2.7\x86
  • Copy cv2.pyd file
  • Navigate to Anaconda Python installation path, in my case C:\Users\WildClick\AppData\Local\Continuum\Anaconda2\Lib\site-packages

}

Verification

Start Python in Anaconda terminal, type

import cv2
cv2.__version__

Related articles

  1. MSDN
  2. Read The Docs

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s