Convert Fingerprint Image to Template with Java


I am trying to convert a fingerprint image with format jpg to a template using the library

But I am receiving a few bytes that doesn’t look like template (Minutiae data), any suggestions to achieve this goal?

   File[] images = directory.listFiles();
            File desiredfile = null;
            for (File file : images) {
                if (file.getName().equals("images.jpg")) {
                    desiredfile = file;
     FingerprintTemplate template = null;
                        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
                            template = new FingerprintTemplate(
                                    new FingerprintImage(
                                            new FingerprintImageOptions()
                        fileLogger.log("template " + template.toByteArray());

It seems the minutiae data is hidden and we can not see the actual bytes, the library aims to use the template object for matching process.


Code should be like this.

Make sure to replace "path/to/fingerprint/images.jpg" with the actual path to your fingerprint image. The code now includes error handling for file-related operations and logs the template size to the console.

public class FingerprintConverter {
        public static void main(String[] args) {
            // Replace "path/to/fingerprint/images.jpg" with the actual image file path
            String imagePath = "path/to/fingerprint/images.jpg";
            Path imagePath = Paths.get(imagePath);
            if (!Files.exists(imagePath) || !Files.isRegularFile(imagePath) || !Files.isReadable(imagePath)) {
                System.err.println("Invalid image file: " + imagePath);
            try {
                byte[] imageBytes = Files.readAllBytes(imagePath);
                // Step 3: Extract the fingerprint template
                FingerprintImage fingerprintImage = new FingerprintImage(
                        new FingerprintImageOptions().dpi(500)
                FingerprintTemplate template = new FingerprintTemplate(fingerprintImage);
                // Logging template information
                System.out.println("Template size: " + template.toByteArray().length + " bytes");
            } catch (IOException e) {
                System.err.println("Error reading image file: " + e.getMessage());

Answered By – Bhavik Nathani

Answer Checked By – Cary Denson (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *