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 build opencv4.5.4+VS2022 Development Environment

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article is about how to build an opencv4.5.4+VS2022 development environment. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.

Download and install Visual Studio

1. Go to Visual Studio2022 website and click Community2022 to download.

2. Double-click Run VS2022 installation package, click Continue, wait a few minutes.

3. After the installation program download and installation verification is completed, you will be prompted to enter this interface:

Select Desktop Development for C++ and Visual Studio Extension Development, tick the box in the upper right corner, and change the installation location.

Note: Solutions that do not modify the installation location of cached and shared components, tools, and SDKs:

Open the registry editor WIN + R --> regedit (or search the registry editor directly, enter regedit), find the SharedInstallationPath entry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\Setup, and delete it directly. Then open vs installer and you can change the installation location.

II. Download of opencv library

1. OPENCV official website, click Releases in Library

2. Select Windows version and start downloading after counting seconds.

3. Double-click the installation package to install

4. Open the folder after installation is like this

build is a library file that OpenCV uses.

sources is OpenCV official for us to provide some demo sample source code

3. Modify path environment variable

Difference between VC14 and VC 15

VC14, Visual Studio 2015 Compiler

VC15, Visual Studio 2017 Compiler

1. After putting the OpenCV folder in place, select this computer-> Properties-> Advanced System Settings-> System Variables, find the Path variable, select it and click Edit, then fill in the path of your OpenCV execution file, and then confirm all the way, so that the environment variables are configured.

xxxx\opencv\build\x64\vc15\bin

xxxx\opencv\build\x64\vc15\lib

IV. Configuration files

If the environment variables are configured correctly, there is no need to enter this section after a restart. That is to say, after completing the above configuration, restart once, jump directly to "V. Configure VS2019" to see if the configuration is successful.

Of course, if you don't want to restart and want to see if the configuration is successful immediately, you have to configure this step.

Copy the opencv_world452.dll and opencv_world452d.dll files under the directory xxxx\opencv\build\x64\vc15\bin (yours may not be identical, you just need to find opencv_worldxxx.dll and opencv_worldxxxd.dll) to the directory: (my system is 64 bits)C:\Windows\SysWOW64.

Note: If Windows is installed on drive C.

The path for 32-bit systems is C:\Windows\System32;

The path for 64-bit systems is C:\Windows\SysWOW64.

Why copy?

When VS compiles, it will default to this folder to find the corresponding library files.

V. VS configuration

1. Open vs2022 software, create a new c++ empty project, and then add a main (name yourself).cpp source file.

2. Click View-> Property Manager

3. Create your own profile

Debug| 64: Represents a configuration file in Debug mode on a 64-bit operating system.

Header file path, library path, library file name.

4, and then configure the property table: VC++ directory-> include directory. (header file path)

xxxx\opencv\build\include

xxxx\opencv\build\include\opencv2

VC++ Directory-> Library Directory (library file path)

xxxx\opencv\build\x64\vc15\lib

Linker: Add name of library: opencv_worldxxxd.lib

The next d: represents the debug version of the library. (Select opencv_world450d.lib for Debug and opencv_world450.lib for Release)

Suffix lib remember to write it up

VI. Test Use//Open Camera Sample #include #include #include using namespace cv; int main(){ VideoCapture cap(0); Mat frame; while (1) { cap >> frame; imshow("invoke camera", frame); waitKey(30); } return 0;} Thank you for reading! About "how to build opencv4.5.4+VS2022 development environment" this article is shared here, I hope the above content can be of some help to everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!

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