Description
Hi, I am using r307 fingerprint sensor. I'm trying to compare fingerprint template by uploading it to the fingerprint sensor flash storage.
I'm trying to run this example code.
Here is the piece of code from the example which I failed to run. I've already saved the fingerprint template('template0.dat') file before executing this code.
# pylint: disable=too-many-branches
def fingerprint_check_file():
"""Compares a new fingerprint template to an existing template stored in a file
This is useful when templates are stored centrally (i.e. in a database)"""
print("Waiting for finger print...")
set_led_local(color=3, mode=1)
while finger.get_image() != adafruit_fingerprint.OK:
pass
print("Templating...")
if finger.image_2_tz(1) != adafruit_fingerprint.OK:
return False
print("Loading file template...", end="", flush=True)
with open("template0.dat", "rb") as file:
data = file.read()
finger.send_fpdata(list(data), "char", 2)
i = finger.compare_templates()
if i == adafruit_fingerprint.OK:
set_led_local(color=2, speed=150, mode=6)
print("Fingerprint match template in file.")
return True
if i == adafruit_fingerprint.NOMATCH:
set_led_local(color=1, mode=2, speed=20, cycles=10)
print("Templates do not match!")
else:
print("Other error!")
return False
I got following error:
Waiting for finger print...
Templating...
Loading file template...Traceback (most recent call last):
File "/home/mockupsystem/Adafruit_CircuitPython_Fingerprint/examples/fingerprint_template_file_compare.py", line 203, in
fingerprint_check_file()
File "/home/mockupsystem/Adafruit_CircuitPython_Fingerprint/examples/fingerprint_template_file_compare.py", line 73, in fingerprint_check_file
i = finger.compare_templates()
File "/home/mockupsystem/python-env/some/lib/python3.10/site-packages/adafruit_fingerprint.py", line 323, in compare_templates
self.confidence = struct.unpack(">H", bytes(r[1:3]))
struct.error: unpack requires a buffer of 2 bytes