Giter Club home page Giter Club logo

dlib-face-recognition-android's Introduction

dlib-face-recognition-android

Recognize faces in android using dlib state-of-the-art face recognition model based on deep learning. The model has an accuracy of 99.13% on the LFW benchmark.

App

Face recognition is very accurate but it takes approximately 6 seconds on a Redmi4 with Snapdragon 435 and Android 7.1.

Usage

git clone --recursive https://github.com/gv22ga/dlib-face-recognition-android.git

Now you can directly open the dlib-face-recognition-app in android studio

Build JNI (Optional)

First get the required libraries

./envsetup

To build native code and copy to android studio's project manually

cd [dlib-face-recognition-android]
ndk-build -j 2
cp -r libs/* dlib-face-recognition-app/dlib/src/main/jniLibs

Please see dlib-android for more details

Dlib 19.9

This project uses dlib 19.9. Due to some c++11 issues, I had problem compiling dlib 19.9 with opencv. So I made some small changes in dlib/dlib/serialize.h, dlib/dlib/dnn/layers.h, dlib/dlib/geometry/rectangle.h, dlib/dlib/image_transforms/interpolation.h, dlib/dlib/dnn/loss.h, dlib/dlib/statistics/running_gradient.h and dlib/dlib/global_optimization/global_function_search.cpp files in dlib library.

Sample code

// recognize person
FaceRec mFaceRec = new FaceRec(Constants.getDLibDirectoryPath());
List<VisionDetRet> results = mFaceRec.recognize(image_bitmap);
for(VisionDetRet n:results) {
    Log.d(TAG, n.getLabel()); // prints the name of recognized person
}

// add person
// add the person image to dlib_rec_example/images directory with name `[PersonName].jpg`
mFaceRec.train()

Image Quality

You can change the parameters INPUT_SIZE in MainActivity.java and MAX_IMAGE_SIZE in AddPerson.java if recognition is not working accurately.

Todos

This app currently uses HOG based face detector. This detector fails to detect small faces and is not very accurate. Instead we can use CNN based face detector, which is very accurate but will take much more time.

License

MIT

Thanks

Many thanks to tzutalin for dlib-android

dlib-face-recognition-android's People

Contributors

gauravgupta22 avatar gv22ga avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.