protected override void Capture_ImageGrabbed(object sender, EventArgs e) { try { MyMat = null; MyMat = new Mat(); if (MyCapture == null) { return; } MyCapture.Retrieve(MyMat, 0); if (icPass && white != null) { FaceOut++; if (FaceOut >= FaceOutCount) { white.Value.IdNo.ToSaveLog("比对超时,比对失败:"); PhotoErr = FaceFun.BitmapToByte(MyMat.Bitmap); icPass = false; ShowEventMsg("对比失败", MsgType.FaceErr); Dispatcher.InvokeAsync(() => { MiniImg.Source = FaceFun.ByteToBitmapImage(PhotoErr); }); ShowEventMsg("失败:当前用户与身份证对比失败", MsgType.Info); } else { ShowEventMsg("识别中" + (FaceOutCount - FaceOut), MsgType.TipErr); CameraRft = Face.FaceTz(MyMat); if (Face.VerifyIr.ToInt32() == 0) { FaceIr = FaceFun.FaceResult(CameraRft, Rft2); if (FaceIr > _confidence) { try { //保存识别到的摄像头图片 white.Value.IdNo.ToSaveLog("保存检票成功照片:"); // MyMat.Bitmap.Save(string.Format("{0}{1}.jpg", CamPath, Cvr.Info.Number),ImageFormat.Jpeg); PhotoOk = FaceFun.BitmapToByte(MyMat.Bitmap); ShowEventMsg("比对成功", MsgType.TipOk); FaceIr.ToString().ToSaveLog(white.Value.IdNo + " 比对成功,相似度:"); FacePass = true; //当取信值大于80%认为是同一个人比对成功 } catch (Exception ex) { ex.ToSaveLog("OnComplete:"); } } } } } //摄像头视频流输出 Dispatcher.Invoke(() => { CameraPic1.ImageView = icPass && !FacePass ? Face.FaceBitmapSource : MyMat.Bitmap; }); } catch (Exception ex) { ex.ToSaveLog("Capture_ImageGrabbed:"); } }
protected override void Capture_ImageGrabbed(object sender, EventArgs e) { try { MyMat = null; MyMat = new Mat(); if (MyCapture == null) { return; } if (Cvr == null) { "身份证硬件初始化失败".ToSaveLog("FaceIdView.Cature_ImageGrabbed:"); return; } MyCapture.Retrieve(MyMat); if (CvrPass && !FacePass) { FaceOut++; if (FaceOut >= FaceOutCount) { Cvr.Info.Number.ToSaveLog("比对超时,比对失败:"); PhotoErr = FaceFun.BitmapToByte(MyMat.Bitmap); CvrPass = false; ShowEventMsg("比对超时:当前用户与身份证对比失败", MsgType.Info); return; } ShowEventMsg("识别中" + (FaceOutCount - FaceOut), MsgType.TipErr); CameraRft = Face.FaceTz(MyMat); if (Face.VerifyIr.ToInt32() == 0) { FaceIr = FaceFun.FaceResult(CameraRft, Rft2); if (FaceIr > _confidence) { try { //保存识别到的摄像头图片 Cvr.Info.Number.ToSaveLog("保存检票成功照片:"); // MyMat.Bitmap.Save(string.Format("{0}{1}.jpg", CamPath, Cvr.Info.Number),ImageFormat.Jpeg); PhotoOk = FaceFun.BitmapToByte(MyMat.Bitmap); ShowEventMsg("比对成功", MsgType.TipOk); FaceIr.ToString().ToSaveLog(Cvr.Info.Number + " 比对成功,相似度:"); FacePass = true; //当取信值大于80%认为是同一个人比对成功 } catch (Exception ex) { ex.ToSaveLog("OnComplete:"); } } } } } catch (Exception ex) { ex.ToSaveLog("Capture_ImageGrabbed:"); } }
protected override void Capture_ImageGrabbed(object sender, EventArgs e) { try { MyMat = null; MyMat = new Mat(); if (MyCapture == null) { return; } MyCapture.Retrieve(MyMat, 0); //摄像头视频流输出 Dispatcher.Invoke(() => { CameraPic2.ImageView2 = null; CameraPic2.ImageView2 = MyMat.Bitmap; }); System.Threading.Thread.Sleep(40);//每秒25帧 if (FacePass) { if (sucessTime.AddSeconds(1.5) < DateTime.Now) { FacePass = false; } else { return; } } if (AFT_System.Face.FaceFun.WhiteList != null && !Compareing) { Compareing = true; Thread thread = new Thread(FaceCompare); thread.Start(); } } catch (Exception ex) { ex.ToSaveLog("Capture_ImageGrabbed:"); } }