安装 vcpkg

安装 Vcpkg 源码的 README 来:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh

安装 Dlib

./vcpkg install dlib

使用 Dlib 做人脸识别

  1. 编译实例代码

    mkdir test
    cd test
    
    ...下载 http://dlib.net/dnn_face_recognition_ex.cpp.html *内容*
    ... 保存为 dnn_face_recognition_ex.cpp
    
    cat > CMakeLists.txt <<EOF
    cmake_minimum_required(VERSION 3.0)
    project(test)
    
    find_package(dlib CONFIG REQUIRED)
    find_package(jpeg REQUIRED)
    
    add_executable(dnn_face_recognition_ex dnn_face_recognition_ex.cpp)
    target_link_libraries(dnn_face_recognition_ex PRIVATE dlib::dlib JPEG::JPEG)
    EOF
    
    mkdir build
    cd build
    cmake .. -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake
    make
    
  2. 下载模型文件

cd build curl -C - -O http://dlib.net/files/shape_predictor_5_face_landmarks.dat.bz2 curl -C - -O http://dlib.net/files/dlib_face_recognition_resnet_model_v1.dat.bz2 gunzip shape_predictor_5_face_landmarks.dat.bz2 gunzip dlib_face_recognition_resnet_model_v1.dat.bz2


3. 识别照片

```bash
./dnn_face_recognition_ex  photo.jpg