How to build vs2015 and OpenCV development environment
Editor to share with you how to build vs2015 and OpenCV development environment, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. Be sure to install vs2015 to disk C (problems such as not finding the library when installing to other hard drives), select Custom installation-> next-> programming language, and select visual C++ (note that nothing else is selected, all other check boxes are removed)-> next step. The installation is complete.
two。 Download opencv, download opencv-3.1.0.exe from www.opencv.org, then extract to the specified directory and copy the path D:\ opencv\ build\ x64\ vc14\ bin, right-click my computer-> Properties-> Advanced system Settings-> Environment variables-> system variables-> Select "Path", click Edit, add ";" and the path you just copied. And click on it all the time.
3. Open vs2015, select New Project-> Visual projects-> Win32 console Application, fill in the name test- > Select Project location-> OK-> next-> check "empty Project"-> finish. Select the project you just created, then select "View"-> "property Manager" in the vs2015 menu bar, see the project under the property manager on the left open "Debug | x64", select "Microsoft.Cpp.x64.user" right-click, select "Properties"; select "VC++ Directory" in the Microsoft.Cpp.x64.user property page
1)。 Select "include directory" on the right, click "edit", add the path "D:\ opencv\ build\ include\ opencv", "D:\ opencv\ build\ include\ opencv2", "D:\ opencv\ build\ include", and then click OK.
2)。 Select the library directory on the right, click Edit, add the path D:\ opencv\ build\ x64\ vc14\ lib, and then click OK.
Select "Linker"-> "input"-> attach dependencies-> Edit, fill in "opencv_world310d.lib" (the library is in the directory D:\ opencv\ build\ x64\ vc14\ lib), click OK, click OK, and then close the property manager on the right. Click solution Explorer-> Select Source File, select add-> New item, fill in the name "main.cpp", click "add", and write down the following
# include
# include
Using namespace cv
Int main (int argc, char** argv) {
Return 0
}
Next to "Debug" in the menu bar, change "x86" to "x64". Then the cpp file will not be incorrectly underlined.
Add the following test to the main function:
# include
# include
Using namespace cv
Int main (int argc, char** argv) {
Mat src = imread ("D:/visual studio 2015_Projects/testopencvinstall/test1.jpg")
If (src.empty ()) {
Printf ("could not load image...\ n")
Return-1
}
NamedWindow ("test opencv setup", CV_WINDOW_AUTOSIZE)
Imshow ("test opencv setup", src)
WaitKey (0); return 0
}
These are all the contents of the article "how to build a vs2015 and OpenCV development environment". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!