Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use VS2022 to permanently configure the OpenCV development environment

Shulou Source: shulou.com Published: 2022-06-01 19:13:09 10月02日 Update

This article will explain in detail how to use VS2022 to permanently configure the OpenCV development environment, Xiaobian thinks it is quite practical, so share it with you as a reference, I hope you can gain something after reading this article.

Download opencv

Go to https://opencv.org/releases/and download the Windows installation files for your version. Note: Try not to choose the latest version, but choose the older two versions of the installation package (the latest version of the installation package may prompt missing.dll file)

Installation process is easy, omitting

Add environment variables

Add the environment variable %opencv%\build\x64\vc15\bin where %opencv% is the location of your own opencv folder

Add Project Property Sheet

Open an existing VS project in the bottom left corner-Property Manager-DeBug| Right-click on X64-Add new item property sheet. Then set a name such as Debug_x64_opencv.props and save it.

profile table

Right-click the attribute sheet you just added and click Properties. Add %opencv%\build\include\opencv2 and %opencv%\build\include, %opencv % for your own opencv directory in Common Properties-VC++ Directory-General-Include Directory

Add %opencv%\build\x64\vc15\lib to Common Properties-VC++ Directory-General-Library Directory, %opencv% is your own opencv directory.

Add %opencv%\build\x64\vc15\lib\opencv_world451d.lib to Common Properties-Linker-Input-Additional Dependency, %opencv% for your own opencv directory. Different versions of the file name is different, just need to fill in your version of the opencv folder of the file name can be. Note that it must be ***d.lib, because only d.lib corresponds to the dubug version

Click OK to save the attribute sheet and test it. Make sure to select DeBug when running| x64

#includeusing namespace cv;int main(){ Mat test = imread("test.jpg"); //load image to test imshow("test", test); waitKey(0); return 0;}

Normal display image indicates successful configuration.

Quick configuration in new projects

In a new project, just right-click DeBug in the Properties Manager.| x64-Add an existing property table-Select the property table we just configured Debug_x64_opencv.props to quickly complete the configuration

Configure Release Mode

Just now we configured only in DeBug| x64 running, below we configure Release| x64 property sheet, available in Release| x64 is running.

In the Properties Manager, right-click Release| x64-Adds a new project property sheet. Then set a name such as Release_x64_opencv.props and save it.

Right-click on the newly created property sheet-Properties, and the settings in "Common Properties-VC++ Directory-General-Contains Directory" and "Common Properties-VC++ Directory-General-Library Directory" are the same as above.

Add %opencv%\build\x64\vc15\lib\opencv_world451.lib to Common Properties-Linker-Input-Additional Dependency, %opencv% for your own opencv directory. Different versions of the file name is different, just need to fill in your version of the opencv folder of the file name can be. Note that it must be ****.lib, because only.lib corresponds to the Release version.

Click OK to save the attribute sheet and test it. Be sure to select Release when running| x64

In a new project, just right-click Release in the Properties Manager.| x64-Add an existing property table-Select the property table Release_x64_opencv.props we just configured to quickly complete the configuration

About "how to use VS2022 permanent configuration OpenCV development environment" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it to let more people see.

Tags: Properties configuration directory version file selection project environment different general file name management run folder article permanent development variable only name Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB macOS MySQL Apple NVidia