如何在C#项目中使用ZK4500指纹扫描仪SDK

时间:2017-03-18 16:02:00

标签: c# c++ sdk fingerprint biometrics

我正在使用C#开发一个项目,我想使用他们的指纹登录/验证用户。

我买了一台ZK4500指纹扫描仪并从http://www.zkteco.com/product/ZK4500_238.html获得了它的SDK。 SDK使用C ++。

那么如何将此SDK与我的C#项目集成以执行所需的功能?

2 个答案:

答案 0 :(得分:5)

您需要添加对将出现在COM类型库下的ZKFPEngXControl的引用。之后,您可以使用ZKFPEngX类来执行您需要的任何操作。

using ZKFPEngXControl;

然后

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);

您可以编写自己的方法fp_OnImageReceived来处理事件。例如,你可以用该方法写出来;

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

其中imgdata是一个字节数组。您还可以使用ZKFPEngX中的其他方法来实现您的目标。请记住在表单关闭时关闭引擎。

fp.EndEngine();

答案 1 :(得分:1)

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
    }
}