How to use ZK4500 Fingerprint Scanner SDK in C# Project [closed]

故事扮演 提交于 2019-12-18 09:23:19

问题


I am developing a project in C#, for which I want to login/authenticate a user using their fingerprint.

I bought a ZK4500 Fingerprint scanner and got its SDK from http://www.zkteco.com/product/ZK4500_238.html. The SDK is in C++.

So How can I integrate this SDK with my C# project to perform the desired functionality?


回答1:


You need to add reference to ZKFPEngXControl that will appear under COM Type Libraries. After that you can use the ZKFPEngX Class to do whatever you require.

using ZKFPEngXControl;

and then

ZKFPEngX fp = new ZKFPEngX();
fp.SensorIndex = 0;
fp.InitEngine(); // Do validation as well as it returns an integer (0 for success, else error code 1-3)
//subscribe to event for getting when user places his/her finger
fp.OnImageReceived += new IZKFPEngXEvents_OnImageReceivedEventHandler(fp_OnImageReceived);

You can write your own method fp_OnImageReceived to handle the event. for example you can write this in that method;

object imgdata = new object();
bool b = fp.GetFingerImage(ref imgdata);

Where imgdata is an array of bytes.You can also use other methods in ZKFPEngX, to achieve your goals. Remember to close the engine when form closes.

fp.EndEngine();



回答2:


You can store a fingerprint under OnEnroll(bool ActionResult, object ATemplate) Event.This event will be called when BeginEnroll() has been executed.

//Add an event handler on OnEnroll Event
ZKFPEngX x = new ZKFPEngX();
x.OnEnroll += X_OnEnroll; 


private void X_OnEnroll(bool ActionResult, object ATemplate)
{
    if (ActionResult)
    {
        if (x.LastQuality >= 80) //to ensure the fingerprint quality
        {
            string regTemplate = x.GetTemplateAsStringEx("9");
            File.WriteAllText(Application.StartupPath + "\\fingerprint.txt", regTemplate);
        }
        else
        {
            //Quality is too low
        }
    }
    else
    {
        //Register Failed
    }
}

You can try to verify the fingerprints under OnCapture(bool ActionResult, object ATemplate)event. This event will be called when a finger is put on the scanner.

Add an event handler on OnCapture Event:

x.OnCapture += X_OnCapture;

Verify the fingerprints when the event has been called (a finger is put on the scanner):

private void X_OnCapture(bool ActionResult, object ATemplate)
{
    if (ActionResult) //if fingerprint is captured successfully
    {
        bool ARegFeatureChanged = true;
        string regTemplate = File.ReadAllText(Application.StartupPath + "\\fingerprint.txt");
        string verTemplate = x.GetTemplateAsString();
        bool result = x.VerFingerFromStr(regTemplate , verTemplate, false, ARegFeatureChanged);
        if (result)
        {
            //matched
        }
        else
        {
            //not matched
        }
    } 
    else
    {
        //failed to capture a valid fingerprint
    }
}


来源:https://stackoverflow.com/questions/42876583/how-to-use-zk4500-fingerprint-scanner-sdk-in-c-sharp-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!