Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fpmatch.py works only with example templates but not with my template #9

Open
1992abubacker opened this issue Nov 7, 2024 · 5 comments

Comments

@1992abubacker
Copy link

Hi myself Abu
My fingerprint sensor module is R307S
Template size is 768 bytes

I fetched latest code and please find the commits id

fpmatch commit is 888479fe33b616cb5bbfcd0ae3db04dc4298c18d

FPM commit is 9b4cb891cf3474415969976077204d534737426c

I am using fpmatch.py and there was an error in line if score > FPM_MATCH_THRESHOLD: score is not initialized with any value before reading, so changed it to avg_score and I believe this is the expected one.

Now coming to the point I will explain the problem.
Code is running smooth and with your sample 512 byte templates I got below happy path result

python - 32-bit
-----------------My template with 768 byte------------------------
First: 0, Second: 0, Average: 0
Templates do not match!
First: 0, Second: 0, Average: 0
Templates do not match!
-----------------Example template with 512 byte------------------------
First: 143, Second: 298, Average: 220
Templates match.
First: 3, Second: 0, Average: 1
Templates do not match!

I replaced my templates of 768 byte and changed FPM_CHAR_SIZE macro value from 256 -> 384 and not update FPM_TEMPLATE_SIZE value from 512 because I see it is not used anywhere in the code.

in order to verify first whether my templates are matching I used Finger_1_Template_0 in database and used the same instead of runtime user input and I was expecting 100 % match but the result says 0%

Could you please support me in this case what I missed or what I need to do.

Please find my modified python code were I have moved my templates to template.py and example templates to template_example.py

# Copyright (C) 2021, Brian Ejike, MIT License

import os
import ctypes
import sys
from template import Finger_1_Template_0, Finger_1_Template_1
from template_example import userInput, correctMatch, template1, template2
print("python - 64-bit" if sys.maxsize > 2**32 else "python - 32-bit")

FPM_CHAR_SIZE = 384
FPM_TEMPLATE_SIZE = 512
FPM_MATCH_THRESHOLD = 50

if __name__ == "__main__":
    if "add_dll_directory" in dir(os):
        os.add_dll_directory(os.path.abspath(os.path.join("..", "common")))

    arth = ctypes.WinDLL('ARTH_DLL')
    print("-----------------My template with 768 byte------------------------")
    database = [Finger_1_Template_0, Finger_1_Template_1]
    for template in database:

        first = arth.Match2Fp(bytes(Finger_1_Template_0), bytes(template))
        second = arth.Match2Fp(bytes(Finger_1_Template_0), bytes(template)[FPM_CHAR_SIZE:])
        
        avg_score = (first + second) // 2
        
        print("First: {}, Second: {}, Average: {}".format(first, second, avg_score))

        if avg_score > FPM_MATCH_THRESHOLD:
            print('Templates match.')
        else:
            print('Templates do not match!')

    print("-----------------Example template with 512 byte------------------------")
    FPM_CHAR_SIZE = 256
    database = [correctMatch, template1]
    for template in database:

        first = arth.Match2Fp(bytes(userInput), bytes(template))
        second = arth.Match2Fp(bytes(userInput), bytes(template)[FPM_CHAR_SIZE:])
        
        avg_score = (first + second) // 2
        
        print("First: {}, Second: {}, Average: {}".format(first, second, avg_score))

        if avg_score > FPM_MATCH_THRESHOLD:
            print('Templates match.')
        else:
            print('Templates do not match!')

content of template.py


Finger_1_Template_0 = [
    3, 3, 95, 16, 4, 1, 37, 1, 121, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    11, 0, 4, 0, 113, 0, 3, 15, 48, 0, 51, 63, 255, 255, 255, 255, 
    191, 238, 186, 170, 170, 170, 169, 150, 85, 86, 101, 68, 84, 81, 84, 69, 
    81, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
    96, 23, 39, 94, 56, 42, 24, 94, 39, 176, 88, 254, 58, 177, 0, 158, 
    21, 177, 194, 158, 73, 185, 64, 126, 90, 68, 27, 126, 53, 22, 172, 95, 
    61, 154, 43, 223, 89, 34, 106, 127, 28, 174, 1, 191, 96, 191, 0, 31, 
    71, 168, 86, 156, 64, 168, 0, 26, 37, 31, 89, 88, 38, 29, 129, 249, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    3, 3, 101, 16, 0, 1, 32, 1, 121, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    11, 0, 3, 0, 117, 0, 12, 195, 240, 192, 0, 63, 255, 255, 255, 255, 
    239, 251, 174, 170, 170, 170, 170, 101, 149, 85, 165, 101, 1, 81, 69, 84, 
    21, 80, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    95, 23, 39, 222, 54, 169, 152, 222, 38, 47, 217, 126, 57, 48, 129, 30, 
    20, 49, 3, 30, 71, 185, 0, 254, 87, 195, 219, 254, 52, 22, 44, 223, 
    60, 153, 172, 95, 88, 34, 42, 255, 27, 45, 66, 63, 94, 191, 0, 159, 
    70, 40, 23, 28, 63, 39, 192, 154, 36, 30, 217, 216, 37, 29, 2, 121, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
]

