Dlib is a modern C ++ toolbox containing machine learning algorithms and tools for creating complex software in C ++ to solve real-world problems. It is widely used in industry and academia, including robotics, embedded devices, mobile phones and large high-performance computing environments. The open source license for Dlib allows you to use it for free in any application. Dlib has a long history and contains many modules. In recent years, the author mainly focuses on the development of modules such as machine learning, deep learning and image processing.

A website,

dlib.net/

dlib.net/files/ source code download

Dlib.net/compile.htm… Build instructions

Github.com/davisking/d…

 

Second, the tutorial

Blog.csdn.net/Dawnfox/art… Win10 dlib installation process (c++ call library, non python version)

Blog.csdn.net/yiyuehuan/a… Dlib related issues

Jingyan.baidu.com/article/48b… Dlib machine learning library installation and use

 

3, MY personal VS2015 environment configuration (Dlib v19.1 must be VS2015 to compile)

1. Use CMake conversion to generate VS2015 project. Keep the default Settings and do not modify any parameters.

2, VS2015 open Dlib. Click on the dlib property page. There are two caveats.

(1) Configuration properties “C/C ++” general additional include directory, need to add the dlib decompression file in the external dlib directory libjpeg, libpng,zlib three file directories

D: \ My Resources \ 7 – cmakeprj \ dlib – 19.17 \ dlib \ external \ libjpeg

D: \ My Resources \ 7 – cmakeprj \ dlib – 19.17 \ dlib \ external \ libpng

D: \ My Resources \ 7 – cmakeprj \ dlib – 19.17 \ dlib \ external \ zlib

(2) Configuration properties c/ C ++ preprocessor definition in preprocessor. You need to check whether it exists

DLIB_JPEG_SUPPORT

DLIB_PNG_SUPPORT

DLIB_JPEG_STATIC

Dlibd. lib and dlib.lib are generated by Debug and Release respectively

3, VS2015 new Win32 console application project, test whether dlib library can be used.

(1) copy the Dlib source package to Win32 exe project.

(2) Win32 EXE project, configuration properties “C/C ++” in the general additional including directory

. \ dlib 19.17.. \ \ dlib dlib 19.17 \ external \ libjpeg. \ \ dlib dlib 19.17 \ external \ libpng. \ \ dlib dlib 19.17 \ external \ zlib

Be careful not to include.. \dlib-19.17\dlib, otherwise error:

***\dlib\dlib-19.4\dlib\dlib_include_path_tutorial. TXT (1): fatal error C1189: #error: “Don’t put the dlib Folder in your include path”

(3) Win32 EXE project, configuration properties “C/C ++” preprocessor in the preprocessor definition, add:

DLIB_JPEG_SUPPORT

DLIB_PNG_SUPPORT

DLIB_JPEG_STATIC

(4) Win32 EXE project, configuration properties “linker” in the general additional library directory. Add the directory where dlib.lib resides

. \ \ Win32 Dlib 19.17

(5) Win32 EXE project, configuration properties “linker” input additional dependencies. Add dlibd.lib and dlib.lib.

(6) If the link (compilation generally does not have a problem) when the following problem occurs

error LNK2001: An external symbol that cannot be parsed USER_ERROR__missing_dlib_all_source_cpp_file__OR__inconsistent_use_of_DEBUG_or_ENABLE_ASSERTS_preprocessor_directives

Add the dlib/all/source. CPP file to the Win32 exe project, and select it directly by adding existing items.

If the above problems do not occur, you generally do not need to add this file.

Add soure. CPP, compile error:

Unexpected file end encountered while looking for precompiled headers. Did you forget to add “#include “stdafx.h” to the source?

The workaround is: right-click soure.cpp, property, and do not use precompiled headers

4, how to use SQLite, download website www.sqlite.org/download.ht… , sqlite amalgamation – 3280000. Zip

Decompression, their new construction into static library, please refer to: blog.csdn.net/starelegant…

Then copy sqlite3.h to \ dlib-19.17\ dlib-sqLite.

Modify the \ dlib-19.17 \ dlib-sqlite.h header

# include < sqlite3. H > / / original

#include “sqlite3.h” //firecat after modification

5, copy \dlib-19.17\tools\visual_studio_natvis\dlib.natvis to

C:\Users\< user names >\Documents\Visual Studio 2015\Visualizers

 

Iv. MFC established the project and found memory leakage

Using WinDBG, you can detect:

1b55c8d SmartDispenser! operator new+0x0000000d 1826e7e SmartDispenser! dlib::threads_kernel_shared::thread_pool+0x0000008e 1539eb0 SmartDispenser! dlib::unregister_thread_end_handler<dlib::logger::global_data>+0x00000040 15c6e5a SmartDispenser! dlib::logger::global_data::~global_data+0x0000005a 16557cb SmartDispenser! dlib::logger::global_data::`scalar deleting destructor'+0x0000002b 15c8b51 SmartDispenser! dlib::logger::~logger+0x000000e1 1bf6968 SmartDispenser! dlib::logger_helper_stuff::`dynamic atexit destructor for 'log''+0x00000028Copy the code

Questions I submitted: github.com/davisking/d…

Solution: github.com/davisking/d…

Dlib-19.17\ Dlib \threads\threads_kernel_shared. CPP

