Java Wrapper For dlib for Linux and MacOSX. Till now the wrapper contains stubs for face HOG detector, facial landmarks, face embedding models.
This is a fork of jdlib which was initially created by Taha Emara.
This fork supports a way to run the CNN based face detection which can utilize the GPU.
<dependency>
<groupId>io.metaloom.jdlib</groupId>
<artifactId>jdlib</artifactId>
<version>2.0.0</version>
</dependency>
- Dlib installation requirements Using dlib from C++
- JDK 17 or newer
- Maven
Debian 11:
* nvidia-cuda-toolkit
* nvidia-cudnn
git clone https://github.com/metaloom/jdlib.git
# Generate needed JNI header files via mvn
mvn clean compile
# Now build JNI lib
mkdir build && cd build
# Ensure to select a compatible compiler (Example for Debian 11)
CC=gcc-10 CXX=/usr/bin/g++-10 cmake ../jni
make
mvn clean package
After that you will have the JAR file including the binaries for your platform inside Jdlib/target. Then you can use it inside your project as an external jar or install it manually in local maven.
- Download needed models to example folder
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
wget http://dlib.net/files/mmod_human_face_detector.dat.bz2
bzip2 -dk shape_predictor_68_face_landmarks.dat.bz2
bzip2 -dk dlib_face_recognition_resnet_model_v1.dat.bz2
bzip2 -dk mmod_human_face_detector.dat.bz2
- Build and run examples
cd examples
mvn clean package
java -jar target/clustering-example-jar-with-dependencies.jar
java -jar target/landmarks-example-jar-with-dependencies.jar
java -jar target/cnn-facedetect-example-jar-with-dependencies.jar
# Set release version and commit changes
mvn versions:set -DgenerateBackupPoms=false
git add pom.xml ; git commit -m "Prepare release"
# Invoke release
mvn clean deploy -Drelease