Article Directory
Operating System: Windows 10
OpenCV version: OpenCV4.0.0-Beta
VS version: vs2017
1. VS2017 Community Download
https://visualstudio.microsoft.com/zh-hans/
Visual Studio IDE download windows version Community 2017
2. opencv download and install
https://opencv.org/releases.html
Download 4.0.0 Win pack, as exe file, run the installation
3. Environment variable configuration
Right-click Computer -> Properties -> Advanced System Settings -> Advanced -> Environment Variables -> System variables path, add the path:
...... \ OpenCV \ Build \ x64 \ VC15 \ bin (OpenCV vs own path and installed in accordance with version set)
my version of VS 2017, the corresponding vc15
so the path is: D: \ tools2 \ opencv \ opencv \ build \ x64 \ vc15 \ bin
Visual Studio 2015 corresponds vc14
Visual Studio 2013 corresponds VC12
Visual Studio 2012 corresponds VC11
Visual Studio 2010 corresponds vc10
4.VS Configuration
In VS File -> New -> Project, the new Windows console application
In the search box to enter VS Property Manager, open the properties manager
Expand the project -> Debug | x64-> Microsoft.Cpp.x64.user double-click to open the Properties page.
4.1 Add Directory
Click the General Properties -> VC ++ directory ->
directory containing:
Add:
D: \ Tools2 \ OpenCV \ OpenCV \ Build \ the include
D: \ Tools2 \ OpenCV \ OpenCV \ Build \ the include \ opencv2
Library Catalog:
Add:
D: \ Tools2 \ OpenCV \ OpenCV \ Build \ x64 \ VC15 \ lib
Note: D: \ tools2 my own opencv installation directory path to see their actual installation directory
4.2 Additional Dependencies
First,
open the folder opencv \ build \ x64 \ vc15 \ lib, check your computer to install the library
in VS, click General Properties -> Linker -> Input -> Additional Dependencies can
add:
opencv_world400d.lib (want to use debug versions of the library)
or
opencv_world400.lib (want to use the release version of the library)
5. Test
New Project -> windows Desktop Wizard -> select an empty project, point to determine
Solution Explorer -> right-click the project's source files -> Add New Item -> cpp file (main.cpp)
The picture (1.jpg) is added to the project directory, that is, and main.cpp same folder
#include <opencv2/opencv.hpp>
using namespace cv;
int main()
{
// 读入一张图片
Mat img = imread("1.jpg");
// 创建一个名为 "test"窗口
namedWindow("test");
// 显示图片
imshow("test", img);
// 等待时间
waitKey(20181107);
}
show result:
PS:
written after error code is displayed, as shown, into the back of the Debug x86 x64 ... it
Attached:
opencv_contrib installation tutorial:
https://blog.csdn.net/zmdsjtu/article/details/78069739
https://www.cnblogs.com/jliangqiu2016/p/5597501.html
Reference:
https://blog.csdn.net/nicewe/article/details/79173346