There are three steps to install OpenCV, which are as follows −
Let us define these steps one by one.
We will use OpenCV in Microsoft Visual Studio. So we must have to download Visual Studio and OpenCV.
Let us learn how to install this software first.
The first step is to download the Visual Studio on your system from its official website or follow link https://visualstudio.microsoft.com/downloads/.
Then click on the download button for downloading the Visual Studio. After installing Visual Studio, you need to download OpenCV.
The first step is to download the OpenCV on your system from its official website or follow link https://opencv.org/.
Then click on the download button for downloading OpenCV.
Once the download is completed, run the file and extract it in C Drive. The following picture will support you to understand better.
After the extraction, you will see that two folders named 'build' and 'sources' have been created. The 'sources' folder contains all the modules, include directories, examples and everything. The build folder contains all the binaries.
CMake is an open-source software tool. It is used to control the compilation process of a software system. We use CMake because it can generate platform-independent configuration files of software modules.
The first step is to download the CMake on your system from its official website or given link https://CMake.org/download/.
Then click on the download button for downloading CMake.
Once the download is completed, extract it in C drive. The figure shows the CMake extraction process.
There are the following steps to complete this process efficiently −
Firstly, launch your Visual Studio Installer device and add C++ for desktop development as a workload to your recent Visual Studio IDE version.
The next step is to set the Environmental Variables. If you do not set up the environmental variables correctly, the OpenCV will not run. There are the following steps to set the environmental variables.
In this step, you can create a new project and go for the C++ Console App template.
Once the project created and then go to the source files. A menu will open.
Then right-click on adding a new item and then another window will open.
Then we are creating a new CPP file from there. Then click on Add.
The coding Interface will be available. Now you can write C++ code here.
There are the following steps to link OpenCV with the project −
The Debug folder is located inside the 'Lib' folder, located inside the 'build' folder of OpenCV. The path is C:\opencv\build\x64\vc15\lib if you have extracted OpenCV in C Drive.