Beispiel #1
0
        public MainWindow()
        {
            InitializeComponent();

            for (var i = 1; i < 15; i++)
            {
                ListView1.Items.Add(new ParkingEntry {
                    Name = $"Person #{i}", PlateNumber = $"Plate #{i}", DateEntry = DateTime.Now, DateExit = DateTime.Now.AddHours(i)
                });
            }

            var path   = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var folder = System.IO.Path.Combine(path, "tessdata");

            _licensePlateDetector = new LicensePlateDetector(folder);

            Mat  m  = new Mat(@"C:\Users\cayent\Desktop\ImageTest\222.jpg");
            UMat um = m.GetUMat(AccessType.ReadWrite);

            this.ImagePlate.Image = um;
            //ProcessImage(m);
            _ocr = new Tesseract(folder, "eng", OcrEngineMode.TesseractLstmCombined, "ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890");
            _ocr.SetVariable("tessedit_char_whitelist", "ABCDEFGHIJKLMNOPQRSTUVWXYZ-1234567890");


            //create OCR engine
            //_ocr = new Tesseract(System.AppDomain.CurrentDomain.BaseDirectory + @"\Data\\", "eng", OcrEngineMode.TesseractLstmCombined);
            //_ocr.Init("", "eng", OcrEngineMode.TesseractLstmCombined);
            //_ocr.SetVariable("tessedit_char_whitelist", "ABCDEFGHIJKLMNOPQRSTUVWXYZ-1234567890");

            _ocr.SetImage(m);
            _ocr.Recognize();

            var text1 = _ocr.GetBoxText();
            var text2 = _ocr.GetCharacters();
            var text3 = _ocr.GetHOCRText();
            //var text4 = _ocr.GetOsdText(1);
            var text5 = _ocr.GetTSVText();
            var text6 = _ocr.GetUNLVText();
            var text7 = _ocr.GetUTF8Text();

            Plate.Text = text7;
        }