• Home
  • >
  • Install
  • >
  • Install OpenCV on Windows – C++ / Python

Install OpenCV on Windows – C++ / Python

Install OpenCV on Windows with our unique EXE-based installer for C++. The Python installation is done with Anaconda.

In this blog post, we will be installing OpenCV on Windows for C++ and Python. The C++ installation is done with the help of custom setup exe files. Whereas Python installation is done with Anaconda.

Installing OpenCV from source takes up a lot of time. Depending on your hardware, and the installation configuration, it can take anywhere from 5 minutes up to 2 hours. Moreover, the installation is not a cakewalk. Hence, we have come up with a solution for Windows users – OpenCV Windows installers. These installers will only work for installing OpenCV for C++. If you want to install OpenCV for Python, you’ll find the information later in the blog.

If you want to install OpenCV 4 on Windows from source, then check out this blog post.

Install OpenCV on Windows for CPP

Step 1: Prerequisites

You need Visual Studio pre-installed on your system. You can download the latest version of Visual Studio from here. Otherwise, you can find older versions from here.

Step 2: Download the Installer

Once you have set up Visual Studio on your system, download the installer according to the Visual Studio version you have installed.

OpenCV Version Visual Studio 16 Visual Studio 15 Visual Studio 14
OpenCV-4.5.0 OpenCV-4.5.0-vc16.exe OpenCV-4.5.0-vc15.exe OpenCV-4.5.0-vc14.exe
OpenCV-4.4.0 OpenCV-4.4.0-vc16.exe OpenCV-4.4.0-vc15.exe OpenCV-4.4.0-vc14.exe
OpenCV-4.1.0 OpenCV-4.1.0-vc16.exe OpenCV-4.1.0-vc15.exe OpenCV-4.1.0-vc14.exe

Step 3: Install OpenCV on Windows

Once you download the installer, double click it to run the installer. Before the installer starts, it’ll ask you permission to run the executable. Click on More info and then on Run anyway.

Microsoft Defender SmartScreen protecting against phishing or malware files
Click on “More Info” to get the option to run the Installer
Microsoft Defender SmartScreen asking explicit permission to Run the installer anyway
Click on “Run anyway” to run the Installer

The installer starts with a welcome screen. Click on Next to read the License.

OpenCV Installer Welcome Screen
Welcome Screen

If you accept the license, click on I accept the agreement and click on Next.

OpenCV Installer License Agreement
License Agreement

Next, it’ll ask you to choose the installation folder. You can install OpenCV anywhere on the system. The default location is C:.

OpenCV Installer Select Destination
Select Installation Location

Finally, the installer will ask you for confirmation to install OpenCV on the system. Click on Install to continue.

OpenCV Installer Confirm Install
Confirm Installation
OpenCV Installer Install OpenCV on Windows

After OpenCV is installed, you can exit the installer.

OpenCV Installer Finish Installation
Finish Installation

Step 4: Execute a sample code

Once the OpenCV installation is completed, you can start coding right away. We have provided with a sample code to test the installation. Below is the code snippet.

 You can download the code using this link.

#include <opencv2/opencv.hpp>
using namespace cv;
int main(void) {
	// Read image in GrayScale mode
	Mat image = imread("boy.jpg", 0);
	// Save grayscale image
	imwrite("boyGray.jpg", image);
	// To display the image
	imshow("Grayscale Image", image);
	waitKey(0);
	return 0;
}
Download Code To easily follow along this tutorial, please download code by clicking on the button below. It's FREE!

Read Next

VideoRAG: Redefining Long-Context Video Comprehension

VideoRAG: Redefining Long-Context Video Comprehension

Discover VideoRAG, a framework that fuses graph-based reasoning and multi-modal retrieval to enhance LLMs' ability to understand multi-hour videos efficiently.

AI Agent in Action: Automating Desktop Tasks with VLMs

AI Agent in Action: Automating Desktop Tasks with VLMs

Learn how to build AI agent from scratch using Moondream3 and Gemini. It is a generic task based agent free from…

The Ultimate Guide To VLM Evaluation Metrics, Datasets, And Benchmarks

The Ultimate Guide To VLM Evaluation Metrics, Datasets, And Benchmarks

Get a comprehensive overview of VLM Evaluation Metrics, Benchmarks and various datasets for tasks like VQA, OCR and Image Captioning.

Subscribe to our Newsletter

Subscribe to our email newsletter to get the latest posts delivered right to your email.

Subscribe to receive the download link, receive updates, and be notified of bug fixes

Which email should I send you the download link?

 

Get Started with OpenCV

Subscribe To Receive

We hate SPAM and promise to keep your email address safe.​