Opencv is a tool for image processing. The program is written in C + + language to realize the recognition algorithm, so it is necessary to configure opencv and vs environment first.
SHAINE belongs to the kind of person who can’t be counted as a halfway monk. During the three or four years of undergraduate study, she’s really half hanging, and she doesn’t know anything about the development direction. As a giser, it will inevitably involve development and graphics and image processing. Therefore, SHAINE plans to take this opportunity to start a small project by herself, starting from the needs, existing research status and referenced classical algorithms, re learn GIS development and preliminarily learn the relevant contents of OpenCV.
It took four or five days to download and install the software. It also configured the environment according to the online configuration tutorial. During the test, various exceptions were thrown and various references were incorrect, that is, it was not successful. SHAINE was puzzled at that time. Because I only learned C and c# two programming languages when I was an undergraduate, and I learned very little, and I didn’t understand C + +, which is a big obstacle. Unfortunately, the system was reinstalled and the configuration was restarted. Therefore, the lesson Shane learned is:
1. When installing the software and configuring the environment according to the online tutorial, you must first read the whole process, have a general understanding, understand its principle, and avoid pasting and copying the contents of some operation steps step by step, because everyone’s computer folder and naming are different. Only when you understand its principle can you suit the remedy to the case in 32 / 64 bit selection, version, etc, Otherwise, it will only embark on the road of constantly reconfiguring, reinstalling and even reinstalling the system.
2. Try to install only one stable and compatible version of each software on the computer, and do not install two or three versions to support the memory. Shane taught you a lesson with blood. At that time, Shane installed three different versions of VS2010 / 2013 / 2015. Do you think Shane was full and supported?
3. When installing any software, do not appear folders named in Chinese characters, whether you are installing Chinese software or English software, because once folders with Chinese names appear during the installation of English software, errors are likely to occur in path identification, so for the sake of insurance, you’d better name them in English.
4. When two or more software are involved in environment construction, it is best to find out the matching versions of the two software on the Internet before downloading and installing. For example, opencv configures vs, opencv3 2. We need vs2015 to configure, because only vc14 in vs2015 can match VC in opencv, and we can directly call the compiled class library in the software package, otherwise we have to compile manually.
Well, SHAINE is not talking nonsense. Let’s talk about the configuration steps of OpenCV and vs first.
1、 Download and installation of installation package
Opencv can be downloaded from the official website for free. Opencv is a foreign software. Due to resource constraints, the download may be slow or even fail. It’s OK. Just download it again directly.
Attach a link to the official website:http://opencv.org/downloads.html
About installation, it’s better to decompress. As shown in the figure, just unzip it directly to the target folder.
Vs2013 must have been contacted by every developer and installed n times. Shane won’t repeat it here.
2、 Configuration of environment variables
Computer → right click Properties → advanced system settings → advanced → environment variables, in the user variable, click new, the variable name is opencv, and the variable value is: D: \ software \ opencv \ build (i.e. the build file path you installed openCV); system variable path, click Edit, and add D: \ software \ opencv \ build \ x86 \ vc12 \ bin.
Note: whether your system is 32-bit or 64 bit, x86 is selected as the path directory, because 32-bit compilation is used for compilation.
3、 New visual c + + Project
Open vs, create a new project, select VC + + under the template, and create a new Win32 console application. Jump out of the application wizard, click next, check the empty item in the additional options, and click finish. (the purpose of checking the blank item is to create a template for the following settings, so you don’t have to configure it every time you create a project)
Create a new C + + file (. Cpp file) in the source file of the solution.
In the attribute manager, do the following:
In debug Win32 Microsoft Cpp. Win32. Double click user to enter the property page and make the following settings:
1. General properties → VC + + Directory:
Add to include directory:
D:\Software\opencv\build\include\opencv2
D:\Software\opencv\build\include\opencv
D:\Software\opencv\build
Add: D: \ software \ opencv \ build \ x86 \ vc12 \ lib to the library directory
2. General attribute → linker → input → attach dependency, and input items in lib Library in dependency Lib file name:
opencv_calib3d2413d.lib
opencv_contrib2413d.lib
opencv_core2413d.lib
opencv_features2d2413d.lib
opencv_flann2413d.lib
opencv_gpu2413d.lib
opencv_highgui2413d.lib
opencv_imgproc2413d.lib
opencv_legacy2413d.lib
opencv_ml2413d.lib
opencv_nonfree2413d.lib
opencv_objdetect2413d.lib
opencv_ocl2413d.lib
opencv_photo2413d.lib
opencv_stitching2413d.lib
opencv_superres2413d.lib
opencv_ts2413d.lib
opencv_video2413d.lib
opencv_videostab2413d.lib
Microsoft.com on release Win32 Cpp. Win32. Double click user to enter the property page and perform the same operations as those in debug. In fact, the above are all lib files under D: \ software \ opencv \ build \ x86 \ vc12 \ lib. You will find that some are followed by D and some are not. This is because there is d in debug and no D in release.
4、 Final test
Shane tests the accuracy of the entire configuration process by displaying a picture.
Create a new one Cpp file, enter the following code:
Pay attention to the input format of the image path of the code certificate. The original directory of the images in Shane is as follows: D: \ Lihong \ blind way recognition \ myproject \ test1_ 0228 ; But have you noticed that in the input of the whole path, all “\” become “\ \”, and “\ \” should be added even when adding the file name.
The operation results are as follows:
So far, the whole configuration process has been successfully completed.
5、 Other instructions
During the test, you may encounter the following problems like SHAINE:
1. In VC + + “skip when finding precompiled header”
The reason for this is that “StdAfx. H” is not added #include in the front line of cpp file. The solution is:
Method 1: remove the precompiled header
Project → attribute → configure attribute → C / C + + → precompiled header → create and use precompiled header → do not use precompiled header
Method 2: add the included file to the precompiled header StdAfx H file
Law 3: in every CPP contains the precompiled header StdAfx H file
Note: #include “StdAfx. H” must be added to the first line of the cpp file.
2. After debugging the solution, a pile of similar to window \ syswow64 \ gdi32 will appear DLL could not find or open the pdb file because of a problem The DLL library is not properly linked so that the relevant classes cannot be called during debugging
Debugging → options and settings → debugging → general → check “enable resource server”
Debugging → options and settings → debugging → general → check “Microsoft symbol server”
In fact, in the end, even if Shane has run the whole test project, there are still a few DLLs that cannot be called. Shane is also very headache and depressed. She has to keep looking for reasons.
Note: after many experiments, SHAINE always reported the errors in the figure below. Later, she consulted a senior student. The reason is that too many configurations may lead to the error of additional dependencies. She deleted the contents of additional dependencies and added them again without checking the options in the lower left corner. Save the settings and vs, close the project and reopen it to solve the problem.
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support developpaer.