Exemple #1
0
        private void TextRecogniser(Image image)
        {
            Emgu.CV.OCR.Tesseract tesseract = new Emgu.CV.OCR.Tesseract
                                                  (@"F:\Working Pack\c#\Scripter\Scripter\Templates\eng.traineddata", "eng",
                                                  OcrEngineMode.TesseractLstmCombined);
            var tempImg = new Bitmap(image).ToImage <Gray, byte>();

            tesseract.SetImage(tempImg);
            tesseract.Recognize();
            string response = tesseract.GetUTF8Text();

            tesseract.Dispose();
        }
Exemple #2
0
        private int recognizeSpeed(Rectangle rec, Image <Gray, byte> processedFrameSt)
        {
            Rectangle roi    = new Rectangle(new Point(rec.Location.X, rec.Location.Y - 2), new Size(20, 14));
            var       imPart = processedFrameSt;

            imPart.ROI = roi;
            imPart     = imPart.Copy();
            //imPart = imPart.SmoothGaussian(1);
            string tempDist = "";

            if (tess != null)
            {
                tess.SetImage(imPart);
                tess.Recognize();

                noFiltDist = tess.GetUTF8Text();
                for (int i = 0; i < noFiltDist.Length; i++)
                {
                    if ((int)noFiltDist[i] > 47 && (int)noFiltDist[i] < 58)
                    {
                        tempDist += noFiltDist[i];
                    }
                }
            }
            else
            {
                return(-666);
            }
            if (tempDist.Length >= 2)
            {
                if (distLess100)
                {
                    tempDist = tempDist.Substring(0, 2);
                }
                filtDist = Convert.ToInt32(tempDist);
            }
            else
            {
                filtDist = -1;
            }

            return(filtDist);
        }
Exemple #3
0
        /// <summary>
        /// Tesseract OCR
        /// </summary>
        /// <param name="filteredPlate"></param>
        /// <returns></returns>
        private StringBuilder TesseractOCR(UMat filteredPlate)
        {
            Emgu.CV.OCR.Tesseract.Character[] words;
            StringBuilder strBuilder = new StringBuilder();

            using (UMat tmp = filteredPlate.Clone())
            {
                _ocr.SetImage(tmp);
                _ocr.Recognize();

                strBuilder.Append(_ocr.GetUTF8Text());

                words = _ocr.GetCharacters();

                //if (words.Length == 0) continue;

                //for (int i = 0; i < words.Length; i++)
                //{
                //    strBuilder.Append(words[i].Text);
                //}
            }

            return(strBuilder);
        }
Exemple #4
0
 public List <string> ConvertImage(Bitmap image)
 {
     _tesseract.SetImage(new Image <Bgr, byte>(image));
     _tesseract.Recognize();
     return(_tesseract.GetLinesOfText());
 }
Exemple #5
0
 public Receipt ConvertImage(Bitmap image)
 {
     _tesseract.SetImage(new Image <Bgr, byte> (image));
     _tesseract.Recognize();
     return(_tesseract.GetReceipt());
 }