Tutorial: OpenCV v4.2.0 Installation in Windows 10
Install OpenCV and Run a Demo Program
In this story, I will download and install OpenCV v4.2.0 and run a demo program to confirm if OpenCV is successfully installed.
- Download & Install OpenCV
- Run a Demo Program Using Visual Studio with Proper Settings
1. Download & Install OpenCV & Setup Environmental Variable
- Go to https://opencv.org/releases/.
- Click “Windows” to download the package.
- Click the package to unpack the files.
- I choose C: as my file location.
- After that, there should be a folder C:\opencv.
1.3. Setup Environment Variable
- Go to Settings for Windows 10.
- Search “View Advanced System Settings”, and click it.
- In the System Properties, click “Environment Variables…”.
- At the System Variables, find & click “Path”, Click “Edit…”.
- Click “New” to add a new path “C:\opencv\build\x64\vc15\bin” as shown above. Then Click OK to close all popup windows.
2. Run a Demo Program Using Visual Studio with Proper Settings
2.1. Create a New Project
- Launch Visual Studio. I use VS2017, it should be similar for other versions including 2019.
- Click “File > New > Project…”
- Choose “Console App” to create a new project.
- And I choose the “x64” platform for the program.
2.2. Project Properties Setup
- In VC++ Directories, at Include Directories, add:
- Also, at Library Directories, add:
- In Linker > Input, at Additional Dependencies, for debug mode, add:
- For release mode, please add:
2.3. Test the Codes
- Add the below sample codes:
using namespace cv;
using namespace std;int main()
Mat image = Mat::zeros(300, 600, CV_8UC3);
circle(image, Point(250, 150), 100, Scalar(0, 255, 128), -100);
circle(image, Point(350, 150), 100, Scalar(255, 255, 255), -100);
imshow("Display Window", image);
- Run the code. The following should be shown which means OpenCV can be used.
My Previous Tutorials
Linux [Ubuntu Installation] [NVIDIA Driver Installation (2018) (Old)] [OpenSSH Installation] [Hard Drive Partitioning/Formatting/Mounting] [Add 1 More GPU] [TeamViewer Installation][NVIDIA Driver Installation (2019)]