Finger_1_Template_1 = [
    3, 3, 95, 16, 4, 1, 37, 1, 121, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    11, 0, 4, 0, 113, 0, 3, 15, 48, 0, 51, 63, 255, 255, 255, 255, 
    191, 238, 186, 170, 170, 170, 169, 150, 85, 86, 101, 68, 84, 81, 84, 69, 
    81, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
    96, 23, 39, 94, 56, 42, 24, 94, 39, 176, 88, 254, 58, 177, 0, 158, 
    21, 177, 194, 158, 73, 185, 64, 126, 90, 68, 27, 126, 53, 22, 172, 95, 
    61, 154, 43, 223, 89, 34, 106, 127, 28, 174, 1, 191, 96, 191, 0, 31, 
    71, 168, 86, 156, 64, 168, 0, 26, 37, 31, 89, 88, 38, 29, 129, 249, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    3, 3, 101, 16, 0, 1, 32, 1, 121, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    11, 0, 3, 0, 117, 0, 12, 195, 240, 192, 0, 63, 255, 255, 255, 255, 
    239, 251, 174, 170, 170, 170, 170, 101, 149, 85, 165, 101, 1, 81, 69, 84, 
    21, 80, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    95, 23, 39, 222, 54, 169, 152, 222, 38, 47, 217, 126, 57, 48, 129, 30, 
    20, 49, 3, 30, 71, 185, 0, 254, 87, 195, 219, 254, 52, 22, 44, 223, 
    60, 153, 172, 95, 88, 34, 42, 255, 27, 45, 66, 63, 94, 191, 0, 159, 
    70, 40, 23, 28, 63, 39, 192, 154, 36, 30, 217, 216, 37, 29, 2, 121, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
]

content of template_example.py

userInput = [
    0x3, 0x1, 0x59, 0x11, 0x0, 0x0, 0xFF, 0xFE, 0xFF, 0x3E, 0xFC, 0x1E, 0xE0, 0xE, 0xE0, 0x6, 
    0xE0, 0x6, 0xE0, 0x2, 0xC0, 0x2, 0xC0, 0x2, 0xC0, 0x2, 0xC0, 0x0, 0x80, 0x0, 0x80, 0x0, 
    0xC0, 0x0, 0xC0, 0x0, 0xE0, 0x0, 0xE0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x53, 0x8A, 0x14, 0x3E, 0x3D, 0x8D, 0xD9, 0x3E, 
    0x4F, 0x92, 0x54, 0xDE, 0x3A, 0x1C, 0x59, 0xFE, 0x48, 0xAE, 0x57, 0x3E, 0x62, 0x3A, 0x68, 0xFE, 
    0x60, 0x97, 0x11, 0xDF, 0x57, 0x99, 0x68, 0x1F, 0x1F, 0x20, 0x83, 0x3F, 0x56, 0xA1, 0x94, 0x7F, 
    0x60, 0xA7, 0x52, 0xDF, 0x54, 0x27, 0xA8, 0xDF, 0x63, 0x3E, 0x53, 0xBF, 0x2F, 0x32, 0xC2, 0x5C, 
    0x28, 0xB3, 0xD9, 0xFC, 0x4D, 0x39, 0xEB, 0x6E, 0x54, 0xBA, 0x95, 0xB2, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0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0x0, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
]

template1 = [
    3, 1, 80, 24, 0, 0, 255, 254, 255, 62, 252, 30, 248, 14, 240, 6,
    224, 6, 192, 6, 192, 6, 128, 6, 128, 6, 128, 6, 128, 2, 0, 2,
    0, 6, 128, 6, 128, 6, 128, 14, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 55, 20, 6, 190, 80, 24, 153, 30,
    67, 155, 156, 126, 31, 30, 197, 62, 66, 162, 90, 158, 107, 174, 210, 254,
    72, 177, 22, 190, 58, 66, 22, 62, 50, 36, 27, 127, 91, 176, 148, 63,
    97, 63, 170, 151, 83, 65, 211, 255, 81, 10, 164, 116, 63, 146, 223, 92,
    25, 178, 4, 125, 19, 178, 156, 221, 25, 39, 68, 218, 25, 37, 28, 155,
    31, 194, 195, 251, 17, 62, 221, 150, 74, 18, 108, 247, 29, 63, 69, 209,
    25, 191, 155, 46, 18, 189, 5, 139, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    3, 1, 83, 21, 0, 0, 255, 254, 255, 254, 255, 30, 252, 14, 248, 6,
    240, 2, 224, 2, 224, 2, 192, 2, 192, 2, 192, 2, 128, 2, 128, 2,
    128, 2, 128, 2, 128, 6, 128, 6, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 83, 15, 219, 222, 56, 18, 134, 158,
    82, 151, 216, 254, 71, 155, 27, 254, 33, 30, 4, 254, 69, 33, 26, 94,
    51, 161, 219, 190, 26, 37, 196, 158, 95, 47, 83, 254, 75, 47, 150, 190,
    17, 183, 68, 30, 61, 64, 86, 62, 36, 183, 90, 127, 87, 64, 20, 191,
    22, 49, 27, 21, 28, 177, 3, 221, 65, 14, 134, 54, 20, 61, 156, 150,
    22, 60, 67, 151, 24, 65, 67, 247, 66, 18, 94, 18, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
]

