Ejemplo n.º 1
0
        protected override void Capture_ImageGrabbed(object sender, EventArgs e)
        {
            base.Capture_ImageGrabbed(sender, e);
            try
            {
                if (FaceOut >= FaceOutCount)
                {
                    ShowEventMsg("对比失败", MsgType.FaceErr);
                    Dispatcher.InvokeAsync(() => { MiniImg.Source = FaceFun.ByteToBitmapImage(PhotoErr); });
                }
                //摄像头视频流输出
                Dispatcher.Invoke(() => { CameraPic1.ImageView = CvrPass && !FacePass ? Face.FaceBitmapSource : MyMat.Bitmap; });

                if (CvrPass && FacePass && _qrInfo != null)
                {
                    if (IsIdSame && (Cvr.Info.Number != _qrInfo.Value.IdNo))
                    {
                        ShowEventMsg("身份证号码与票面不符合!", MsgType.Info);
                    }
                    else
                    {
                        InSession(); //写入本地记录并且通知
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToSaveLog("FaceIdView.Capture_ImageGrabbed:");
            }
        }
Ejemplo n.º 2
0
 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:");
     }
 }
Ejemplo n.º 3
0
        /// <summary> 写入数据库 </summary>
        protected override void InSession()
        {
            try
            {
                //写入本地记录并且通知
                var info = new SessionsInfo
                {
                    SessionId    = MyMatch.SessionId,
                    CreateDate   = DateTime.Now,
                    Name         = MyMatch.SessionName,
                    IdNo         = Cvr.Info.Number,
                    IdCardPhoto  = IrAdvanced.ReadBytesFromFile(FaceFun.BaseDir + "\\pic.bmp"),
                    TakePhoto    = PhotoOk,
                    FaceData     = FaceFun.StructToBytes(CameraRft),
                    IdAddress    = Cvr.Info.Address,
                    TicketType   = 2,
                    TicketNo     = null,
                    Area         = null,
                    Row          = null,
                    Seat         = null,
                    TelNo        = IrAdvanced.ReadString("TelNo"),
                    TelArea      = IrAdvanced.ReadString("TelArea"),
                    BuyName      = Cvr.Info.Name,
                    BuyPhoto     = null,
                    BuyDate      = null,
                    ValidateType = 1,
                    SyncTime     = null,
                    Status       = 0,
                    Remark       = "",
                    UserName     = AftUserName,
                };

                if (FaceFun.AddSessions(info) > 0)
                {
                    Dispatcher.InvokeAsync(() =>
                    {
                        MiniImg.Source = FaceFun.ByteToBitmapImage(PhotoOk);
                    });
                    base.InSession();
                }
                else
                {
                    "写入数据库失败".ToSaveLog("入场记录时:");
                }
            }
            catch (Exception ex)
            {
                ex.ToSaveLog("InSession");
            }
        }
Ejemplo n.º 4
0
 protected override void Capture_ImageGrabbed(object sender, EventArgs e)
 {
     base.Capture_ImageGrabbed(sender, e);
     try
     {
         if (FaceOut >= FaceOutCount)
         {
             ShowEventMsg("对比失败", MsgType.FaceErr);
             Dispatcher.InvokeAsync(() => { MiniImg.Source = FaceFun.ByteToBitmapImage(PhotoErr); });
         }
         //摄像头视频流输出
         Dispatcher.Invoke(() => { CameraPic1.ImageView = CvrPass && !FacePass ? Face.FaceBitmapSource : MyMat.Bitmap; });
     }
     catch (Exception ex)
     {
         ex.ToSaveLog("FaceIdView.GetCamBitmap:");
     }
 }
Ejemplo n.º 5
0
        protected override void ShowEventMsg(string strMsg, MsgType type)
        {
            base.ShowEventMsg(strMsg, type);
            Dispatcher.InvokeAsync(() =>
            {
                switch (type)
                {
                case MsgType.TipErr:
                    Tip1.Text       = strMsg;
                    Tip1.Foreground = Brushes.Red;
                    break;

                case MsgType.Info:
                    Tip2.Text       = strMsg;
                    Tip2.Foreground = Brushes.GreenYellow;
                    break;

                case MsgType.InfoErr:
                    Tip2.Text       = strMsg;
                    Tip2.Foreground = Brushes.Red;
                    break;

                case MsgType.TipOk:
                    Tip1.Text       = strMsg;
                    Tip1.Foreground = Brushes.White;
                    Tip2.Text       = "请将身份证放置刷卡感应区域!";
                    MiniImg.Source  = FaceFun.ByteToBitmapImage(PhotoOk);
                    break;

                case MsgType.FaceOk:
                    Tip1.Text       = strMsg;
                    Tip1.Foreground = Brushes.White;
                    icPass          = false;
                    HideShow(2);
                    break;

                case MsgType.FaceErr:
                    Tip1.Text       = strMsg;
                    Tip1.Foreground = Brushes.Red;
                    break;
                }
            });
        }