//do_not_ever_destruct = true;
do_not_ever_destruct = false; //firecat,Detected memory leaks
Copy the code

 

5. Main functions of Dlib

The main features

  • The document is rich

    • Unlike many open source projects, Dlib provides complete and accurate documentation for each class and function. It also has a debug mode that helps you check the prerequisites for using a function. When enabled, it catches the vast majority of errors caused by incorrectly calling functions or using objects in an incorrect way.
    • Many sample programs (very useful examples!) are provided.
    • I think documentation is the most important part of a library. Therefore, if you find any unrecorded content, unclear or outdated documents, please tell the original author and the author will fix it in time.
  • High quality widely compatible code

    • Good unit test coverage. The ratio of unit test lines of code to library lines is about 1 to 4.
    • The library is regularly tested on MS Windows, Linux, and Mac OS X systems. In fact, it runs on any POSIX system and is already available on Solaris, HPUX, and BSD.
    • No other software package dependencies. All you need is the underlying API provided by the operating system out of the box.
    • No installation or configuration steps are required before using the library. For more information, see How to Compile pages.
    • All operating system specific code is isolated in the smallest possible operating system abstraction layer. The rest of the library is either layered above the OS abstraction layer or is pure ISO standard C ++.
  • Machine learning algorithm

    • Deep Learning Deep Learning
    • Traditional SMO based Support Vector Machines for Classification and Regression
    • Reduced-rank methods for large-scale classification and regression
    • Relevance Vector Machine for classification and regression
    • A universal multiclass classification tool
    • A Multiclass SVM
    • Tools for solving optimization problems related to structural Support Vector machines.
    • A structured SVM tool for Sequence labeling
    • A structured SVM tool for solving Assignment problems
    • Structured SVM tools for object detection in images and more powerful (but slower) deep learning tools for object detection.
    • SVM tool for labeling the structure of nodes in the graph (Labeling Nodes)
    • A large-scale SVM-rank implementation
    • Online Kernel RLS Regression algorithm
    • Online SVM Classification algorithm
    • Semidefinite Metric Learning
    • On-line Nucleated Centroid Estimator/Novel Detector and Off-line Support Vector One-class Classification
    • Clustering algorithms: linear or kernel K-means, Chinese Whispers clustering and Newman clustering.
    • Radial Basis Function Networks
    • Multi Layer Perceptrons
  • Numerical computation algorithm

    • Fast matrix objects implemented using expression template technology, and able to use the BLAS and LAPACK libraries when available.
    • Many linear algebraic and mathematical operations are defined for matrix objects, such as singular value decomposition, transpose, trigonometric functions, etc.
    • General unconstrained nonlinear optimization algorithms using conjugate gradients, BFGS and L-BFGS techniques
    • Levenberg-marquardt is used to solve nonlinear least squares problems
    • The box constraint derivative – free optimization was carried out by BOBYQA algorithm
    • Optimized Cutting Plane Algorithm
    • Several quadratic program solvers
    • Combinatorial optimization tools for solving optimal allocation and minimum cut/maximum flow problems and CKY algorithms for finding the most Probable parse Tree
    • A large integer object
    • A random number object
  • Graph model inference algorithm

    • Tree algorithm is added to make accurate inference in Bayesian network.
    • Gibbs sampling Markov chain Monte Carlo algorithm for approximate inference in Bayesian networks.
    • Routines that perform MAP inference in chained structures, Potts, or general factor graphs.
  • The image processing

    • Routines for reading and saving common image formats.
    • Automatic color space conversion between various pixel types
    • Common image operations, such as edge detection and morphological operations
    • SURF, HOG and FHOG feature extraction algorithms.
    • Tools for object detection in images, including frontal face detection and object posture estimation.
    • High quality face recognition
  • thread

    • The library provides a portable and simple threading API
    • A messaging pipeline for interthread and interprocess communication
    • A timer object that generates events arranged in time intervals
    • The thread object
    • The thread function
    • Loop in parallel
    • Future-oriented thread_pool
  • Network communication

    • The library provides a portable and simple TCP socket API
    • Helps you make objects for tcp-based servers
    • Iostream and Streambuf objects that enable TCP sockets to interoperate with the C ++ IOStreams library
    • A simple HTTP server object that can be used to embed a Web server in an application
    • A messaging pipeline for interthread and interprocess communication
    • Tools for implementing algorithms using the Batch Synchronous parallel (BSP) computing model
  • Graphical user interface

    • The library provides a portable and simple core GUI API
    • Many widgets are implemented on top of the core GUI API
    • Unlike many other GUI toolkits, the entire Dlib GUI toolkit is thread-safe
  • Data compression and integrity checking algorithms

    • CRC 32 object
    • MD5 function
    • Various abstract objects that represent parts of the data compression algorithm. Includes many forms of PPM algorithms.
  • test

    • Thread-safe logger object following the popular Java logger Log4J
    • Modular unit testing framework
    • Assertion macros are useful for testing preconditions
  • Other General functions

    • A type-safe object used to convert between size byte sorts
    • A command line parser capable of parsing and validating command lines with various parameters and options
    • An XML parser
    • An object that can perform a Base64 transformation
    • Many container classes
    • Serialization support
    • Many memory manager objects that implement different memory pool policies
    • A tool that allows you to easily call C ++ from MATLAB

 

C + + library books

Github.com/fffaraz/awe…