mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2026-05-11 09:38:09 +02:00
Implements a Match-on-Host driver for the FocalTech FT9362 fingerprint sensor (USB 0x2808:0xc652). The driver uses FpDevice with a custom NCC-based matcher instead of NBIS, as the 64x80 sensor at 188 DPI does not yield enough minutiae for reliable NBIS matching. Enroll captures 10 images stored individually in FpPrint as a raw byte array. Verify performs a single capture and computes normalized cross-correlation with a ±10px search window against each enrolled template; the maximum NCC score across all templates is compared against a threshold of 0.50 to report match or no-match. Identify applies the same NCC approach across all prints in the gallery and returns the best-matching one above the threshold. Add an umockdev driver test using a synthetic pcapng recording (gradient image, NCC=1.0) that covers open, enroll (10 stages), and verify.
57 lines
1.6 KiB
Python
57 lines
1.6 KiB
Python
#!/usr/bin/python3
|
|
|
|
import traceback
|
|
import sys
|
|
import gi
|
|
|
|
gi.require_version('FPrint', '2.0')
|
|
from gi.repository import FPrint, GLib
|
|
|
|
# Exit with error on any exception, included those happening in async callbacks
|
|
sys.excepthook = lambda *args: (traceback.print_exception(*args), sys.exit(1))
|
|
|
|
ctx = GLib.main_context_default()
|
|
|
|
c = FPrint.Context()
|
|
c.enumerate()
|
|
devices = c.get_devices()
|
|
|
|
d = devices[0]
|
|
del devices
|
|
|
|
assert d.get_driver() == "focaltech"
|
|
assert not d.has_feature(FPrint.DeviceFeature.CAPTURE)
|
|
assert d.has_feature(FPrint.DeviceFeature.IDENTIFY)
|
|
assert d.has_feature(FPrint.DeviceFeature.VERIFY)
|
|
assert not d.has_feature(FPrint.DeviceFeature.DUPLICATES_CHECK)
|
|
assert not d.has_feature(FPrint.DeviceFeature.STORAGE)
|
|
assert not d.has_feature(FPrint.DeviceFeature.STORAGE_LIST)
|
|
assert not d.has_feature(FPrint.DeviceFeature.STORAGE_DELETE)
|
|
assert not d.has_feature(FPrint.DeviceFeature.STORAGE_CLEAR)
|
|
|
|
d.open_sync()
|
|
|
|
template = FPrint.Print.new(d)
|
|
|
|
def enroll_progress(*args):
|
|
print("finger status: ", d.get_finger_status())
|
|
print('enroll progress: ' + str(args))
|
|
|
|
# Enroll, then verify
|
|
print("enrolling")
|
|
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
|
|
p = d.enroll_sync(template, None, enroll_progress, None)
|
|
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
|
|
print("enroll done")
|
|
|
|
print("verifying")
|
|
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
|
|
verify_res, verify_print = d.verify_sync(p)
|
|
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
|
|
print("verify done")
|
|
assert verify_res == True
|
|
|
|
d.close_sync()
|
|
|
|
del d
|
|
del c
|