I want to store Zk4500 fingerprint template in k50 biometric attendance machine . I am using java for zk4000 scanner and python for communicating with attendance machine(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; } }
I am trying to store this template in 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)])
I think the main issue is in Finger print object In 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'))
But nothing is working Can anyone have an idea .
I am using this unofficial library
pip install -U pyzk
Advertisement
Answer
i found a solution the main problem was k50 was using ZkFingerprint10.0 algorithm and zk4500 was using algorithm ZkFingerprint9.0 by updating drivers of zk4500 from website https://www.zkteco.com/en/product_detail/ZKFinger-SDK-Windows.html
(not from CD) to latest version….problem was solved