static private int GenerateRegisteredFingerPrint() { if (FingerTap == 0) { return(fpInstance.GenerateRegTemplate(RegTmps[0], RegTmps[0], RegTmps[0], RegTmp, ref regTempLen)); } else { return(fpInstance.GenerateRegTemplate(RegTmps[0], RegTmps[1], RegTmps[2], RegTmp, ref regTempLen)); } }
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); }
/// <summary> /// Combines Three Pre-Registered Fingerprint Templates as One Registered Fingerprint Template /// </summary> /// <returns></returns> private int GenerateRegisteredFingerPrint() { return(fpInstance.GenerateRegTemplate(RegTmps[0], RegTmps[1], RegTmps[2], RegTmp, ref regTempLen)); }
protected override void DefWndProc(ref Message m) { switch (m.Msg) { case MESSAGE_CAPTURED_OK: { MemoryStream ms = new MemoryStream(); BitmapFormat.GetBitmap(FPBuffer, fpInstance.imageWidth, fpInstance.imageHeight, 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 = fpInstance.Identify(CapTmp, ref fid, ref score); if (zkfp.ZKFP_ERR_OK == ret) { textRes.Text = "This finger was already register by " + fid + "!"; return; } if (RegisterCount > 0 && fpInstance.Match(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 = fpInstance.GenerateRegTemplate(RegTmps[0], RegTmps[1], RegTmps[2], RegTmp, ref cbRegTmp)) && zkfp.ZKFP_ERR_OK == (ret = fpInstance.AddRegTemplate(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 = fpInstance.Identify(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 = fpInstance.Match(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; } }