C# 生物指纹

C# 生物指纹,c#,asp.net,fingerprint,biometrics,C#,Asp.net,Fingerprint,Biometrics,我正在使用ZKFinger SDK2.3.3.1版本和设备 通信协议SDK(32位Ver6.2.4.1--DLL版本:zkemkeeper.DLL-6.2.4.1。我有一个小型USB指纹扫描仪。当我扫描指纹时 我得到了一个字节数组。我将它保存在一个位图文件和jpg文件中的光盘中,指纹扫描看起来很好。要将指纹模板设置为设备上的用户,我解压缩了指纹图像,然后调用zkemceeper.dll的SetUserTmp函数 I am getting size error , (-3) in code. H

我正在使用ZKFinger SDK2.3.3.1版本和设备 通信协议SDK(32位Ver6.2.4.1--DLL版本:zkemkeeper.DLL-6.2.4.1。我有一个小型USB指纹扫描仪。当我扫描指纹时

我得到了一个字节数组。我将它保存在一个位图文件和jpg文件中的光盘中,指纹扫描看起来很好。要将指纹模板设置为设备上的用户,我解压缩了指纹图像,然后调用zkemceeper.dll的SetUserTmp函数

I am getting size error , (-3) in code.

How can i go further? What is my mistake? 
下面是我将手指从USB设备转移到生物识别设备的代码

   bool fullImage = false;

            zkfpEng.SaveJPG("Myfirstfinger.jpg");

            string strtmp, sRegTemplate;
            object pTemplate;


            sRegTemplate = zkfpEng.GetTemplateAsStringEx("9");

            pTemplate = zkfpEng.DecodeTemplate1(sRegTemplate);

            // Note: 10.0Template can not be compressed
            zkfpEng.SetTemplateLen(ref pTemplate, 602);
            zkfpEng.SaveTemplate("Myfirstfingerprint.tpl", pTemplate);



            byte[] TmpData = new byte[700];

            TmpData =ObjectToByteArray(pTemplate);



            if (bIsConnected == false)
            {
                MessageBox.Show("Please connect the device first!", "Error");
                return;
            }



            int idwFingerIndex = Convert.ToInt32(cbFingerIndex.Text.Trim());

            int idwEnrollNumber = Convert.ToInt32(txtUserID.Text.Trim());
            int iTmpLength = 0;
            string sdwEnrollNumber = txtUserID.Text.Trim();


            axCZKEM1.EnableDevice(iMachineNumber, false);
            Cursor = Cursors.WaitCursor;
            bool IsSetTmp = false;

            IsSetTmp = axCZKEM1.SetUserTmp(iMachineNumber, idwEnrollNumber, idwFingerIndex, ref TmpData[0]);
            int errCode = 0;
            axCZKEM1.GetLastError(ref errCode);
            MessageBox.Show(IsSetTmp.ToString() + " " + errCode.ToString());
            if (IsSetTmp == true)
            {
                MessageBox.Show("User template set successfully!", "Success");
            }
            else
            {
                MessageBox.Show("User template not set successfully!", "Error");
            }

将FP作为字符串读取,并将相同的字符串推送到生物识别设备,而不进行任何压缩或转换。

我认为您不必像Remin所说的那样将其转换为图像文件。 这里有一些例子,我使用的是xaf和mysql数据库

private void DownloadUserInformationAction_Execute(object sender, SimpleActionExecuteEventArgs e)
    {
        IObjectSpace os = Application.CreateObjectSpace();
        Terminal terminal = (Terminal)View.SelectedObjects[0];

        //create new czkemclass obj
        CZKEMClass myCZKEMClass = new CZKEMClass();

        //connecting the device
        myCZKEMClass.Connect_Net(terminal.IPAddress, terminal.Port);

        //Initialize variable for store temporary user information
        int tMachineNo = 0;
        string tEnrollNo = "";
        string tName = "";
        string tPassword = "";
        int tPrivilage = 0;
        bool tEnabled = false;
        int tFingerIndex;
        int tFlag = 0;
        string tTemplateData = "";
        int tTemplateLength = 0;
        myCZKEMClass.EnableDevice(terminal.DeviceId, false);
        myCZKEMClass.ReadAllUserID(terminal.DeviceId);
        myCZKEMClass.ReadAllTemplate(terminal.DeviceId);
        while (myCZKEMClass.SSR_GetAllUserInfo(tMachineNo, out tEnrollNo, out tName, out tPassword, out tPrivilage, out tEnabled))
        {
            for (tFingerIndex = 0; tFingerIndex < 10; tFingerIndex++)
            {
                if (myCZKEMClass.GetUserTmpExStr(tMachineNo, tEnrollNo, tFingerIndex, out tFlag, out tTemplateData, out tTemplateLength))
                {
                    EmployeeBiometric employeeBiometric = new EmployeeBiometric(terminal.Session);
                    //employeeBiometric.EnrollNumber = tEnrollNo;
                    XPCollection<Employee> employees = new XPCollection<Employee>(terminal.Session);
                    employeeBiometric.Employee = employees.Where(emp => emp.EnrollNo == tEnrollNo).FirstOrDefault();//(emp => emp.Sequence.ToString() == tEnrollNo).FirstOrDefault();
                    employeeBiometric.UserName = tName;
                    employeeBiometric.Password = tPassword;
                    employeeBiometric.Privilege = (Privilege)Enum.ToObject(typeof(Privilege), tPrivilage);
                    employeeBiometric.Enabled = tEnabled;
                    employeeBiometric.FingerprintIndex = tFingerIndex;
                    employeeBiometric.FingerprintTemplate = tTemplateData;
                    employeeBiometric.TemplateLength = tTemplateLength;
                    terminal.Session.CommitTransaction();

                }

            }
        }
        myCZKEMClass.EnableDevice(terminal.DeviceId, true);
    }
private void DownloadUserInformationAction\u Execute(对象发送方,SimpleActionExecuteeEventargs e)
{
IOObjectSpace os=Application.CreateObjectSpace();
终端=(终端)视图。选择对象[0];
//创建新的类对象
CZKEMClass myCZKEMClass=新CZKEMClass();
//连接设备
myCZKEMClass.Connect_Net(terminal.IPAddress,terminal.Port);
//初始化用于存储临时用户信息的变量
int tMachineNo=0;
字符串tEnrollNo=“”;
字符串tName=“”;
字符串tPassword=“”;
int-tPrivilage=0;
bool-tEnabled=false;
int-tFingerIndex;
int-tFlag=0;
字符串tTemplateData=“”;
int tTemplateLength=0;
MyCzkeClass.EnableDevice(terminal.DeviceId,false);
MyCzkeClass.ReadAllUserID(终端设备ID);
myCZKEMClass.ReadAllTemplate(terminal.DeviceId);
while(myCZKEMClass.SSR_GetAllUserInfo(tMachineNo、out-tEnrollNo、out-tName、out-tPassword、out-tPrivilage、out-tEnabled))
{
对于(tFingerIndex=0;tFingerIndex<10;tFingerIndex++)
{
if(myCZKEMClass.GetUserTmpExStr(tMachineNo、tEnrollNo、tFingerIndex、out-tFlag、out-tTemplateData、out-tTemplateLength))
{
EmployeeBiometric EmployeeBiometric=新员工生物识别(终端会话);
//employeeBiometric.EnrollNumber=tEnrollNo;
XPCollection employees=新的XPCollection(terminal.Session);
employeeBiometric.Employee=employees.Where(emp=>emp.EnrollNo==tEnrollNo.FirstOrDefault();/(emp=>emp.Sequence.ToString()==tEnrollNo.FirstOrDefault();
employeeBiometric.UserName=tName;
employeeBiometric.Password=tPassword;
employeeBiometric.Privilege=(Privilege)Enum.ToObject(typeof(Privilege),tPrivilage);
employeeBiometric.Enabled=tEnabled;
employeeBiometric.FingerprintIndex=tFingerIndex;
employeeBiometric.FingerprintTemplate=t员工数据;
employeeBiometric.TemplateLength=tTemplateLength;
terminal.Session.CommitTransaction();
}
}
}
MyCzkeClass.EnableDevice(terminal.DeviceId,true);
}
这是将指纹图像从设备下载到应用程序的方法

在这里,您可以将其上传回另一台设备

private void UploadUserInformationAction_Execute(object sender, PopupWindowShowActionExecuteEventArgs e)
    {
        IObjectSpace os = Application.CreateObjectSpace();
        EmployeeBiometric employeeBiometric = (EmployeeBiometric)View.SelectedObjects[0];
        EmployeeBiometricParameter param = (EmployeeBiometricParameter)e.PopupWindowViewCurrentObject;

        //create new czkemclass obj
        CZKEMClass myCZKEMClass = new CZKEMClass();

        //connecting the device
        myCZKEMClass.Connect_Net(param.Terminal.IPAddress, param.Terminal.Port);
        myCZKEMClass.EnableDevice(param.Terminal.DeviceId, false);


        int myCount = View.SelectedObjects.Count;
        //Set specific user to fingerprint device
        for (int i = 1; i <= myCount; i++)
        {
            int tMachineNo = param.Terminal.DeviceId;
            string tEnrollNo = employeeBiometric.Employee.EnrollNo;//Sequence.ToString();
            string tName = employeeBiometric.UserName;
            string tPassword = employeeBiometric.Password;
            int tPrivilege = (int)employeeBiometric.Privilege;
            bool tEnabled = employeeBiometric.Enabled;
            int tFingerIndex = employeeBiometric.FingerprintIndex;
            string tTmpData = employeeBiometric.FingerprintTemplate;
            int tFlag = 1;

            if (myCZKEMClass.SSR_SetUserInfo(tMachineNo, tEnrollNo, tName, tPassword, tPrivilege, tEnabled))
            {
                myCZKEMClass.SetUserTmpExStr(tMachineNo, tEnrollNo, tFingerIndex, tFlag, tTmpData);
            }
        }

        myCZKEMClass.RefreshData(param.Terminal.DeviceId);
        myCZKEMClass.EnableDevice(param.Terminal.DeviceId, true);
    }
private void UploadUserInformationAction\u Execute(对象发送方,PopupWindowShowActionExecuteEventArgs e)
{
IOObjectSpace os=Application.CreateObjectSpace();
EmployeeBiometric EmployeeBiometric=(EmployeeBiometric)视图。选择对象[0];
EmployeeBiometricParameter=(EmployeeBiometricParameter)e.PopupWindowViewCurrentObject;
//创建新的类对象
CZKEMClass myCZKEMClass=新CZKEMClass();
//连接设备
myCZKEMClass.Connect_Net(param.Terminal.IPAddress,param.Terminal.Port);
MyCzkeClass.EnableDevice(param.Terminal.DeviceId,false);
int myCount=View.SelectedObjects.Count;
//将特定用户设置为指纹设备

对于(int i=1;我认为您将服务器端编程与客户端计算机上运行的程序混淆。首先,我使用客户端连接代码连接到USB设备,并保存指纹图像。然后,我将连接到其他生物测量设备,在压缩后传输我拍摄的指纹图像模板。什么指纹扫描仪(硬件)你用什么?
public partial class Terminal : XPCustomObject
{
    Guid fOid;
    [Key(AutoGenerate = true), Browsable(false)]
    public Guid Oid
    {
        get { return fOid; }
        set { SetPropertyValue<Guid>("Oid", ref fOid, value); }
    }

    private Branch _Branch;
    [RuleRequiredField("", DefaultContexts.Save, "Branch required")]
    public Branch Branch
    {
        get
        {
            return _Branch;
        }
        set
        {
            SetPropertyValue("Branch", ref _Branch, value);
        }
    }
    string fDescription;
    [RuleUniqueValue("", DefaultContexts.Save, "The value was already registered within the system.", ResultType = ValidationResultType.Warning)]
    [RuleRequiredField("", DefaultContexts.Save, "Description required")]
    public string Description
    {
        get { return fDescription; }
        set { SetPropertyValue<string>("Description", ref fDescription, value); }
    }
    string fIPAddress;
    [Size(15)]
    public string IPAddress
    {
        get { return fIPAddress; }
        set { SetPropertyValue<string>("IPAddress", ref fIPAddress, value); }
    }

    private int _Port;
    public int Port
    {
        get
        {
            return _Port;
        }
        set
        {
            SetPropertyValue("Port", ref _Port, value);
        }
    }

    string fDeviceDescription;

    public string DeviceDescription
    {
        get { return fDeviceDescription; }
        set { SetPropertyValue<string>("DeviceDescription", ref fDeviceDescription, value); }
    }

    private int _DeviceId;
    public int DeviceId
    {
        get
        {
            return _DeviceId;
        }
        set
        {
            SetPropertyValue("DeviceId", ref _DeviceId, value);
        }
    }

    private bool _Disabled;
    public bool Disabled
    {
        get
        {
            return _Disabled;
        }
        set
        {
            SetPropertyValue("Disabled", ref _Disabled, value);
        }
    }}