Opencv3 installation and configuration
Description: just beginning to learn opencv, I would like to record every step left, and able to motivate yourself to learn, so wanted to write opencv series of articles.
1. Using the development environment
windows操作系统
VS2019
Opencv3.4.9
Installation procedure
Download and install Opencv SDK 2.1
Opencv SDK to the official website Opencv be downloaded from the release version download opencv needed, I chose opencv-3.4.9 windows version. Download as https://opencv.org/release
After the download is complete, you can get a opencv3xxx.exe run, this process is actually more like a decompression process, a package will extract to set your installation directory such as D: / opencv
2.2 Configuration Environment
Find My Computer -> Right [Property] -> Advanced System Settings -> Environment Variables, find the path inside, add environment variables
Add D environment variables at: \ opencv \ opencv \ build \ x64 \ vc15 \ bin
2.3 Configuration of a directory VS2019
Creating Project Files
Create a new project in VS2019, such as I named Opencv-sample. Create a new cpp file in the source file, for example named test1.cpp
Add include directory
In Solution Explorer interface, locate items (such as Opencv-sample) you have created, right click and choose [Properties], [Configuration Properties] in find [Vc ++ directory], in [the directory containing], add the following three paths
D:\opencv\build\include
D:\opencv\build\include\opencv
D:\opencv\build\include\opencv2
Add lib directory
The method is substantially similar to the previous, the library catalog to find [] in [Configuration Properties], add
D:\opencv\build\x64\vc15\lib
Here is the x64 and you actually running median time compiler related. Next to VS in debug / release has x64 and x32 options, this time adding the lib directory if it is x64 bit, it means that when running the x64 compiler to choose the
2.4 add a dependency
[In Solution Explorer, right [attributes]], [] configuration properties found in [linker] to find [Additional Dependencies] in [input], add
opencv_world349.lib
opencv_world349d.lib
It is worth noting:
- In the Configuration Properties page of the look is configured to debug or release, the platform is x64 or x86 platform, the configuration shown in only configured to include debug x64-bit platforms, lib, and dependencies.
- Here add dependencies name opencv_world349.lib, you should go to D: \ opencv \ find the next build x64 \ vc15 \ lib path \. Behind the numbers indicate the version, such as 349 indicates the version 3.4.9, this should be selected according to your version.
- There is dependency, with d (opencv_world349d.lib) is dependent items debug, d (opencv_world349.lib) is a release without dependency.
2.5 add dynamic link library
If you restart after configuration in front of the file, it does not require this step. Otherwise there will not be found opencv_world349.lib errors. If you do not re-start, it is imperative that all relevant dll file, copied to the windows operating system directory. That is opencv_world349.dll and opencv_world349.dll two files are copied to the C: \ Windows \ SysWOW64 and C: \ Windows \ System32 can be.
3. Code Test
Just find a picture that is placed under cpp same path, run the following procedures, opencv to test whether the installation was successful.
#include<opencv2/opencv.hpp>
using namespace cv;
int main()
{
Mat m = imread("1.jpg");
imshow("载入图片", m);
waitKey(6000);
return 0;
}