Hi lightsomal,
For ZK4500 Fingerprint integration you can refer below link for complete sample in Windows application.
https://github.com/zaagan/ZKTecoFingerPrintScanner-Implementation
Or download the AxInterop.ZKFPEngXControl.dll from below link.
https://github.com/ehmad11/ZKTeco-ZK4500/tree/master/dlls
Add the dll reference in your project.
Form Design
Then import the namespaces.
Namespaces
C#
using System.Drawing;
using AxZKFPEngXControl;
VB.Net
Imports System.Drawing
Imports AxZKFPEngXControl
Code
C#
private AxZKFPEngX ZkFprint = new AxZKFPEngX();
private bool Check;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Controls.Add(ZkFprint);
InitialAxZkfp();
}
private void InitialAxZkfp()
{
try
{
ZkFprint.OnImageReceived += zkFprint_OnImageReceived;
ZkFprint.OnFeatureInfo += zkFprint_OnFeatureInfo;
ZkFprint.OnEnroll += zkFprint_OnEnroll;
if (ZkFprint.InitEngine() == 0)
{
ZkFprint.FPEngineVersion = "9";
ZkFprint.EnrollCount = 3;
deviceSerial.Text += " " + ZkFprint.SensorSN + " Count: " + ZkFprint.SensorCount.ToString() + " Index: " + ZkFprint.SensorIndex.ToString();
ShowHintInfo("Device successfully connected");
}
}
catch (Exception ex)
{
ShowHintInfo("Device init err, error: " + ex.Message);
}
}
private void zkFprint_OnImageReceived(object sender, IZKFPEngXEvents_OnImageReceivedEvent e)
{
Graphics g = fpicture.CreateGraphics();
Bitmap bmp = new Bitmap(fpicture.Width, fpicture.Height);
g = Graphics.FromImage(bmp);
int dc = g.GetHdc().ToInt32();
ZkFprint.PrintImageAt(dc, 0, 0, bmp.Width, bmp.Height);
g.Dispose();
fpicture.Image = bmp;
}
private void zkFprint_OnFeatureInfo(object sender, IZKFPEngXEvents_OnFeatureInfoEvent e)
{
String strTemp = string.Empty;
if (ZkFprint.EnrollIndex != 1)
{
if (ZkFprint.IsRegister)
{
if (ZkFprint.EnrollIndex - 1 > 0)
{
int eindex = ZkFprint.EnrollIndex - 1;
strTemp = "Please scan again ..." + eindex;
}
}
}
ShowHintInfo(strTemp);
}
private void zkFprint_OnEnroll(object sender, IZKFPEngXEvents_OnEnrollEvent e)
{
if (e.actionResult)
{
string template = ZkFprint.EncodeTemplate1(e.aTemplate);
txtTemplate.Text = template;
ShowHintInfo("Registration successful. You can verify now");
btnRegister.Enabled = false;
btnVerify.Enabled = true;
}
else
{
ShowHintInfo("Error, please register again.");
}
}
private void zkFprint_OnCapture(object sender, IZKFPEngXEvents_OnCaptureEvent e)
{
string template = ZkFprint.EncodeTemplate1(e.aTemplate);
if (ZkFprint.VerFingerFromStr(ref template, txtTemplate.Text, false, ref Check))
{
ShowHintInfo("Verified");
}
else
{
ShowHintInfo("Not Verified");
}
}
private void ShowHintInfo(String s)
{
prompt.Text = s;
}
private void btnVerify_Click(object sender, EventArgs e)
{
if (ZkFprint.IsRegister)
{
ZkFprint.CancelEnroll();
}
ZkFprint.OnCapture += zkFprint_OnCapture;
ZkFprint.BeginCapture();
ShowHintInfo("Please give fingerprint sample.");
}
private void btnRegister_Click(object sender, EventArgs e)
{
ZkFprint.CancelEnroll();
ZkFprint.EnrollCount = 3;
ZkFprint.BeginEnroll();
ShowHintInfo("Please give fingerprint sample.");
}
private void btnClear_Click(object sender, EventArgs e)
{
fpicture.Image = null;
}
VB.Net
Private ZkFprint As AxZKFPEngX = New AxZKFPEngX()
Private Check As Boolean
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Controls.Add(ZkFprint)
InitialAxZkfp()
End Sub
Private Sub InitialAxZkfp()
Try
AddHandler ZkFprint.OnImageReceived, AddressOf zkFprint_OnImageReceived
AddHandler ZkFprint.OnFeatureInfo, AddressOf zkFprint_OnFeatureInfo
AddHandler ZkFprint.OnEnroll, AddressOf zkFprint_OnEnroll
If ZkFprint.InitEngine() = 0 Then
ZkFprint.FPEngineVersion = "9"
ZkFprint.EnrollCount = 3
deviceSerial.Text += " " & ZkFprint.SensorSN & " Count: " + ZkFprint.SensorCount.ToString() & " Index: " + ZkFprint.SensorIndex.ToString()
ShowHintInfo("Device successfully connected")
End If
Catch ex As Exception
ShowHintInfo("Device init err, error: " & ex.Message)
End Try
End Sub
Private Sub zkFprint_OnImageReceived(ByVal sender As Object, ByVal e As IZKFPEngXEvents_OnImageReceivedEvent)
Dim g As Graphics = fpicture.CreateGraphics()
Dim bmp As Bitmap = New Bitmap(fpicture.Width, fpicture.Height)
g = Graphics.FromImage(bmp)
Dim dc As Integer = g.GetHdc().ToInt32()
ZkFprint.PrintImageAt(dc, 0, 0, bmp.Width, bmp.Height)
g.Dispose()
fpicture.Image = bmp
End Sub
Private Sub zkFprint_OnFeatureInfo(ByVal sender As Object, ByVal e As IZKFPEngXEvents_OnFeatureInfoEvent)
Dim strTemp As String = String.Empty
If ZkFprint.EnrollIndex <> 1 Then
If ZkFprint.IsRegister Then
If ZkFprint.EnrollIndex - 1 > 0 Then
Dim eindex As Integer = ZkFprint.EnrollIndex - 1
strTemp = "Please scan again ..." & eindex
End If
End If
End If
ShowHintInfo(strTemp)
End Sub
Private Sub zkFprint_OnEnroll(ByVal sender As Object, ByVal e As IZKFPEngXEvents_OnEnrollEvent)
If e.actionResult Then
Dim template As String = ZkFprint.EncodeTemplate1(e.aTemplate)
txtTemplate.Text = template
ShowHintInfo("Registration successful. You can verify now")
btnRegister.Enabled = False
btnVerify.Enabled = True
Else
ShowHintInfo("Error, please register again.")
End If
End Sub
Private Sub zkFprint_OnCapture(ByVal sender As Object, ByVal e As IZKFPEngXEvents_OnCaptureEvent)
Dim template As String = ZkFprint.EncodeTemplate1(e.aTemplate)
If ZkFprint.VerFingerFromStr(template, txtTemplate.Text, False, Check) Then
ShowHintInfo("Verified")
Else
ShowHintInfo("Not Verified")
End If
End Sub
Private Sub ShowHintInfo(ByVal s As String)
prompt.Text = s
End Sub
Private Sub btnVerify_Click(ByVal sender As Object, ByVal e As EventArgs)
If ZkFprint.IsRegister Then
ZkFprint.CancelEnroll()
End If
AddHandler ZkFprint.OnCapture, AddressOf zkFprint_OnCapture
ZkFprint.BeginCapture()
ShowHintInfo("Please give fingerprint sample.")
End Sub
Private Sub btnRegister_Click(ByVal sender As Object, ByVal e As EventArgs)
ZkFprint.CancelEnroll()
ZkFprint.EnrollCount = 3
ZkFprint.BeginEnroll()
ShowHintInfo("Please give fingerprint sample.")
End Sub
Private Sub btnClear_Click(ByVal sender As Object, ByVal e As EventArgs)
fpicture.Image = Nothing
End Sub
For sample project refer below link.
https://github.com/ehmad11/ZKTeco-ZK4500