package com.example.utils; import com.example.types.FingerprintCompareListItem; import com.example.types.VerificationResult; import com.machinezoo.sourceafis.FingerprintMatcher; import com.machinezoo.sourceafis.FingerprintTemplate; public class Verification { private static final double MATCH_THRESHOLD = 40.0; public static VerificationResult verifyFingeprint(FingerprintTemplate fingerprintData, FingerprintCompareListItem[] givenDataToMatch, FingerprintCompareListItem[] localData) { try { FingerprintCompareListItem[] fingerprintList; double bestScore = 0; VerificationResult matchedPerson = null; // If no given Data to Match then try local data to match if (givenDataToMatch == null || givenDataToMatch.length <= 0) { fingerprintList = localData; } else { fingerprintList = givenDataToMatch; } if (fingerprintList.length <= 0) { return null; } for (FingerprintCompareListItem entry : fingerprintList) { String personName = entry.getName(); int fpPosition = entry.getFingerPosition(); FingerprintTemplate candidate = entry.getFingerprint(); double score = new FingerprintMatcher(fingerprintData).match(candidate); if (score > bestScore) { bestScore = score; matchedPerson.setName(personName); matchedPerson.setFingerPosition(fpPosition); matchedPerson.setFingerprint(candidate); matchedPerson.setScore(bestScore); } } // Return response based on score if (bestScore >= MATCH_THRESHOLD) { System.out.println("Person Matched: " + matchedPerson.getName() + "Score: " + bestScore); return matchedPerson; } else { return null; } } catch (Exception e) { System.out.println("Exception Error" + e); return null; } } }