libfprint, a microservice approach
15 Nov 2019I was looking for ways to integrate fingerprinting in one of my projects some time ago when I’ve found the C library libfprint.
At the time I’d like to implement a fingerprint system using only Java or C#, but I didn’t find anything relevant. What I’ve found was a helpful bridge to use libfprint in Java applications and I’ve used that in a Spring Boot project to have some web interface.
It was not optimal in my opinion, because libfprint is totally synchronous and needs constant interaction with the users for enrollment, verification and identification, while Spring Boot rest services are intent to be asynchronous and stateless.
Now I got some time to proceed with my investigation and besides improving the overall implementation to have libfprint working with a web environment, I’d like to store the enrolled fingerprints in a database, then retrieve them later for verification and identification.
For the development, I’ve run the Spring Boot application and the MySQL database on a (Mac) machine, while the C libfprint services mentioned on the next steps run in the Raspbery pi with compatible fingerprint scanners connected to it.
I had a Raspberry Pi 3 and OS Raspian Buster and I believe that if you try it in a different OS the steps might be slightly different.
This is the architecture overview and the steps to run the demo:
We have three fingerprint services: enrollment, verification and identification. They communicate with the Spring Boot rest services that has the connections with the MySQL database and manages a websocket (queue) that updates the user web interface.
- This demo uses a MySQL database with just a table
users
.
- Set up the
application.yml
of the Spring Boot application so it points to your database:
- Install the pre-requisites in your Raspberry pi to compile libfprint:
Notice here that meson is not set automatically in the $PATH. In my installation it was available on home/pi/.local/bin/meson
(I was logged in as pi user). Double check it because it will be necessary for the compilation.
- Download libfprint v1.0 sources in your Raspberry pi and unzip it:
- Compile libfprint:
- Download and compile facil.io:
- Now we’re good to compile and run
enroll.c
,verify.c
andidentify.c
from raspi-libfprint.
You can use the same syntax to compile all of them. Just specify the name of the output and the .c file. Below for example is the compilation of the enrollment service:
- Set the environment variables WEBSERVER and WEBSERVER_PORT as super user. It is the Spring Boot application address:
- Run the enrollment, verification or identification service. You must run as super user, because libfprint needs full acess to the fingerprint scanners:
- All the
enroll.c
,verify.c
andidentify.c
expose the same port (3000), so you must change it in the source code if you want to run them simultaneously. Then change also theapplication.yml
on the Spring Boot project so it point to the correct services’ addresses and ports.
The project raspi-libfprint is available on github here. If you have any question or trouble, please create a new issue on the github project.