The Dlib library is a very powerful open source library with detailed documentation and C + + code, as well as some interface with Python, but the installation and configuration process is a little cumbersome and there are some tutorials on the web, but most sporadic are not comprehensive. The author personally put all the pits have stepped over, a more comprehensive tutorial, for everyone to reference
1. Download the installation package
First download the latest library files on the Dlib website http://dlib.net/, the left column is the menu bar, including the use of dlib, compile a few, Python interface and other detailed instructions, you can see that the library's application scenarios include API packaging, image processing, linear algebra, Machine learning, network programming, such as several large scenes, each scene has a small classification, cannot help but sigh dlib library powerful.
I downloaded the dlib-19.7, unzip the files, put the extracted folder with any folder, the path does not contain Chinese
2, the establishment of the control station project
Open Visual Studio 2017 (similar to the configuration process for other versions) to establish a console project. At this point, if the code directly in the example directly copied into, will report various errors, first of all, the error is unable to enter the Dlib library files to find the various header files
3. Contains dlib corresponding folder
We need to add the Lib path that we just unzipped in the project properties, note that the dlib-19.7 is added instead of the dlib-19.7/dlib, because the former contains a lot of content except the Dlib library, and to avoid the trouble later, it directly contains dlib-19.7
Right-side Solution Explorer, right-click on the project, properties->vc++ directory, include directory, reference directory, library directory all add dlib-19.7 folder path, click to confirm
4. Add Dlib.lib
You can find that the previous red and red wavy line errors are gone, but when compiling, the following error occurs.
Probably read the error content and the type of error, can be judged because of the lack of dlib.lib file caused. The following need to make dlib.lib, of course, there are online, but not necessarily the latest dlib, suggest their own production, nor trouble
5. Making Dlib.lib
We need to use CMake software, CMake is a cross-platform compilation tool that makes it easy to make library files, go to the official website (https://cmake.org/download/) to download, download versions that match the number of operating system bits
After the download is complete, start the installation, the first line of the dlib-19.7 folder in the Dlib folder, Dlib_building2 is an empty folder for the file after the completion of the production
Click Generate, select the corresponding VS version number, click Finish, the library file creation begins
When the following words appear, the production is completed
When you are finished, locate the Dlib_building2 folder and open it with vs2017 dlib.vcxproj
Right-click Rebuild,
In the folder you just found the debug folder, there is a need lib file
Enter the original project, right-click into the Properties page, modify two places, in the General tab under the linker in the additional library directory, add the previously generated dubug path.
Add Dlib.lib in additional dependent items in the Input tab of the connector
6. Add source and modify STADFX properties
It is best to go to this step and do most of the work, but if the following error occurs
Error LNK2001: unresolved external symbols User_error__missing_dlib_all_source_cpp_file__or__inconsistent_use_of_debug_or_enable_asserts_preprocessor _directives
That means you need to join the Source.cpp file, we add the existing item in the same way, the file is located under the dlib-19.7 folder
This is the author met with such a mistake:
This error seems simple, but when you add "stdafx.h" header file, there will be other precompiled errors, the implementation of trouble, the author after looking at various materials, as well as their own attempts to find the simplest way is to right-click on the Source.cpp file, point "properties", Change the precompiled header setting to not use
If you encounter such a problem:
***\dlib\all\source.cpp:fatal error C1128: The number of sections exceeds the object file format limit : Please use /bigobj to compile
is resolved as follows
7. Successful operation
Run the sample program directly (http://dlib.net/gui_api_ex.cpp.html), you can get a graphical user interface, you can see that this is a mouse click and count a program, each click on the button, will be the number plus a
7, Graphics processing class configuration
The above configuration can meet the needs of non-graphics processing, but if your program in the algorithm needs to deal with pictures, such as you want to face recognition or object detection, need to read pictures, then please continue to look down
This error may be encountered at compile time.
You must #define Dlib_jpeg_support and link to libjpeg to read JPEG files.
do the-following the instructions at http://dlib.net/compile.html.
Note that you must cause Dlib_jpeg_support to be defined Foryour entire project.
So don ' t #define it in one file. Instead, add it to thec/c++->preprocessor->preprocessor definitions
field in Visual Studio's property Pages windows so it takes effect for yourentire application.
Here's how to fix it:
Add the missing item in the comment
If the following error is reported:
\dlib\dlib-19.4\dlib\image_loader\jpeg_loader.cpp: Fatal error C1083: cannot open include file : "Jpeglib.h": No such file or directory
You need to add dlib_jpeg_static as described above.
Detailed configuration of the installation process based on the Dlib Library of visual studio2017 in Windows systems