コード例 #1
0
        private void btnAllow_Click_1(object sender, EventArgs e)
        {
            ReasonForm reasonForm = new ReasonForm(null, null, null, null, null, null, null, null);

            reasonForm.Show();
        }
コード例 #2
0
        private void timerPlateOut_Tick(object sender, EventArgs e)

        {
            Image <Bgr, byte> capPrImageOut = null;

            if (_isDemo)
            {
                if (_currentFramePlateOut < _totalFramePlateOut)
                {
                    capPrImageOut = _capturePlateOut.QueryFrame().ToImage <Bgr, byte>();
                    _currentFramePlateOut++;
                    Image_Xe_Ra_Truoc.Image = capPrImageOut.Resize(Image_Xe_Ra_Truoc.Width, Image_Xe_Ra_Truoc.Height, Inter.Cubic).Bitmap;
                    Image_Xe_Ra_Truoc.Update();
                }
                //await Task.Delay(1000 / _fpsFaceIn / 4);
            }
            else if (_capturePlateOut.IsOpened)
            {
                capPrImageOut           = _capturePlateOut.QueryFrame().ToImage <Bgr, byte>();
                Image_Xe_Ra_Truoc.Image = capPrImageOut.Resize(Image_Xe_Ra_Truoc.Width, Image_Xe_Ra_Truoc.Height, Inter.Cubic).Bitmap;
            }

            if (capPrImageOut != null && _isFinishFaceOut && !_isFinishOut)
            {
                lbNotify.Text = Global.TEXT_DETECT_PLATE;
                try
                {
                    Image             Plate_Draw;
                    Image <Bgr, byte> PlateResize;
                    _lprPlateOut.ProcessImage(capPrImageOut.Bitmap, out Plate_Draw, out PlateResize, _plate);
                    if (_lprPlateOut.PlateImagesList.Count != 0)
                    {
                        _isFinishPlateOut = true;
                        Bitmap imagePlate = null;
                        string biensoxe   = _lprPlateOut.GetRecoginatinon(_lprPlateOut.PlateImagesList, out imagePlate);
                        Image_Plate.Image = (new Image <Bgr, byte>(imagePlate).Resize(Image_Plate.Width, Image_Plate.Height, Inter.Cubic)).Bitmap;
                        #region Xử lý khi đã nhận diện biển số thành công (Lưu ảnh và lưu vào cơ sở dữ liệu
                        if (imagePlate != null)
                        {
                            DateTime currentDT = DateTime.Now;
                            string   stringDT  = currentDT.Year.ToString() + currentDT.Month.ToString()
                                                 + currentDT.Day.ToString() + currentDT.Hour.ToString()
                                                 + currentDT.Minute.ToString() + currentDT.Second.ToString();
                            string pathface  = Global.PATH_FACE_IMAGE + stringDT + ".jpg";
                            string pathPlate = Global.PATH_PLATE_IMAGE + stringDT + ".jpg";;
                            string pathFull  = Global.PATH_FULL_IMAGE + stringDT + ".jpg";;
                            if (biensoxe.Length > 7)
                            {
                                if (_checkOCRPlateOut != biensoxe)
                                {
                                    _isCheckPlateOut  = false;
                                    _checkOCRPlateOut = biensoxe;
                                }
                                else
                                {
                                    //lbNotify.Text = Global.TEXT_SAVE;
                                    _isCheckPlateOut = true;
                                }
                                lbPlate.Text = biensoxe;
                                if (_isCheckPlateOut)
                                {
                                    if (_IsExistFaceOut)
                                    {
                                        LeaveError resultDB = _dataContext.CheckGoLeave(Int32.Parse(lbID.Text), biensoxe, pathface, pathPlate, pathFull);
                                        if (resultDB == LeaveError.SUCCESSS)
                                        {
                                            _captureFaceOut.QueryFrame().ToImage <Bgr, byte>().Save(pathFull);
                                            imagePlate.Save(pathPlate);
                                            _image_Store_FaceOut.Save(pathface);
                                            string OCR = biensoxe;
                                            lbPlate.Text  = OCR;
                                            lbNotify.Text = Global.TEXT_SUCCESS;
                                            MessageBox.Show("Xe ra thành công");
                                            _isFinishFaceOut        = false;
                                            _isFinishOut            = true;
                                            _startWatingTimeFaceOut = DateTime.Now;
                                            _isLeave         = false;
                                            _countErrorPlate = 0;
                                        }
                                        else if (resultDB == LeaveError.NOTFOUND)
                                        {
                                            if (_isLeave)
                                            {
                                                lbNotify.Text = Global.TEXT_SUCCESS;
                                                MessageBox.Show("Xe ra thất bại, có thể khuôn mặt không đúng hoặc là xe mới. Vui lòng kiểm tra lại ");

                                                _isLeave = false;
                                            }
                                        }
                                        else if (resultDB == LeaveError.WRONGOCG && _countErrorPlate <= 5)
                                        {
                                            _countErrorPlate++;
                                        }
                                        else if (resultDB == LeaveError.WRONGOCG && _countErrorPlate > 5)
                                        {
                                            ReasonForm reasonForm = new ReasonForm(null, biensoxe,
                                                                                   null, _captureFaceOut.QueryFrame().ToImage <Bgr, byte>(),
                                                                                   null, _image_Store_FaceOut,
                                                                                   null, new Image <Bgr, byte>(imagePlate));
                                            reasonForm.ShowDialog();
                                            // _dataContext.CreateMember(biensoxe, pathface, pathPlate, pathFull);
                                            string OCR = biensoxe;
                                            lbPlate.Text            = OCR;
                                            _isFinishFaceOut        = false;
                                            _isFinishOut            = true;
                                            _startWatingTimeFaceOut = DateTime.Now;
                                        }
                                    }
                                    else
                                    {
                                        if (_isStopFinish)
                                        {
                                            ReasonForm reasonForm = new ReasonForm(null, biensoxe,
                                                                                   null, _captureFaceOut.QueryFrame().ToImage <Bgr, byte>(),
                                                                                   null, _image_Store_FaceOut,
                                                                                   null, new Image <Bgr, byte>(imagePlate));
                                            reasonForm.Show();
                                            // _dataContext.CreateMember(biensoxe, pathface, pathPlate, pathFull);
                                            string OCR = biensoxe;
                                            lbPlate.Text            = OCR;
                                            _isFinishFaceOut        = false;
                                            _isFinishOut            = true;
                                            _startWatingTimeFaceOut = DateTime.Now;
                                        }
                                    }
                                    lbDirector.Text = Global.TEXT_DIRECTOR_OUT;

                                    _dataContext.LoadTraningFace(out _listFace, out _listLabel);
                                    _recognition.Update(_listFace, _listLabel);
                                }
                            }
                        }
                        #endregion
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }