我想在k50生物识别考勤机中存储Zk4500指纹reader模板均来自zktecho

I want to store Zk4500 fingerprint reader template in k50 biometric attendance machine both are from zktecho

我想将Zk4500指纹模板存入k50生物识别考勤机。我正在使用 java 用于 zk4000 扫描仪和 python 用于与考勤机(k 50)通信。

public void onAccept(){
    if (count == 1){
        image1.setImage(imageView.getImage());

        fingerPrintTemplateForDB1 = FingerprintSensorEx.BlobToBase64(template, templateLen[0]);
        System.out.println(fingerPrintTemplateForDB1);

        ++count;
    }else
    if (count == 2){
        image2.setImage(imageView.getImage());
        fingerPrintTemplateForDB2 = FingerprintSensorEx.BlobToBase64(template, templateLen[0]);
        count = 1;
    }
}

我正在尝试将此模板存储在 fingerPrintTemplateForDB1 = FingerprintSensorEx.BlobToBase64(template, templateLen[0]);

from zk import ZK, const
from zk.finger import Finger
conn = None
zk = ZK('192.168.10.201', port=4370, timeout=5, password=0, force_udp=False, ommit_ping=False)
conn = zk.connect()
conn.disable_device()
conn.set_user(uid=6, name='ahmed f', privilege=const.USER_ADMIN, password='12345678', group_id='', user_id='6', card=0)

fingerPrintTemplateForDB1 = "Template from Zk45000"

Myfinger = {
    "uid": 6,
    "fid": 6,
    "valid": 1,
    'template': fingerPrintTemplateForDB1
}
users = conn.get_users()
for user in users:
    if user.user_id == "3":
         conn.save_user_template(user, [ Finger.json_unpack(Myfinger)])

我认为主要问题出在指纹对象 python 中:

from struct import pack #, unpack
import codecs


class Finger(object):

    def __init__(self, uid, fid, valid, template):
        self.size = len(template) # template only
        self.uid = int(uid)
        self.fid = int(fid)
        self.valid = int(valid)
        self.template = template
        #self.mark = str().encode("hex")
        self.mark = codecs.encode(template[:8], 'hex') + b'...' + codecs.encode(template[-8:], 'hex')

    def repack(self): #full
        return pack("HHbb%is" % (self.size), self.size+6, self.uid, self.fid, self.valid, self.template)

    def repack_only(self): #only template
        return pack("H%is" % (self.size), self.size, self.template)

    @staticmethod
    def json_unpack(json):
        return Finger(
            uid=json['uid'],
            fid=json['fid'],
            valid=json['valid'],
            template=codecs.decode(json['template'],'hex')
        )

    def json_pack(self): #packs for json
        return {
            "size": self.size,
            "uid": self.uid,
            "fid": self.fid,
            "valid": self.valid,
            "template": codecs.encode(self.template, 'hex').decode('ascii')
        }

    def __eq__(self, other):
        return self.__dict__ == other.__dict__

    def __str__(self):
        return "<Finger> [uid:{:>3}, fid:{}, size:{:>4} v:{} t:{}]".format(self.uid, self.fid, self.size, self.valid, self.mark)

    def __repr__(self):
        return "<Finger> [uid:{:>3}, fid:{}, size:{:>4} v:{} t:{}]".format(self.uid, self.fid, self.size, self.valid, self.mark)

    def dump(self):
        return "<Finger> [uid:{:>3}, fid:{}, size:{:>4} v:{} t:{}]".format(self.uid, self.fid, self.size, self.valid, codecs.encode(self.template, 'hex'))

但没有任何效果 任何人都可以有想法。

我正在使用这个非官方库

 pip install -U pyzk

我找到了一个解决方案,主要问题是 k50 使用的是 ZkFingerprint10.0 算法,而 zk4500 使用的是算法 ZkFingerprint9.0,方法是从网站更新 zk4500 的驱动程序 https://www.zkteco.com/en/product_detail/ZKFinger-SDK-Windows.html
(不是来自 CD)到最新版本....问题已解决