#recognition #face #apple-silicon


Unofficial Rust wrappers to the C++ library dlib, face recognition tools

14 releases

0.3.2 Oct 2, 2023
0.3.1 Aug 31, 2023
0.3.0 Apr 19, 2023
0.2.3 Nov 10, 2022
0.1.1 May 29, 2020

#36 in Machine learning

Download history 26/week @ 2023-08-16 20/week @ 2023-08-23 47/week @ 2023-08-30 46/week @ 2023-09-06 22/week @ 2023-09-13 12/week @ 2023-09-20 42/week @ 2023-09-27 19/week @ 2023-10-04 16/week @ 2023-10-11 30/week @ 2023-10-18 36/week @ 2023-10-25 18/week @ 2023-11-01 110/week @ 2023-11-08 28/week @ 2023-11-15 36/week @ 2023-11-22 84/week @ 2023-11-29

260 downloads per month
Used in dlib-face-recognition-cv


933 lines


Current Crates.io Version

Inspired by a similar python library, dlib-face-recognition is a Rust library that binds to certain specific features of the dlib C++ library.

This repository will dedicate itself to improve the library's content.

These include:

  • An FHOG-based face detector.
  • A CNN-based face detector (slower, but more powerful).
  • A face landmark predictor for identifying specific landmarks (eyes, nose, etc) from face rectangles.
  • A face encoding neural network for generating 128 dimensional face encodings that can be compared via their euclidean distances.

Original Working

The original work is here (unmaintaned; since Aug 2021).


Supported Platforms

  • Linux { aarch64, x86_64 }
    • Ubuntu 20.04
  • MacOS { aarch64, x86_64 }
    • Apple Silicon (Apple M1)
  • Windows { x86_64 }
    • Windows 10

For better maintenance, please let us know whether the other platforms support it. Besides, you may claim us whether the specific platform should support it through Issues .


  • cmake
  • Blas
  • Openblas (optional; overrides blas for better performance when enabling openblas feature )
  • dlib (optional; can be skipped by enabling build-native feature)
  • lapack

For Windows, vcpkg may help building both Blas and lapack . For other platforms such as Linux, package managers should support installing them.

Building Native library

dlib-face-recognition requires dlib to be installed. You can either provide a existing system-wide installation, or build it with this library.

  • To build it in compile-time:
    • cargo build --features build-native
  • To use a system-wide dependency:
    • cargo build

The C++ library dlib will be installed via dlib-face-recognition-sys when the build-native feature flag is enabled.

For the build, this library uses cmake , so please make sure to have cmake .

The build-native flag is disabled by default, offering increased build times.

Building Rust package

dlib-face-recognition includes a embed-all feature flag that can be used with cargo build --features embed-all .

embed-all will enable the Default::default implementations the matching structs. These will search for the /files folder, and if a file doesn't exist it will be downloaded at runtime.

It is recommended to acquire the files before compile/runtime and set them in a protected location. The embed-all flag is disabled by default, offering increased build times.


There is one included test to recognize, and draw a face's points:

  • cargo run --features embed-all --example draw -> To run the example.

There is two files to benchmark the code, and test some functions:

  • cargo test --features embed-all --test benchmarks -> To run the benchmarks.
  • cargo test --features embed-all --test utilities_tests -> To run the utilities tester.


For more information on examples: https://github.com/ulagbulag/dlib-face-recognition/tree/master/examples/README.md


~202K SLoC