private void timerPlateIn_Tick(object sender, EventArgs e) { Image <Bgr, byte> capPrImageIn = null; if (isDemo) { if (_currentFramePlateIn < _totalFramePlateIn) { capPrImageIn = _capturePlateIn.QueryFrame().ToImage <Bgr, byte>(); _currentFramePlateIn++; Image_Xe_Vao_Truoc.Update(); } //await Task.Delay(1000 / _fpsFaceIn / 4); } else { capPrImageIn = _capturePlateIn.QueryFrame().ToImage <Bgr, byte>(); //Image_Xe_Vao_Truoc.Update(); //Image_Xe_Vao_Sau.Update(); } if (capPrImageIn != null && isFinishFaceIn) { try { List <Rectangle> listRect = new List <Rectangle>(); List <Mat> listMat = new List <Mat>(); Bitmap imagePlate; Image Plate_Draw; Image <Bgr, byte> Plate_Draw_Resize; _currentPRDT = DateTime.Now; //if (_currentPRDT.Subtract(_startPRDT).TotalMilliseconds > DELAY_PR_DT) //{ // _startPRDT = DateTime.Now; _lpr.ProcessImage(capPrImageIn.Bitmap, out Plate_Draw, out Plate_Draw_Resize, null); if (Plate_Draw_Resize != null) { isFinishPlateIn = true; Image_Plate.Image = Plate_Draw; } //if (_lpr.DetectRectangleLPR(capPrImageIn.Bitmap, out imagePlate, out listRect, out listMat)) //{ //} //} } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
private void timerPlateIn_Tick(object sender, EventArgs e) { Image <Bgr, byte> capPrImageIn = null; if (_isDemo) { if (_currentFramePlateIn < _totalFramePlateIn) { capPrImageIn = _capturePlateIn.QueryFrame().ToImage <Bgr, byte>(); _currentFramePlateIn++; Image_Xe_Vao_Truoc.Image = capPrImageIn.Resize(Image_Xe_Vao_Truoc.Width, Image_Xe_Ra_Truoc.Height, Inter.Cubic).Bitmap; Image_Xe_Vao_Truoc.Update(); } //await Task.Delay(1000 / _fpsFaceIn / 4); } else if (_capturePlateIn.IsOpened) { capPrImageIn = _capturePlateIn.QueryFrame().ToImage <Bgr, byte>(); Image_Xe_Vao_Truoc.Image = capPrImageIn.Resize(Image_Xe_Vao_Truoc.Width, Image_Xe_Ra_Truoc.Height, Inter.Cubic).Bitmap; } if (capPrImageIn != null && _isFinishFaceIn && !_isFinishIn) { lbNotify.Text = Global.TEXT_DETECT_PLATE; try { Image Plate_Draw; Image <Bgr, byte> PlateResize; _lprPlateIn.ProcessImage(capPrImageIn.Bitmap, out Plate_Draw, out PlateResize, _plate); if (_lprPlateIn.PlateImagesList.Count != 0) { _isFinishPlateIn = true; Bitmap imagePlate = null; string biensoxe = _lprPlateIn.GetRecoginatinon(_lprPlateIn.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 (_checkOCRPlateIn != biensoxe) { _isCheckPlateIn = false; _checkOCRPlateIn = biensoxe; } else { lbNotify.Text = Global.TEXT_SAVE; _isCheckPlateIn = true; } lbPlate.Text = biensoxe; if (_isCheckPlateIn) { if (_IsExistFaceIn) { _dataContext.CreateGoLeave(Int32.Parse(lbID.Text), biensoxe, pathface, pathPlate, pathFull); _captureFaceIn.QueryFrame().ToImage <Bgr, byte>().Save(pathFull); imagePlate.Save(pathPlate); _image_Store_FaceIn.Save(pathface); string OCR = biensoxe; lbPlate.Text = OCR; lbNotify.Text = Global.TEXT_SUCCESS; _isFinishFaceIn = false; _isFinishIn = true; MessageBox.Show("Xe vào thành công"); _startWatingTimeFaceIn = DateTime.Now; } else { _dataContext.CreateMember(biensoxe, pathface, pathPlate, pathFull); _captureFaceIn.QueryFrame().ToImage <Bgr, byte>().Save(pathFull); imagePlate.Save(pathPlate); _image_Store_FaceIn.Save(pathface); string OCR = biensoxe; lbPlate.Text = OCR; lbNotify.Text = Global.TEXT_SUCCESS; _isFinishFaceIn = false; _isFinishIn = true; MessageBox.Show("Xe vào thành công"); _startWatingTimeFaceIn = DateTime.Now; } lbDirector.Text = Global.TEXT_DIRECTOR_GO; _dataContext.LoadTraningFace(out _listFace, out _listLabel); _recognition.Update(_listFace, _listLabel); } _isFinishPlateIn = true; } } #endregion } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }