Install OpenCV-Python on Windows

Install OpenCV-Python on Windows

In this article, you will learn to setup OpenCV-Python in your Windows system.

Below steps are tested in a Windows 7-64 bit machine with Visual Studio 2010 and Visual Studio 2012. The screenshots shows VS2012.

Installing OpenCV from prebuilt binaries

1 - Below Python packages are to be downloaded and installed to their default locations.

1.1. Python-2.7.x.> 1.2. Numpy.> 1.3. Matplotlib (Matplotlib is optional, but recommended since we use it a lot in our tutorials). 2 - Install all packages into their default locations. Python will be installed to **C:/Python27/.

3 - After installation, open Python IDLE. Enter import numpy and make sure Numpy is working fine.

4 - Download latest OpenCV release from sourceforge site and double-click to extract it.

5 - Goto opencv/build/python/2.7 folder.

6 - Copy cv2.pyd to C:/Python27/lib/site-packages.

7 - Open Python IDLE and type following codes in Python terminal.

>>> import cv2
>>> print cv2.__version__

If the results are printed out without any errors, congratulations !!! You have installed OpenCV-Python successfully.

Building OpenCV from source

1 - Download and install Visual Studio and CMake.

1.1. Visual Studio 2012> 1.2. CMake 2 - Download and install necessary Python packages to their default locations 2.1. Python 2.7.x> 2.2. Numpy> 2.3. Matplotlib (Matplotlib is optional, but recommended since we use it a lot in our tutorials.) Note: In this case, we are using 32-bit binaries of Python packages. But if you want to use OpenCV for x64, 64-bit binaries of Python packages are to be installed. Problem is that, there is no official 64-bit binaries of Numpy. You have to build it on your own. For that, you have to use the same compiler used to build Python. When you start Python IDLE, it shows the compiler details. You can get more *[information here]( "information here*"). So your system must have the same Visual Studio version and build Numpy from source.

Note: Another method to have 64-bit Python packages is to use ready-made Python distributions from third-parties like *[Anaconda]( "Anaconda*"), *[Enthought]( "Enthought*")* etc. It will be bigger in size, but will have everything you need. Everything in a single shell. You can also download 32-bit versions also.*

3 - Make sure Python and Numpy are working fine.

4 - Download OpenCV source. It can be from Sourceforge (for official release version) or from Github (for latest source).

5 - Extract it to a folder, opencv and create a new folder build in it.

6 - Open CMake-gui (Start > All Programs > CMake-gui)

7 - Fill the fields as follows (see the image below):

7.1. Click on Browse Source... and locate the opencv folder.

7.2. Click on Browse Build... and locate the build folder we created.

7.3. Click on Configure.

7.4. It will open a new window to select the compiler. Choose appropriate compiler (here, Visual Studio 11) and click Finish.

7.5. Wait until analysis is finished.

8 - You will see all the fields are marked in red. Click on the WITH field to expand it. It decides what extra features you need. So mark appropriate fields. See the below image:

9 - Now click on BUILD field to expand it. First few fields configure the build method. See the below image:

10 - Remaining fields specify what modules are to be built. Since GPU modules are not yet supported by OpenCV-Python, you can completely avoid it to save time (But if you work with them, keep it there). See the image below:

11 -Now click on ENABLE field to expand it. Make sure ENABLE*SOLUTIONFOLDERS* is unchecked (Solution folders are not supported by Visual Studio Express edition). See the image below:

12 - Also make sure that in the PYTHON field, everything is filled. (Ignore PYTHONDEBUGLIBRARY). See image below:

13 - Finally click the Generate button.

14 - Now go to our opencv/build folder. There you will find OpenCV.sln file. Open it with Visual Studio.

15 - Check build mode as Release instead of Debug.

16 - In the solution explorer, right-click on the Solution (or ALL_BUILD) and build it. It will take some time to finish.

17 - Again, right-click on INSTALL and build it. Now OpenCV-Python will be installed.

18 - Open Python IDLE and enter import cv2. If no error, it is installed correctly.

Note: We have installed with no other support like TBB, Eigen, Qt, Documentation etc. It would be difficult to explain it here. A more detailed video will be added soon or you can just hack around.

python opencv

What's new in Bootstrap 5 and when Bootstrap 5 release date?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Random Password Generator Online

HTML Color Picker online | HEX Color Picker | RGB Color Picker

Create a Virtual Pen and Eraser with Python OpenCV - Genial Code

Learn Free how to create a virtual pen and eraser with python and OpenCV with source code and complete guide. This entire application is built fundamentally on contour detection. It can be thought of as something like closed color curves on compromises that have the same color or intensity, it's like a blob. In this project we use color masking to get the binary mask of our target color pen, then we use the counter detection to find the location of this pen and the contour to find it.

Basic Data Types in Python | Python Web Development For Beginners

In the programming world, Data types play an important role. Each Variable is stored in different data types and responsible for various functions. Python had two different objects, and They are mutable and immutable objects.

OpenCV Python Tutorial: Computer Vision With OpenCV In Python

OpenCV Python Tutorial: Computer Vision With OpenCV In Python: Learn Vision Includes all OpenCV Image Processing Features with Simple Examples. Face Detection, Face Recognition. Computer Vision is an AI based, that is, Artificial Intelligence based technology that allows computers to understand and label images. Use OpenCV to work with image files. Create Face Detection Software. Detect Objects, including corner, edge, and grid detection techniques with OpenCV and Python. Use Python and Deep Learning to build image classifiers. Use Python and OpenCV to draw shapes on images and videos. Create Color Histograms with OpenCV

OpenCV Python Tutorial - Computer Vision With OpenCV In Python

In this OpenCV Python Tutorial article, we will be covering various aspects of Computer Vision using OpenCV in Python. OpenCV has been a vital part in the development of software for a long time. Learning OpenCV is a good asset to the developer to improve aspects of coding and also helps in building a software development career.

Python OpenCV Tutorial - Learn Computer Vision with OpenCV and Python

Python OpenCV Tutorial - Learn Computer Vision with OpenCV and Python: Introduction to OpenCV and Image Processing in Python, Image processing basics, Object detection and tracking, Deep Learning, Facial landmarks and many special applications.