Visual studio 2022 configures opencv to use C++ (for Xiaobai)

The teacher set up an image processing project, and it took a few hours for a novice who had never touched cv to match the environment, and finally it came out! ! Write a Xiaobai practical tutorial for everyone.

Download and install visual studio

Since I installed visual studio a long time ago, this part can refer to this "Visual Studio 2022 Installation and Create C++ Project" http://t.csdn.cn/3MRWi icon-default.png?t=M85Bhttp://t.csdn.cn/3MRWi

Download and install opencv

The opencv versions corresponding to different vs versions are limited, and vs2022 corresponds to opencv4.5.5

Click the link ↓ OpenCV 4.5.5 Is Now Available! - OpenCV https://opencv.org/opencv-4-5-5/

 Scroll to the bottom of the page, select the package corresponding to your own operating system, and click to download. For example, if I am win11, I can choose win pack.

 After the download is complete, there is such a file, double-click to execute

 There will be a window like this

 You can change the path to a suitable location~ After clicking Extract, opencv will be decompressed to the path you choose. Notice! ! Be sure to remember what this path is! The configuration environment will be used many times later.

I later chose to install it on the D drive. After the decompression is complete, enter the path you set and you can see such a folder, the name is opencv

 Next, the first step is to configure the environment variables! !

Search for "edit system environment variables"

 Click on "Environment Change Face"

 

 Find the path to the build folder under your opencv installation path

Let's say mine is

 Create a new user variable. The variable name is opencv, and the variable value is the path to the build folder

Add a path to the PATH value of the user variable and edit the environment variable

The new value is (your installation path)\opencv\build\x64\vc15\bin

 Add the same value to the PATH value of the system variable

 Click OK to save the environment variable configuration.

ide configuration

under! Enter visual studio to create a new C++ project. (Skip this step if you already have your own project using opencv)

 Click "Create New Project"

 Select "C++ Console Application"

 

 

 Choose a name at will, it must be all English!

After entering our project, click "Project" - "(your project name) Properties"

 Add three values ​​​​under the VC++ directory-include directory

 as the picture shows

 Add in the library directory

 Add these two values ​​in linker --input

 After clicking OK to save, the environment configuration is complete! ! Sprinkle flowers! Sprinkle flowers!

If you have any questions, please comment or chat with me privately

Guess you like

Origin blog.csdn.net/weixin_61720360/article/details/128357769