我正在使用 ZKFingerSDK 5.3。它有一个 c# 演示,他们使用内存缓存进行测试,但我需要将手指数据保存到数据库并匹配手指数据以进行客户识别。请给我一个例子,如何将手指数据保存到任何数据库((MS SQL/MySQL/sqlite)以及如何匹配。
C# 演示项目 -- https://github.com/emrancu/zk4500
Demo里面的代码:
MemoryStream ms = new MemoryStream();
BitmapFormat.GetBitmap(FPBuffer, mfpWidth, mfpHeight, ref ms);
Bitmap bmp = new Bitmap(ms);
this.picFPImg.Image = bmp;
String strShow = zkfp2.BlobToBase64(CapTmp, cbCapTmp);
textRes.AppendText("capture template data:" + strShow + "\n");
if (IsRegister)
{
int ret = zkfp.ZKFP_ERR_OK;
int fid = 0, score = 0;
ret = zkfp2.DBIdentify(mDBHandle, CapTmp, ref fid, ref score);
if (zkfp.ZKFP_ERR_OK == ret)
{
textRes.AppendText("This finger was already register by " + fid + "!\n");
return;
}
if (RegisterCount > 0 && zkfp2.DBMatch(mDBHandle, CapTmp, RegTmps[RegisterCount - 1]) <= 0)
{
textRes.AppendText("Please press the same finger 3 times for the enrollment.\n");
return;
}
Array.Copy(CapTmp, RegTmps[RegisterCount], cbCapTmp);
String strBase64 = zkfp2.BlobToBase64(CapTmp, cbCapTmp);
byte[] blob = zkfp2.Base64ToBlob(strBase64);
RegisterCount++;
if (RegisterCount >= REGISTER_FINGER_COUNT)
{
RegisterCount = 0;
if (zkfp.ZKFP_ERR_OK == (ret = zkfp2.DBMerge(mDBHandle, RegTmps[0], RegTmps[1], RegTmps[2], RegTmp, ref cbRegTmp)) &&
zkfp.ZKFP_ERR_OK == (ret = zkfp2.DBAdd(mDBHandle, iFid, RegTmp)))
{
iFid++;
textRes.AppendText("enroll succ\n");
}
else
{
textRes.AppendText("enroll fail, error code=" + ret + "\n");
}
IsRegister = false;
return;
}
else
{
textRes.AppendText("You need to press the " + (REGISTER_FINGER_COUNT - RegisterCount) + " times fingerprint\n");
}
}
我无法理解 zkfp2.DBIdentify(),zkfp2.DBAdd(),zkfp2.DBMerge();
public class zkfp2
{
public zkfp2();
public static int AcquireFingerprint(IntPtr devHandle, byte[] imgBuffer, byte[] template, ref int size);
public static int AcquireFingerprintImage(IntPtr devHandle, byte[] imgbuf);
public static byte[] Base64ToBlob(string base64Str);
public static string BlobToBase64(byte[] blob, int nDataLen);
public static bool ByteArray2Int(byte[] buf, ref int value);
public static int CloseDevice(IntPtr devHandle);
public static int DBAdd(IntPtr dbHandle, int fid, byte[] regTemp);
public static int DBClear(IntPtr dbHandle);
public static int DBCount(IntPtr dbHandle);
public static int DBDel(IntPtr dbHandle, int fid);
public static int DBFree(IntPtr dbHandle);
public static int DBGetParameter(IntPtr dbHandle, int code, ref int value);
public static int DBIdentify(IntPtr dbHandle, byte[] temp, ref int fid, ref int score);
public static IntPtr DBInit();
public static int DBMatch(IntPtr dbHandle, byte[] temp1, byte[] temp2);
public static int DBMerge(IntPtr dbHandle, byte[] temp1, byte[] temp2, byte[] temp3, byte[] regTemp, ref int regTempLen);
public static int DBSetParameter(IntPtr dbHandle, int code, int value);
public static int ExtractFromImage(IntPtr dbHandle, string FileName, int DPI, byte[] template, ref int size);
public static int GetDeviceCount();
public static int GetParameters(IntPtr devHandle, int code, byte[] paramValue, ref int size);
public static int Init();
public static bool Int2ByteArray(int value, byte[] buf);
public static IntPtr OpenDevice(int index);
public static int SetParameters(IntPtr devHandle, int code, byte[] pramValue, int size);
public static int Terminate();
}