当前位置:网站首页>[win10 vs2019 opencv4.6 configuration reference]

[win10 vs2019 opencv4.6 configuration reference]

2022-06-23 18:02:14A bowl of bean curd


opencv Of VS It takes only three minutes to configure the environment , But the various configurations on the Internet are dazzling , I don't know what to say opencv The compatibility of the two versions is too poor, or we should say that we are too good

I have given up treatment , Feeling VS It should still be in the garbage can , a pile BUG How nice to release
But , Who let me python Environment is the most used thing , Collected two configuration methods that have been compiled
( There will be warnings , Recommend the first , There seem to be fewer problems , At least a few dozen warnings )

My environment :

  • win10 Education
  • vs2019 Community Edition
  • opencv4.6

1. download

The website links : The website links , Maybe it's slow , But the version is relatively new
Or I also put the official website opencv4.6 Upload the CSDN: Download link

2. Add environment variables

It is recommended to add environment variables , This can reduce one VS Operating environment configuration

decompression

  • The downloaded package is a self extracting executable , Double click and select a good location to extract , Will automatically create a new... In the selected directory opencv Folder , You don't have to create it yourself
     Insert picture description here

Add environment variables

  • Right click Properties of this computer , Select advanced system settings -> environment variable - System variables , find Path double-click , Add one bin Catalog
    Be careful , Don't add wrong , yes build/x64/vc15 The one inside , No build The one in the catalog , Adding errors will not find the library file
     Insert picture description here
    Or you can choose to configure this , The system environment variables are no longer configured :
     Insert picture description here
    And to system32 How to copy folders , I can only deeply worship this

3.VS2019 To configure

There are many online configurations , The difference is that the place where the library path is added is different

The first one is

  1. Select compilation configuration ,x64 The release , Experiment with other configurations
     Insert picture description here
  2. In solution explorer, right-click the project and select properties
     Insert picture description here
  3. stay C/C++ -> Attach include directory add header file path , Both of these need to be added , Be short of one cannot , Some tutorials only add one , Self testing
D:\lib\opencv\build\include
D:\lib\opencv\build\include\opencv2

 Insert picture description here
4. Add library file path
 Insert picture description here
5. Add additional dependencies , This one doesn't have a path , There is also a suffix under the directory d Version of , yes Debug For compiling

 Insert picture description here
After adding here, you can test

#include <opencv2/highgui.hpp>
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
using namespace cv;

Test code :

	Mat img = imread("./demo.jpg");
	imshow("12345", img);
	waitKey(2000);
	destroyAllWindows();

The second kind

  1. Open the property manager
     Insert picture description here

  2. Create a new configuration table , Any name , The default configuration table may be different from others , I don't know why I should configure it like this ..
     Insert picture description here

  3. Double-click to open , Add include directory , In many tutorials, three are added here , The new version doesn't need :

 Insert picture description here

  1. Add Library Directory
     Insert picture description here

5. Add linker additional dependencies , There is no need to add a path , Just copy the library name
 Insert picture description here

  1. After the configuration is completed, it is better to restart vs
原网站

版权声明
本文为[A bowl of bean curd]所创,转载请带上原文链接,感谢
https://chowdera.com/2022/174/202206231644308969.html

随机推荐