using irisHelper; using irisRefactor.FrmService; using System; using System.Diagnostics; using System.Reflection; using System.Threading; namespace irisRefactor.IrisThread { public class IdentifyTh { private static readonly IdentifyTh identiyfTh = new IdentifyTh(); private IdentifyTh() { } public static IdentifyTh GetInstance { get => identiyfTh; } public void Identify() { LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "Identify Thread Started"); ProMemory.irisConfig.IdentifyAccess = true; ProMemory.irisConfig.IdentifyThreadRun = true; // 用于计算操作耗时 Stopwatch sw = new Stopwatch(); try { int iMatchNumber = 0; float iHammingDistance = 1; int iLeftRight = 0; while (ProMemory.identifyConfig.IdentifyTaskId != "" && iMatchNumber == 0 && !ProMemory.goingToCloseForm && !ProMemory.isSyning) { if (ProMemory.irisConfig.QueueIdentify.Count > 0) { LogHelper.WriteDebugLog(MethodBase.GetCurrentMethod().DeclaringType, "QueueIdentify:" + ProMemory.irisConfig.QueueIdentify.Count); lock (ProMemory.irisConfig.QueueIdentify) { if (ProMemory.irisConfig.QueueIdentify.Count > 0) { ProMemory.irisConfig.QualifiedIrisBuffer = ProMemory.irisConfig.QueueIdentify.Pop(); } } if (ProMemory.irisConfig.QualifiedIrisBuffer != null) { //加载匹配列表 sw.Restart(); iMatchNumber = ProMemory.proConfig.CodeListMgr.MatchOneEye(ProMemory.irisConfig.QualifiedIrisBuffer, out iHammingDistance, out iLeftRight); sw.Stop(); LogHelper.WriteDebugLog(MethodBase.GetCurrentMethod().DeclaringType, "识别[" + iMatchNumber + "]:" + sw.ElapsedMilliseconds); } } } // ProMemory.timer2.Dispose();//停止计时器 //跳出循环,条件是时间到、匹配成功或者正在关闭程序 // ProMemory.irisConfig.AssessThreadRun = false; // ProMemory.irisConfig.EyeFinderThreadRun = false; ProMemory.identifyConfig.FlagFindingEye = false; if (ProMemory.appConfig.AuthConfig.HasTempDtAuthority) ProMemory.tempRegion = Form1.GetInstance().obtainTemp(); //匹配成功 if (iMatchNumber > 0) { string personId = ProMemory.proConfig.CodeListMgr.GetUserForIndex(iMatchNumber);//personId if (ProMemory.formType == "1") Form1.GetInstance().Success(personId); else if (ProMemory.formType == "2") Form2.GetInstance().Success(personId); //int time = Convert.ToInt32(ConfigHelper.GetAppConfig("showTimeSuccess")); Thread.Sleep(ProMemory.appConfig.ShowTimeSuccess); } //匹配失败 //else //{ // LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "未知人员温度:" + ProMemory.tempString.ToString()); // if (ProMemory.formType == "1") // Form1.GetInstance().Failure(); // else if (ProMemory.formType == "2") // Form2.GetInstance().Failure(); // //int time2 = Convert.ToInt32(ConfigHelper.GetAppConfig("showTimeFailure")); // Thread.Sleep(ProMemory.appConfig.ShowTimeFailure); //} ProMemory.identifyConfig.InitConfig(); ProMemory.jobRuning = false; ProMemory.cameraController.ContinuousShot_TriggerOff(); } catch (Exception ex) { LogHelper.WriteLog(MethodBase.GetCurrentMethod().DeclaringType, "虹膜匹配线程CatchError:" + ex); } } } }