template2 = [
    3, 1, 86, 22, 0, 0, 255, 254, 254, 62, 252, 30, 240, 6, 224, 6,
    224, 6, 224, 2, 192, 2, 192, 2, 192, 2, 192, 2, 192, 2, 192, 2,
    128, 2, 128, 2, 128, 2, 128, 6, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 64, 140, 225, 126, 55, 22, 134, 222,
    80, 155, 216, 190, 69, 158, 219, 222, 69, 37, 218, 62, 50, 166, 156, 30,
    75, 180, 22, 94, 92, 52, 19, 158, 26, 61, 195, 222, 63, 150, 222, 127,
    33, 161, 69, 95, 23, 181, 219, 247, 38, 56, 131, 95, 39, 188, 218, 191,
    81, 13, 227, 92, 78, 144, 232, 253, 35, 23, 134, 250, 35, 26, 95, 154,
    28, 42, 196, 218, 53, 46, 66, 154, 51, 49, 26, 218, 28, 40, 155, 219,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    3, 1, 82, 21, 0, 0, 255, 254, 252, 254, 240, 30, 224, 14, 192, 14,
    192, 14, 192, 6, 192, 6, 128, 6, 128, 6, 128, 6, 0, 2, 0, 2,
    0, 2, 128, 6, 128, 6, 128, 14, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 65, 153, 24, 62, 55, 156, 219, 158,
    35, 163, 155, 94, 103, 164, 18, 222, 81, 47, 211, 30, 62, 177, 22, 30,
    76, 193, 148, 30, 55, 34, 89, 191, 16, 51, 131, 255, 21, 67, 90, 191,
    41, 21, 198, 60, 47, 20, 94, 189, 37, 46, 154, 58, 36, 172, 66, 91,
    27, 186, 154, 59, 64, 139, 38, 88, 62, 17, 167, 214, 19, 59, 2, 244,
    51, 11, 161, 79, 58, 146, 128, 21, 62, 14, 164, 211, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
]
@brianrho
Copy link
Owner

brianrho commented Nov 8, 2024

I am using fpmatch.py and there was an error in line if score > FPM_MATCH_THRESHOLD: score is not initialized with any value before reading, so changed it to avg_score and I believe this is the expected one.

Thanks, I'll be correcting that in a bit, must've missed it when I renamed stuff and didn't test again.

I replaced my templates of 768 byte and changed FPM_CHAR_SIZE macro value from 256

With a template size of 768 bytes, I would normally assume that the template contains 3 char-files of size 256 bytes. Therefore, you should not change FPM_CHAR_SIZE but instead call Match2Fp a third time to match your input against the 3rd char-file in the template, as I explained here recently: brianrho/FPM#57 (comment)

However, I've taken a look at your template content e.g. Finger_1_Template_0 and the size of each char-file doesn't appear to be 256 bytes. Instead, if one assumes that each char-file within the template begins with the pattern "3, 3, ...", it seems there are still only 2 templates, but now of size 384 bytes. So your modification of FPM_CHAR_SIZE is correct.

Per my understanding, Match2Fp expects to receive 2 buffers of size 256 bytes, each of them being a complete char-file. In other words, since it doesn't accept a length argument, the function will process only the first 256 bytes of both passed buffers. This means that Match2Fp is processing only part of your 384-byte template currently, which is probably the reason you're getting garbage match results.

Therefore, I don't think you can use this library to match the templates generated by your sensor. You'll have to either:

  • get another sensor which generates the usual 512-byte template
  • extract the fingerprint image from your sensor and pass that to the DLL's GenChar function to generate new compatible templates. I haven't added an example to do this yet though, so you'll have to experiment in the meantime if you're up to it.
  • (there may be other options I don't see rn ...)

@brianrho
Copy link
Owner

brianrho commented Nov 8, 2024

I've pushed some corrections to the script and also attached the API manual which provides some info on both Match2Fp and GenChar.

I'm unable to test the script currently since I'm not using a Windows machine -- if you manage to test it, please let me know if it still works alright.

@1992abubacker
Copy link
Author

Thanks for the quick response.

Sure, I will try and update the result in this same thread.

Also as you suggested, I will try with other fingerprint sensor with template size of 512 byte.

@psycoxer
Copy link

psycoxer commented Jan 2, 2025

Hi,
Is there any update on this? Did you manage to find a sensor with a template size of 512 byte? I've tried R307 and FPM10A, but they had 768 and 1538 byte template sizes instead (in the same format as above, with 384 byte character size).
Trying to decompile ARTH_DLL got me nowhere. Also, can you please provide an example for using GenChar, as I couldn't get it to work.

@abu1002
Copy link

abu1002 commented Jan 2, 2025

Hi,

I managed to find 512 byte Template Finger print sensor.

Sensor name - R305

Regards,
Abu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants