Installing OpenCV3.3 with Python3 on Windows10

Shachindra
5 min readAug 22, 2017

--

In this post we will learn how to install the latest OpenCV3.3 on Windows10 PC with Python3 using the step-by-step instructions given below:

Install the required Software and Applications:

1. Install Visual Studio 2017:

Download and Run the Installer for VS2017 (Community or Professional Version) from the link: https://www.visualstudio.com/vs/. While Installation, Make Sure, You select Desktop Development with C++ and Python Development (See the Picture below) under Workloads, then proceed with the installation.

Check the Required Tools while Installation
Select the Compiler and Build Tools

After the installation is complete, Launch the Visual Studio Application in Administrative Mode.

Launch the Application in Administrative Mode

2.Install Anaconda3 or Modify Visual Studio 2017

Anaconda is a freemium open source distribution of the Python and R programming languages for large-scale data processing, predictive analytics, and scientific computing, that aims to simplify package management and deployment. Download and install the 64-Bit version from link: https://www.continuum.io/downloads or you can choose to install it by Modifying VS2017 Installation.

Installation of Anaconda Python:

Check the Required Options

Modifying the Visual Studio 2017 Installation:

Select Modify Option
Choose Anaconda3 64-Bit

3. Download OpenCV3.3 Source Code Releases

Download and unzip the OpenCV3.3 Source Codes (.zip File) from the link: https://github.com/opencv/opencv/releases and https://github.com/opencv/opencv_contrib/releases/tag/3.3.0 to the MyDocuments Directory as, Documents\ComputerVision\OpenCV.

Download Zip Files

4. Install CMake:

CMake is an extensible, open-source system that manages the build process in an operating system and in a compiler-independent manner. Unlike many cross-platform systems, CMake is designed to be used in conjunction with the native build environment.

Download and Install CMake from link: https://cmake.org/download/ adding CMake to System Path.

Add to System Path

Run the application in Administrative Mode after installation.

5. Install Doxygen (Optional):

Doxygen is a documentation generator, a tool for writing software reference documentation.

Select Full Installation

6. Install GStreamer (Optional):

GStreamer is a pipeline-based multimedia framework that links together a wide variety of media processing systems to complete complex workflows.

Download and Install the software link: https://gstreamer.freedesktop.org/ and choose the options as as given below:

Download and Install as per requirements

7. Install VTK (Optional):

The Visualization Toolkit (VTK) is an open-source, freely available software system for 3D computer graphics, image processing and visualization. VTK consists of a C++ class library and several interpreted interface layers including Tcl/Tk, Java, and Python.

Download and Install the application from link: http://www.vtk.org/download/ and follow the instructions given on http://www.vtk.org/Wiki/VTK/Building/Windows.

Use the VS2017
Select VTK_WRAP_PYTHON and Enter VTK_PYTHON_VERSION = 3.6 (Based on your Python version)

8. Install ImageMagick (Optional):

ImageMagick is a free and open-source software suite for displaying, converting, and editing raster image and vector image files. It can read and write over 200 image file formats.

Download and Install the application from link: http://www.imagemagick.org/script/download.php and follow the instructions in the wizard to verify the successful installation.

Choose the Required Options

Configuring the OpenCV Installation using CMake and Visual Studio 2017:

  • Select the source and Build directories in CMake as:

Source: C:\Users\shach\Documents\ComputerVision\OpenCV\opencv-3.3.0

Build: C:\Users\shach\Documents\ComputerVision\OpenCV\opencv-3.3.0\build (Create a new folder named “build”)

  • To get default configurations, Click on Configure and select Visual Studio 15 2017 Win64
  • Click Finish. After this step, click Finish again without changing any default parameters. Then click Finish to generate Makefiles.
  • Set the configurations for additional CMake flags as given in the pictures below:
Check “BUILD_EXAMPLES”
Check the executable Path
Verify Python3 library and provide the path of modules directory in “ OPENCV_EXTRA_MODULES_PATH”
Select GStreamer
  • After the changes done, Click Configure Again. If there are no errors in configuration, Proceed with Generate to generate the Visual Studio Project (.sln)

Compile OpenCV3.3 using Visual Studio 2017:

You can either click on Open Project (in CMake) and Choose Visual Studio 2017 or Import the Project “OpenCV.sln” (‘build’ folder) inside Visual Studio 2017.

Proceed with building OpenCV with two configurations:

  • Debug mode — x64 platform.
  • Release mode — x64 platform.
  1. Select mode as ‘Debug’ and target as ‘x64’ in the Menu Bar. From Solutions Explorer, Under Folder CMakeTargets find INSTALL then get options to build by doing a right click and select “Build”.
  2. Repeat the above process again selecting mode as ‘Release’ and target as ‘x64’ in the Menu Bar.
Right Click INSTALL and Select Build

After the Build is complete, We proceed to verify our successful installation of OpenCV3.3 with Python3 in the next part.

Verifying the OpenCV3.3 Installation:

  • Adding the OpenCV3.3 library to System Variables and Path (Setting Environment Variables):
Add to System Variables
Add to Path
  • Open Command Prompt and execute, python.
  • Inside Python Shell, execute these commands as per the picture below:

import cv2

cv2.__version__

Verify the Installation

If you get the above results, that means the installation is successful and now you can KickStart Your Image Processing Adventures. Enjoy!

--

--

Shachindra

Blockchain Developer, Computer Vision Enthusiast and a Seasoned IoT Engineer