private void CaptureDataFingerpint(int message) { switch (message) { case MESSAGE_CAPTURED_OK: { MemoryStream ms = new MemoryStream(); BitmapFormat.GetBitmap(FPBuffer, mfpWidth, mfpHeight, ref ms); Bitmap bmp = new Bitmap(ms); // set image to Scan Finger's Form scanFinger.SetImage(bmp); String strShow = zkfp2.BlobToBase64(CapTmp, cbCapTmp); scanFinger.DataFinger = strShow; scanFinger.DataFingerLength = strShow.Length; Console.WriteLine(strShow); // set quality finger string present_quality_finger = tk.CalculatePercentageTemplateFingerprint(strShow.Length); scanFinger.SetPresentQuality(present_quality_finger); } break; default: Console.WriteLine("Error : Invalid Data Fingerprint."); break; } }
private void CaptureDataFingerpint(int message) { switch (message) { case MESSAGE_CAPTURED_OK: { MemoryStream ms = new MemoryStream(); BitmapFormat.GetBitmap(FPBuffer, mfpWidth, mfpHeight, ref ms); Bitmap bmp = new Bitmap(ms); // this is for testing, to check whether it receives a proper Bitmap data. //bmp.Save("test.bmp", ImageFormat.Png); String strShow = zkfp2.BlobToBase64(CapTmp, cbCapTmp); String current_dt = tk.GetCurrentDatetime(); Console.WriteLine("----------------------"); Console.WriteLine(current_dt); Console.WriteLine("----------------------"); Console.WriteLine("captured data : " + strShow + "\n"); Keyboard.AutoCopyPasteEvent(strShow); } break; default: Console.WriteLine("Error : Invalid Data Fingerprint."); break; } }
protected override void DefWndProc(ref Message m) { switch (m.Msg) { case MESSAGE_CAPTURED_OK: { MemoryStream ms = new MemoryStream(); BitmapFormat.GetBitmap(FPBuffer, mfpWidth, mfpHeight, ref ms); Bitmap bmp = new Bitmap(ms); this.picFPImg.Image = bmp; foreach (RightingSys.Models.ACL_FingerPrint PF in AllFinger) { int ret = zkfp2.DBMatch(mDBHandle, CapTmp, PF.FingerData); if (50 < ret) { FingerUserId = PF.UserId; base.DialogResult = DialogResult.OK; this.bnClose_Click(null, null); return; } } textRes.Text = "\r\n没有找到匹配到用户指纹信息" + textRes.Text; } break; default: base.DefWndProc(ref m); break; } }
protected override void DefWndProc(ref Message m) { switch (m.Msg) { case MESSAGE_CAPTURED_OK: { MemoryStream ms = new MemoryStream(); BitmapFormat.GetBitmap(FPBuffer, mfpWidth, mfpHeight, ref ms); Bitmap bmp = new Bitmap(ms); this.picFPImg.Image = bmp; foreach (Models.ACL_FingerPrint PF in AllFinger) { int ret = zkfp2.DBMatch(mDBHandle, CapTmp, PF.FingerData); if (50 < ret) { textRes.Text = string.Format("\r\n匹配率={0} 姓名:{1} 指纹ID:{2} ", ret, PF.FullName, PF.Id) + textRes.Text; return; } } textRes.Text = "\r\n没有找到匹配到用户指纹信息" + textRes.Text; } break; default: base.DefWndProc(ref m); break; } }
protected override void DefWndProc(ref Message m) { switch (m.Msg) { case MESSAGE_CAPTURED_OK: MemoryStream ms = new MemoryStream(); BitmapFormat.GetBitmap(FPBuffer, mfpWidth, mfpHeight, ref ms); Bitmap bmp = new Bitmap(ms); this.pic.Image = bmp; { 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) { lb_msg.Text = "指纹识别成功,匹配度=" + score + "%"; Bll.T_Staff t_Staff = new T_Staff(); DataTable user = t_Staff.GetUserID(fid.ToString()); string userId = user.Rows[0]["StaffID"].ToString(); Bll.User.UserID = userId; zkfp2.Terminate(); cbRegTmp = 0; if (captureThread != null) { captureThread.Abort(); } //close device bIsTimeToDie = true; RegisterCount = 0; Thread.Sleep(1000); zkfp2.CloseDevice(mDevHandle); MangJianFrm f = new MangJianFrm(); f.Owner = this; this.Hide(); f.ShowDialog(); Application.ExitThread(); } else { lb_msg.Text = "指纹识别失败,状态码=" + ret; return; } } break; default: base.DefWndProc(ref m); break; } }
private void _fingerImageTimer_Tick(object sender, EventArgs e) { _fingerImageTimer.Stop(); _cbCapTmp = 2048; if (_flagFinger == "1") { this.nRet = ZwClass.ZKFPModule_GetFingerImage(this.m_hDevice, ref this.m_nWidth, ref this.m_nHeight, this.m_pImageBuffer, ref this.m_nSize); if (this.nRet == 0) { try { MemoryStream ms = new MemoryStream(); BitmapFormat.WriteBitmap(this.m_pImageBuffer, this.m_nWidth, this.m_nHeight); BitmapFormat.GetBitmap(this.m_pImageBuffer, this.m_nWidth, this.m_nHeight, ref ms); Bitmap bitmap = new Bitmap((Stream)ms); this.PictureBox_Finger.SizeMode = PictureBoxSizeMode.StretchImage; this.PictureBox_Finger.Image = (System.Drawing.Image)bitmap; SaveFingerOrSignImage(ms); } catch (Exception ex) { LoggerHelper.Log(ex.Message); } } else { LoggerHelper.Log("this.nRet:" + this.nRet); } } else { this.nRet = FingerClass.AcquireFingerprint(this.m_hDevice, this._fPBuffer, this._capTmp, ref this._cbCapTmp); if (this.nRet == 0) { MemoryStream ms = new MemoryStream(); FingerBitmapFormat.GetBitmap(this._fPBuffer, this.m_nWidth, this.m_nHeight, ref ms); Bitmap bitmap = new Bitmap((Stream)ms); this.PictureBox_Finger.SizeMode = PictureBoxSizeMode.StretchImage; this.PictureBox_Finger.Image = (System.Drawing.Image)bitmap; SaveFingerOrSignImage(ms); ms.Dispose(); } } _fingerImageTimer.Start(); }
private void DoCapture() { while (!isTimeToDie) { int ret = zkfp2.AcquireFingerprint(deviceHandle, imgBuffer, captureTemplate, ref templateSize); if (ret == zkfp.ZKFP_ERR_OK) { // Ricreo l'immagine MemoryStream stream = new MemoryStream(); BitmapFormat.GetBitmap(imgBuffer, imgWidth, imgHeight, ref stream); Bitmap bmp = new Bitmap(stream); // Creo il template String strTemplate = zkfp2.BlobToBase64(captureTemplate, templateSize); // Preparo la callback ed eseguo ScansioneEvent sevent = new ScansioneEvent { tempo = DateTime.Now, isValid = true, bmpFileName = Path.ChangeExtension(Path.GetTempFileName(), ".bmp"), strBase64Template = strTemplate }; // TODO questo salvataggio potrebbe anche non servire (per risparmiare tempo) if (generateBmp) { bmp.Save(sevent.bmpFileName); } EmissioneFeedback(true); // callback(this, sevent); // SendMessage( FormHandle, MESSAGE_CAPTURED_OK, IntPtr.Zero, IntPtr.Zero ); } Thread.Sleep(300); } }
private void DisplayFingerPrintImage() { // NORMAL METHOD >>> //Bitmap fingerPrintImage = Utilities.GetImage(FPBuffer, fpInstance.imageWidth, fpInstance.imageHeight); //Rectangle cropRect = new Rectangle(0, 0, pbxImage2.Width / 2, pbxImage2.Height / 2); //Bitmap target = new Bitmap(cropRect.Width, cropRect.Height); //using (Graphics g = Graphics.FromImage(target)) //{ // g.DrawImage(fingerPrintImage, new Rectangle(0, 0, target.Width, target.Height), cropRect, GraphicsUnit.Pixel); //} //this.pbxImage2.Image = target; // OPTIMIZED METHOD MemoryStream ms = new MemoryStream(); BitmapFormat.GetBitmap(FPBuffer, mfpWidth, mfpHeight, ref ms); Bitmap bmp = new Bitmap(ms); this.picFPImg.Image = bmp; }
protected override void DefWndProc(ref Message m) { switch (m.Msg) { case MESSAGE_CAPTURED_OK: { MemoryStream ms = new MemoryStream(); BitmapFormat.GetBitmap(FPBuffer, mfpWidth, mfpHeight, ref ms); Bitmap bmp = new Bitmap(ms); bool IsRegister = frm2.GetIsRegister(); if (IsRegister) { frm2.SetImg(bmp); textTips.Text = "开始注册"; 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) { frm2.SetTips("当前手指已录入成功 " + fid + "!"); return; } int userid = frm2.GetUserId(); string realname = frm2.GetRealName(); if (userid == 0 || realname == "") { MessageBox.Show("请先填写学生的ID和真实姓名,Id可以从排课系统后台看到!", "提示"); return; } int fingerindex = frm2.GetFingerIndex(); if (RegisterCount > 0 && zkfp2.DBMatch(mDBHandle, CapTmp, RegTmps[RegisterCount - 1]) <= 0) { //将手指放在指纹感应器上,使用同一手指的不同区块重复此操作,直到指纹成功录入 frm2.SetTips("使用同一手指的不同区块重复此操作"); playVoice("try"); 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))) { //插入数据到本地数据库 int last_id = ldb.AddFingerprint(userid, fingerindex, "", strBase64, realname); if (last_id != 0) { if (zkfp.ZKFP_ERR_OK == (ret = zkfp2.DBAdd(mDBHandle, last_id, RegTmp))) { frm2.SetTips("指纹存储成功!"); playVoice("success"); MessageBox.Show("指纹存储成功!", "提示"); } else { var s = ldb.DelFingerprint("template", last_id); if (!s) //再删除一遍 { ldb.DelFingerprint("template", last_id); } frm2.SetTips("指纹录入失败02"); playVoice("fail"); MessageBox.Show("指纹录入失败02", "提示"); } } else { frm2.SetTips("指纹存储失败!"); playVoice("fail"); MessageBox.Show("指纹存储失败!", "提示"); } } else { frm2.SetTips("指纹录入失败 code=" + ret); playVoice("fail"); } IsRegister = false; return; } else { frm2.SetTips("还需按压" + (REGISTER_FINGER_COUNT - RegisterCount) + "次"); playVoice("try"); } } return; } else { this.fingerprintImg.Image = bmp; if (cbRegTmp <= 0) { textTips.Text = "指纹库指纹条数为0,请先录入指纹!"; playVoice("dd"); return; } if (bIdentify) { //1:1识别 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) { var userInfo = ldb.GetUserInfo(fid); if (userInfo.Autoid == 0) { textTips.Text = "当前指纹已删除!"; return; } textTips.Text = "1:1指纹识别成功, 识别ID: " + fid + ",姓名:" + userInfo.Realname + ",手指:" + userInfo.Fingerindex + ",识别分数:" + score + "!"; //textTips.Text = f.SendGprsPrintContent("邹慧刚");c#直接发送请求给打印机 string resultJson = goPrint.SendPrint(userInfo.userid); //请求golang服务器,简介发送打印请求,同时判断是否成功 //解析json字符串 var rs = JsonConvert.DeserializeObject <JsonAnooc>(resultJson); //result为上面的Json数据 if (rs.status == 200) { textTips.Text = "发送打印请求成功!返回信息:" + resultJson; playVoice("line"); } else { textTips.Text = "发送打印请求失败!返回信息:" + resultJson; playVoice("di"); } return; } else { textTips.Text = "1:1指纹识别失败, 错误: " + ret; return; } } else { //1:N识别 int ret = zkfp2.DBMatch(mDBHandle, CapTmp, RegTmp); if (0 < ret) { textTips.Text = "1:N指纹识别成功, score=" + ret + "!"; playVoice("print"); return; } else { textTips.Text = "1:N指纹识别失败, ret= " + ret; return; } } } } break; default: base.DefWndProc(ref m); //程序初始化,会到这里 break; } }
protected override void DefWndProc(ref Message m) { switch (m.Msg) { case MESSAGE_CAPTURED_OK: MemoryStream ms = new MemoryStream(); BitmapFormat.GetBitmap(FPBuffer, mfpWidth, mfpHeight, ref ms); Bitmap bmp = new Bitmap(ms); this.pic.Image = bmp; { 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) { try { lb_msg.Text = "指纹识别成功,匹配度=" + score + "%"; Bll.T_Staff t_Staff = new T_Staff(); DataTable user = t_Staff.GetUserID(fid.ToString()); string userId = user.Rows[0]["StaffID"].ToString(); Bll.User.UserID = userId; bool result = t_Staff.GetRoleID(userId); //MessageBox.Show(result.ToString()); if (result) { this.DialogResult = DialogResult.OK; zkfp2.Terminate(); cbRegTmp = 0; if (captureThread != null) { captureThread.Abort(); } this.Close(); } else { //MessageBox.Show("请班长输入指纹!"); lb_msg.BackColor = Color.Red; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } else { lb_msg.Text = "指纹识别失败,状态码=" + ret; return; } } break; default: base.DefWndProc(ref m); break; } }
protected override void DefWndProc(ref Message m) { switch (m.Msg) { case MESSAGE_CAPTURED_OK: { 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); 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) { txtStatus.Text = "This finger was already register"; return; } if (RegisterCount > 0 && zkfp2.DBMatch(mDBHandle, CapTmp, RegTmps[RegisterCount - 1]) <= 0) { txtStatus.Text = "Please press the same finger 1 times for the enrollment."; return; } Array.Copy(CapTmp, RegTmps[RegisterCount], cbCapTmp); String strBase64 = zkfp2.BlobToBase64(CapTmp, cbCapTmp); byte[] blob = zkfp2.Base64ToBlob(strBase64); RegisterCount++; Save_Database(strBase64); if (RegisterCount >= REGISTER_FINGER_COUNT) { txtStatus.Text = "Enroll succesfully"; IsRegister = false; cbRegTmp = 1; return; } else { txtStatus.Text = "You need to press the " + (REGISTER_FINGER_COUNT - RegisterCount) + " times fingerprint"; } } else { if (cbRegTmp <= 0) { txtStatus.Text = "Please register your finger first!"; return; } if (bIdentify) { 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) { txtStatus.Text = "Identify succesfully, fid= " + fid + ",score=" + score + "!"; return; } else { txtStatus.Text = "Identify failed, ret= " + ret; return; } } else { RfcConfigParameters parameters = new RfcConfigParameters(); parameters[RfcConfigParameters.Name] = SAPFingerprint.Properties.Settings.Default.Name; parameters[RfcConfigParameters.User] = txtUser.Text; parameters[RfcConfigParameters.Password] = txtPass.Text; parameters[RfcConfigParameters.Client] = SAPFingerprint.Properties.Settings.Default.Client; parameters[RfcConfigParameters.Language] = SAPFingerprint.Properties.Settings.Default.Language; parameters[RfcConfigParameters.AppServerHost] = SAPFingerprint.Properties.Settings.Default.AppServerHost; parameters[RfcConfigParameters.SystemNumber] = SAPFingerprint.Properties.Settings.Default.SystemNumber; parameters[RfcConfigParameters.SAPRouter] = SAPFingerprint.Properties.Settings.Default.SAPRouter; parameters[RfcConfigParameters.SystemID] = SAPFingerprint.Properties.Settings.Default.SystemID; RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination(parameters); RfcSessionManager.BeginContext(SapRfcDestination); SapRfcDestination.Ping(); IRfcFunction function = null; try { function = SapRfcDestination.Repository.CreateFunction("ZFM_READ_WRITE_FINGERPRINT"); function.SetValue("IM_MODE", "V"); IRfcTable gt_table = function.GetTable("EX_FINGERPRINT"); function.Invoke(SapRfcDestination); jj = 0; foreach (IRfcStructure row in gt_table) { jj = jj + 1; byte[] blob1 = Convert.FromBase64String(Convert.ToString(row.GetValue(0))); String strBase64 = zkfp2.BlobToBase64(CapTmp, cbCapTmp); byte[] blob2 = Convert.FromBase64String(strBase64.Trim()); int ret = zkfp2.DBMatch(mDBHandle, blob1, blob2); if (ret > 0) { txtStatus.Text = "Selamat Datang!"; vald = ret; break; } else { txtStatus.Text = "Maaf and tidak dikenali"; } zkfp2.DBClear(mDBHandle); } if (vald > 0) { // function = SapRfcDestination.Repository.CreateFunction("ZFM_READ_WRITE_FINGERPRINT"); // function.SetValue("MODE", "V"); // function.SetValue("INDX", jj); // function.Invoke(SapRfcDestination); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Error: " + ex.Message); } RfcSessionManager.EndContext(SapRfcDestination); SapRfcDestination = null; } } } break; default: base.DefWndProc(ref m); break; } }
public HttpResponseMessage PostFingerPrintReturn(JObject JsonRequest) { JObject Parameters = JsonRequest; string functionName = Parameters["functionName"].ToString(); //string patientID = Parameters["PatientID"].ToString(); string returnValue = String.Empty; IntPtr mDevHandle = Common.mDevHandle; IntPtr mDBHandle = Common.mDBHandle; int size = 4; byte[] paramValue = new byte[size]; byte[] FPBuffer; int cbCapTmp = 2048; byte[] CapTmp = new byte[2048]; string CapTmpOut = String.Empty; string acquireCount = String.Empty; int status = 0; int score = 0; string rootPath = System.Environment.CurrentDirectory; try { zkfp2.GetParameters(mDevHandle, 1, paramValue, ref size); zkfp2.ByteArray2Int(paramValue, ref mfpWidth); zkfp2.GetParameters(mDevHandle, 2, paramValue, ref size); zkfp2.ByteArray2Int(paramValue, ref mfpHeight); FPBuffer = new byte[mfpWidth * mfpHeight]; switch (functionName) { case "FPInit": // init device status = zkfp2.Init(); if (status == 0) { int count = zkfp2.GetDeviceCount(); if (count != 1) { status = ERR_MULTIPLE_DEVICES; returnValue = JsonConvert.SerializeObject(new { status = status.ToString() }); break; } } else { returnValue = JsonConvert.SerializeObject(new { status = status.ToString() }); break; } // open device if (IntPtr.Zero == (mDevHandle = zkfp2.OpenDevice(DEVICE_NUMBER))) { status = DEVICE_OPEN_FAILED; returnValue = JsonConvert.SerializeObject(new { status = status.ToString() }); break; } if (IntPtr.Zero == (mDBHandle = zkfp2.DBInit())) { status = DB_INIT_FAILED; zkfp2.CloseDevice(mDevHandle); mDevHandle = IntPtr.Zero; returnValue = JsonConvert.SerializeObject(new { status = status.ToString() }); break; } Common.mDBHandle = mDBHandle; Common.mDevHandle = mDevHandle; returnValue = JsonConvert.SerializeObject(new { status = status.ToString() }); break; case "FPRegister": // register fingerprint acquireCount = Parameters["acquireCount"].ToString(); status = zkfp2.AcquireFingerprint(mDevHandle, FPBuffer, CapTmp, ref cbCapTmp); if (status == zkfp.ZKFP_ERR_OK) { if ((Int32.Parse(acquireCount) == 1) || ((Int32.Parse(acquireCount) > 1) && ((score = zkfp2.DBMatch(mDBHandle, zkfp2.Base64ToBlob(Parameters["regTmp"].ToString()), CapTmp)) > 0))) { CapTmpOut = zkfp2.BlobToBase64(CapTmp, cbCapTmp); //Array.Copy(zkfp2.Base64ToBlob(strBase64), CapTmpOut, cbCapTmp); MemoryStream ms = new MemoryStream(); BitmapFormat.GetBitmap(FPBuffer, mfpWidth, mfpHeight, ref ms); Bitmap bmp = new Bitmap(ms); bmp.Save(Path.Combine(rootPath, "regTmp.jpeg")); returnValue = JsonConvert.SerializeObject(new { status = status.ToString(), FPTmp = CapTmpOut, score = score }); } else { status = FP_REGISTER_MISMATCH; returnValue = JsonConvert.SerializeObject(new { status = status.ToString() }); } } else { returnValue = JsonConvert.SerializeObject(new { status = status.ToString() }); } break; case "FPTerminate": status = zkfp2.Terminate(); returnValue = JsonConvert.SerializeObject(new { status = status.ToString() }); break; case "FPMatch": // compare fingerprint status = zkfp2.AcquireFingerprint(mDevHandle, FPBuffer, CapTmp, ref cbCapTmp); if (status == zkfp.ZKFP_ERR_OK) { byte[] compTmp = zkfp2.Base64ToBlob(Parameters["compTmp"].ToString()); score = zkfp2.DBMatch(mDBHandle, CapTmp, compTmp); CapTmpOut = zkfp2.BlobToBase64(CapTmp, cbCapTmp); MemoryStream ms = new MemoryStream(); BitmapFormat.GetBitmap(FPBuffer, mfpWidth, mfpHeight, ref ms); Bitmap bmp = new Bitmap(ms); bmp.Save(Path.Combine(rootPath, "compTmp.jpeg")); returnValue = JsonConvert.SerializeObject(new { status = status.ToString(), FPTmp = CapTmpOut, score = score }); } else { returnValue = JsonConvert.SerializeObject(new { status = status.ToString() }); } break; case "FPMatchBatch": // compare fingerprint status = zkfp2.AcquireFingerprint(mDevHandle, FPBuffer, CapTmp, ref cbCapTmp); int hScore = 0; string matchedTmp = ""; if (status == zkfp.ZKFP_ERR_OK) //== zkfp.ZKFP_ERR_OK { JArray compTmpArray = JArray.Parse(Parameters["compTmp"].ToString()); for (int i = 0; i < compTmpArray.Count; i++) { byte[] compTmp = zkfp2.Base64ToBlob(compTmpArray[i].ToString()); score = zkfp2.DBMatch(mDBHandle, CapTmp, compTmp); if (score > 60 && score > hScore) { hScore = score; matchedTmp = compTmpArray[i].ToString(); } } if (hScore < 60) { status = ERR_NO_MATCHED_TMP; } returnValue = JsonConvert.SerializeObject(new { status = status.ToString(), matchedTmp = matchedTmp }); } else { returnValue = JsonConvert.SerializeObject(new { status = status.ToString() }); } break; case "FPMerge": // merge fingerprint byte[] mergeTmp01 = zkfp2.Base64ToBlob(Parameters["mergeTmp01"].ToString()); byte[] mergeTmp02 = zkfp2.Base64ToBlob(Parameters["mergeTmp02"].ToString()); byte[] mergeTmp03 = zkfp2.Base64ToBlob(Parameters["mergeTmp03"].ToString()); byte[] mergedTmp = new byte[2048]; int cbMergedTmp = 0; if (zkfp.ZKFP_ERR_OK == (status = zkfp2.DBMerge(mDBHandle, mergeTmp01, mergeTmp02, mergeTmp02, mergedTmp, ref cbMergedTmp))) { string mergedTmpOut = zkfp2.BlobToBase64(mergedTmp, cbMergedTmp); returnValue = JsonConvert.SerializeObject(new { status = status.ToString(), FPTmp = mergedTmpOut }); break; } returnValue = JsonConvert.SerializeObject(new { status = status.ToString() }); break; } } catch (Exception e) { returnValue = JsonConvert.SerializeObject(new { error = e.ToString() }); } return(ResultToJson.toJson(returnValue)); }
private bool ReadFPCaptureForMember(int msg) { bool result = true; if (msg == MESSAGE_CAPTURED_OK) { var window = meetingController.mainWindow.updateFingerPrintWindow; byte[] blob1 = CapTmp; String showFP = zkfp2.BlobToBase64(blob1, cbCapTmp); Console.WriteLine("capture template data:" + showFP + "\n"); if (window.RegisterCount > 0 && zkfp2.DBMatch(mDBHandle, CapTmp, RegTmps[window.RegisterCount - 1]) <= 0) { window.Dispatcher.Invoke(() => { Xceed.Wpf.Toolkit.MessageBox.Show("Та нэг л хуруугаа 3 удаа уншуулна уу!"); }); return(false); } Array.Copy(CapTmp, RegTmps[window.RegisterCount], cbCapTmp); if (window.RegisterCount + 1 >= REGISTER_FINGER_COUNT) { int ret = zkfp.ZKFP_ERR_OK; window.RegisterCount = 0; if (zkfp.ZKFP_ERR_OK == (ret = zkfp2.DBMerge(mDBHandle, RegTmps[0], RegTmps[1], RegTmps[2], RegTmp, ref cbRegTmp))) { String base64fp = zkfp2.BlobToBase64(RegTmp, cbCapTmp); Console.WriteLine("merged template data:" + base64fp + "\n"); window.Dispatcher.BeginInvoke((Action)(() => { window.updateUserFingerPrint(base64fp); })); return(true); } else { window.Dispatcher.Invoke(() => { Xceed.Wpf.Toolkit.MessageBox.Show("Бүртгэхэд алдаа гарлаа. Та түр хүлээгээд ахин оролдож үзнэ үү. "); }); return(false); } } window.Dispatcher.Invoke(() => { window.RegisterCount++; var v = "Та хуруугаа " + (REGISTER_FINGER_COUNT - window.RegisterCount).ToString() + " удаа уншуулна уу!"; MemoryStream ms = new MemoryStream(); BitmapFormat.GetBitmap(FPBuffer, mfpWidth, mfpHeight, ref ms); BitmapImage ObjBitmapImage = new BitmapImage(); ObjBitmapImage.BeginInit(); ObjBitmapImage.StreamSource = ms; ObjBitmapImage.EndInit(); window.image.Source = ObjBitmapImage; window.InfoLabel.Content = v; }); result = true; } else { result = false; } return(result); }
protected override void DefWndProc(ref Message m) { switch (m.Msg) { case MESSAGE_CAPTURED_OK: { MemoryStream ms = new MemoryStream(); BitmapFormat.GetBitmap(FPBuffer, mfpWidth, mfpHeight, ref ms); bmp = new Bitmap(ms); this.picFPImg.Image = bmp; String strShow = zkfp2.BlobToBase64(CapTmp, cbCapTmp); 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) { lblResult.Text = ("This finger was already register by " + fid + "!\n"); return; } if (RegisterCount > 0 && zkfp2.DBMatch(mDBHandle, CapTmp, RegTmps[RegisterCount - 1]) <= 0) { lblResult.Text = ("Por favor ingrese 3 veces su dedo para el enrolamiento.\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++; var f = new frmMsgCopiar(strShow); f.ShowDialog(); lblResult.Text = "Enrolamiento exitoso"; } else { lblResult.Text = ("Fracaso al enrolar, intente otra vez. Codigo de error=" + ret + "\n"); } IsRegister = false; return; } else { lblResult.Text = ("Es necesario la huella " + (REGISTER_FINGER_COUNT - RegisterCount) + " veces mas\n"); } } else { if (cbRegTmp <= 0) { lblResult.Text = ("Primero registre su dedo por favor!\n"); return; } if (bIdentify) { 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) { lblResult.Text = ("Identify succ, fid= " + fid + ",score=" + score + "!\n"); return; } else { lblResult.Text = ("Identify fail, ret= " + ret + "\n"); return; } } else { int ret = zkfp2.DBMatch(mDBHandle, CapTmp, RegTmp); if (0 < ret) { lblResult.Text = ("Match finger succ, score=" + ret + "!\n"); return; } else { lblResult.Text = ("Match finger fail, ret= " + ret + "\n"); return; } } } } break; default: base.DefWndProc(ref m); break; } }
/// <summary> /// windows 信息处理机制 /// </summary> protected override void DefWndProc(ref Message m) { switch (m.Msg) { case MESSAGE_CAPTURED_OK: { MemoryStream ms = new MemoryStream(); BitmapFormat.GetBitmap(FPBuffer, mfpWidth, mfpHeight, ref ms); Bitmap bmp = new Bitmap(ms); this.picFPImg.Image = bmp; if (IsRegister) { int ret = zkfp.ZKFP_ERR_OK; if (RegisterCount > 0 && zkfp2.DBMatch(mDBHandle, CapTmp, RegTmps[RegisterCount - 1]) <= 0) { textRes.Text = "请按同一个手指3次报名+\r\n" + textRes.Text; return; } Array.Copy(CapTmp, RegTmps[RegisterCount], cbCapTmp); 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))) { model.Id = Guid.NewGuid(); model.FingerData = RegTmp; model.FingerDescription = cbmFingerRemark.SelectedItem.ToString(); model.CreateTime = DateTime.Now; if (fingerMg.AddNew(model)) { textRes.Text = "\r\n登记成功\r\n" + textRes.Text; clsPublic.ShowMessage("登记成功", "Finger提示"); } else { textRes.Text = "登记失败请重新登记\r\n" + textRes.Text; } bnEnroll.Enabled = true; UserFingerAdd_FormClosing(null, null); } else { textRes.Text = "注册失败, 错误代码=" + ret + "\r\n" + textRes.Text; bnEnroll.Enabled = true; UserFingerAdd_FormClosing(null, null); } IsRegister = false; return; } else { textRes.Text = "你需要按下 " + (REGISTER_FINGER_COUNT - RegisterCount) + " 次指纹\r\n" + textRes.Text; } } } break; default: base.DefWndProc(ref m); break; } }
protected override void DefWndProc(ref Message m) { switch (m.Msg) { case MESSAGE_CAPTURED_OK: { MemoryStream ms = new MemoryStream(); BitmapFormat.GetBitmap(FPBuffer, mfpWidth, mfpHeight, ref ms); Bitmap bmp = new Bitmap(ms); this.picFPImg.Image = bmp; 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.Text = "This finger was already register by " + fid + "!"; return; } if (RegisterCount > 0 && zkfp2.DBMatch(mDBHandle, CapTmp, RegTmps[RegisterCount - 1]) <= 0) { textRes.Text = "Please press the same finger 3 times for the enrollment"; return; } Array.Copy(CapTmp, RegTmps[RegisterCount], cbCapTmp); 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.Text = "enroll succ"; } else { textRes.Text = "enroll fail, error code=" + ret; } IsRegister = false; return; } else { textRes.Text = "You need to press the " + (REGISTER_FINGER_COUNT - RegisterCount) + " times fingerprint"; } } else { if (cbRegTmp <= 0) { textRes.Text = "Please register your finger first!"; return; } if (bIdentify) { 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.Text = "Identify succ, fid= " + fid + ",score=" + score + "!"; return; } else { textRes.Text = "Identify fail, ret= " + ret; return; } } else { int ret = zkfp2.DBMatch(mDBHandle, CapTmp, RegTmp); if (0 < ret) { textRes.Text = "Match finger succ, score=" + ret + "!"; return; } else { textRes.Text = "Match finger fail, ret= " + ret; return; } } } } break; default: base.DefWndProc(ref m); break; } }
private EventTransItem OnFingerGet() { EventTransItem evitem = new EventTransItem(); evitem.result = 100; //传送图像 MemoryStream ms = new MemoryStream(); try { BitmapFormat.GetBitmap(FPBuffer, fpInstance.imageWidth, fpInstance.imageHeight, ref ms); //Bitmap bmp = new Bitmap(ms); //evitem.Transitem = bmp; evitem.Transitem = ms; } catch (Exception ex) { } evitem.EventType = "指纹仪获得图像"; //this._eventAggregator.GetEvent<HardWareControlEvent>().Publish(evitem); int ret = zkfp.ZKFP_ERR_OK; int fid = 0, score = 0; ret = fpInstance.Identify(CapTmp, ref fid, ref score); switch (SensorStates) { case (1): { if (zkfp.ZKFP_ERR_OK == ret) { evitem.EventType = "这个手指指纹已经被注册为 " + fid + "号!"; evitem.result = 10; break; } if (RegisterCount > 0 && fpInstance.Match(CapTmp, RegTmps[RegisterCount - 1]) <= 0) { evitem.EventType = "请不要更换手指!!!"; evitem.result = 10; break; } Array.Copy(CapTmp, RegTmps[RegisterCount], cbCapTmp); RegisterCount++; if (RegisterCount >= REGISTER_FINGER_COUNT) { RegisterCount = 0; if (zkfp.ZKFP_ERR_OK == (ret = fpInstance.GenerateRegTemplate(RegTmps[0], RegTmps[1], RegTmps[2], RegTmp, ref cbRegTmp)) // &&zkfp.ZKFP_ERR_OK == (ret = fpInstance.AddRegTemplate(iFid, RegTmp)) ) { string temp = string.Empty; if (zkfp.Blob2Base64String(RegTmp, RegTmp.Length, ref temp) > 0) { //指纹注册成功,返回模板 evitem.Transitem = temp; evitem.EventType = "指纹注册完成"; evitem.result = 100; } else { evitem.EventType = "指纹注册失败,错误代码" + ret; evitem.result = 100; } } else { evitem.EventType = "指纹注册失败,错误代码" + ret; evitem.result = 100; } break; } else { evitem.EventType = "请继续按压相同的指纹" + (REGISTER_FINGER_COUNT - RegisterCount) + "次!"; evitem.result = 10; break; } } case (2): { ret = fpInstance.Identify(CapTmp, ref fid, ref score); if (zkfp.ZKFP_ERR_OK == ret) { evitem.Transitem = _userList.SingleOrDefault(a => a.FingerNo == fid); evitem.EventType = "指纹识别成功"; evitem.result = 100; break; } else { evitem.EventType = "识别失败,错误代码= " + ret; evitem.result = 100; break; } } case (3): { ret = fpInstance.Match(CapTmp, RegTmp); if (0 < ret) { evitem.Transitem = _userList.SingleOrDefault(a => a.FingerNo == fid); evitem.EventType = "指纹识别成功"; evitem.result = 100; break; } else { evitem.EventType = "识别失败,错误代码= " + ret; evitem.result = 100; break; } } } return(evitem); }
protected override void DefWndProc(ref Message m) { switch (m.Msg) { case MESSAGE_CAPTURED_OK: { 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"); // capture template if (MessageBox.Show("Are you want to save in db?", "Confirmation t", MessageBoxButtons.YesNo) == DialogResult.Yes) { //do something SqlConnection con = new SqlConnection("Data Source = DESKTOP-PJ65AUS; Initial Catalog = BioTestDb; Integrated Security = True"); //insert the information to the database SqlCommand cmd = new SqlCommand("INSERT INTO[dbo].[tblBioTest] ([en64] ,[name]) values(@en64, @name)", con); Console.Write("Enter the Id:"); cmd.Parameters.Add("@en64", SqlDbType.VarChar, 512).Value = strShow; cmd.Parameters.Add("@name", SqlDbType.VarChar, 50).Value = "capture template data"; if (con.State == ConnectionState.Closed) { con.Open(); } int i = cmd.ExecuteNonQuery(); if (i > 0) { MessageBox.Show("Record Inserted Successfully"); } else { MessageBox.Show("Operation Failed,Please Try Again Later"); } //Get the information by Id //SqlDataAdapter dad = new SqlDataAdapter("Select * from T1 where Id=@Id", con); //Console.Write("Enter the Id to get the record:"); //dad.SelectCommand.Parameters.Add("@Id", SqlDbType.Int).Value = Convert.ToInt32(Console.ReadLine()); //DataTable dtbl = new DataTable(); //dad.Fill(dtbl); //Console.WriteLine("Id:" + dtbl.Rows[0]["Id"].ToString()); //Console.WriteLine("Name:" + dtbl.Rows[0]["Name"].ToString()); } 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"); } } else { if (cbRegTmp <= 0) { textRes.AppendText("Please register your finger first!\n"); return; } if (bIdentify) { 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("Identify succ, fid= " + fid + ",score=" + score + "!\n"); return; } else { textRes.AppendText("Identify fail, ret= " + ret + "\n"); return; } } else { int ret = zkfp2.DBMatch(mDBHandle, CapTmp, RegTmp); if (0 < ret) { textRes.AppendText("Match finger succ, score=" + ret + "!\n"); return; } else { textRes.AppendText("Match finger fail, ret= " + ret + "\n"); return; } } } } break; default: base.DefWndProc(ref m); break; } }