#recognition #face #c #python #wrapper #unofficial #repository #wrappers #tools

dlib-face-recognition

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

12 releases

Uses new Rust 2021

0.2.3 Nov 10, 2022
0.2.2 Jan 30, 2022
0.1.7 Jun 5, 2020
0.1.1 May 29, 2020

#226 in Development tools

Download history 24/week @ 2022-08-04 40/week @ 2022-08-11 7/week @ 2022-08-18 103/week @ 2022-08-25 44/week @ 2022-09-01 60/week @ 2022-09-08 17/week @ 2022-09-15 21/week @ 2022-09-22 22/week @ 2022-09-29 34/week @ 2022-10-06 6/week @ 2022-10-13 14/week @ 2022-10-20 32/week @ 2022-10-27 31/week @ 2022-11-03 37/week @ 2022-11-10 42/week @ 2022-11-17

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

BSD-3-Clause

47KB
1K SLoC

dlib-face-recognition

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 working is here (unmaintaned; since Aug 2021).

Building

Supported Platforms

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

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

Dependencies

  • cmake
  • blas
  • 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.

The C++ library dlib will be automatically installed via dlib-face-recognition-sys .

For building, this library uses cmake , so please make sure for getting cmake .

Building Rust package

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

This will automatically download the face predictor, cnn face detector and face encoding neural network models (the fhog face detector is included in dlib and does not need to be downloaded). Alternatively, these models can be downloaded manually:

If this feature flag is enabled, the matching structs will have Default::default implementations provided that allows you to load them without having to worry about file locations.

# Install cmake on a CUDA-enabled machine ...
cargo build --features embed-all

Testing

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.

Examples

mkdir outputs
cargo run --features embed-all --example draw assets/obama_1.jpg outputs/obama_1.jpg

Dependencies

~6–8MB
~117K SLoC