Jdlib a Java Wrapper for Dlib library

Introduction

Dlib is C++ library for machine learning and deep learning. Being it a header only library and we can’t compile it to shared library directly, it is impossible to expose it to java directly. Many dlib ports to many languages are exist but for Java SE I don’t see any of them works well. I started Jdlib by exposing the most dlib famous examples face HOG detector, facial landmarks, face embedding models.

Compiling Jdlib

Even there is a precompiled package on center maven central repository for MacOSX and linux binaries, I recommend to compile it manually as follow.

  1. Clone project
    $ git clone https://github.com/tahaemara/jdlib.git
  2. Compile JNI/C++ code
    $ cd jdlib/jni
    $ mkdir build
    $ cd build
    $ cmake ..
    $ make 
  3. Compile Java package via maven:
    $ cd ../../Jdlib
    $ mvn package

After that you will have the JAR file including the binaries for your platform inside Jdlib/target. You can use it inside your project after adding it manually using you IDE. For example Netbeans, In the projects window, right-click the Libraries node for the your project and then click on "Add JAR/Folder...". Then locate the jdlib jar and select it.
Or simply create a maven project and install Jdlib jar manually in your local maven center.

Compiling and running examples

  1. To run examples, we need to download the needed model for facial landmarks and face embedding extraction and save them to examples folder and uncompress them.
    $ cd examples
    $ wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
    $ wget http://dlib.net/files/dlib_face_recognition_resnet_model_v1.dat.bz2
    $ bzip2 -dk shape_predictor_68_face_landmarks.dat.bz2
    $ bzip2 -dk dlib_face_recognition_resnet_model_v1.dat.bz2
  2. Change Diectory to an example folder such as faces_clustering:
    cd examples/faces_clustering/
  3. Build the example via maven
    mvn package
  4. Run the example
    java -jar target/JdlibExamples-1.0.0-jar-with-dependencies.jar

Face Clustering Using Jdlib

Subscribe to Our Mailing List



Share:

Subscribe


Blog Tags

Follow me

Facebook Page