How to use ZK4500 Fingerprint Scanner SDK in C# Pr

2020-02-14 20:25发布

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?

2条回答
爱情/是我丢掉的垃圾
2楼-- · 2020-02-14 20:45

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();
查看更多
淡お忘
3楼-- · 2020-02-14 20:57

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
    }
}
查看更多
登录 后发表回答