Install OpenCV with OpenCV_contrib on Windows Using Binaries

OpenCV stands for “Open Source Computer Vision Library”. It is a computer vision and machine learning library. It gives your programs the ability to see, read, manipulate and detect objects and faces in images and videos.

Installing OpenCV from source by compiling is a tedious process. To make it quick this article explains how to install OpenCV with OpenCV_contrib from binaries on windows.

Prerequisites

  • To install OpenCV you need python installed on your machine.
  • NumPy Python Library is required

If you are using anaconda. You will get NumPy pre-installed.
If you don’t have NumPy Download the latest binary from NumPy Windows Binaries for your platform
Install it using “pip install”

Both NumPy and OpenCV that you download should match your python version platform

Install NumPy

Let’s say I have downloaded “numpy‑1.17.4+mkl‑cp37‑cp37m‑win_amd64.whl” for python3.7 and 64-bit windows from Unofficial Windows Binaries For Python: NumPY. Once NumPy is downloaded open command prompt in that directory then install it using PIP

pip install "numpy‑1.17.4+mkl‑cp37‑cp37m‑win_amd64.whl"

Download OpenCV Binaries

Since we are opting to install OpenCV from binaries (pre compiled machine code). We can download binaries from “Unofficial Windows Binaries for Python“. Here you will find all prominent python libraries & frameworks pre compiled for targeted windows platforms in various versions to choose from.

Select OpenCV that suites your needs from “OpenCV Binaries

For the sake of this article I’m selecting for 64-bit, python3.7 and opencv with opencv_contrib. Make sure you are selecting the binary which contains the word “contrib” to download OpenCV with OpenCV_contrib.

 opencv_python‑4.1.2+contrib‑cp37‑cp37m‑win_amd64.whl 

Install OpenCV

Once you download the selected file, go to downloaded location for further instructions

If you are using anaconda. Open anaconda prompt instead of windows command prompt and navigate to the location where we have downloaded opencv binaries

Use pip to install downloaded python package

pip install "opencv_python-4.1.2+contrib-cp37-cp37m-win_amd64.whl"
Processing e:\al_mi_cv\opencv_python-4.1.2+contrib-cp37-cp37m-win_amd64.whl
Installing collected packages: opencv-python
Successfully installed opencv-python-4.1.2+contrib

If you have downloaded correct package, you should see “Successfully instealled .. ” message in out put

Verify OpenCV Insteallation

To verify OpenCV Installation. Open python interpreter and typing following statements

import cv2
cv2.__version__

If you are able to import without any error and see version. Yuy! you have successfully installed OpenCV and good to go to make wonders with OpenCV

Troubleshoot Install

If you get into problem installing OpenCV

  • Make sure you have installed minimal required version of NumPy
  • Make sure binaries that you are downloading are for the python your are using
    Check python version using command “python –version”

Default image
neotam
Leave a Reply