Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use VS2022 to permanently configure the OpenCV development environment

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report