Example #1
0
 /// <summary>
 ///   Initialize a new OCR Object.
 /// 
 ///   This object is a wrapper for the Emgu Tesseract Wrapper to give a level of abstraction
 ///   necessary for scanning shreds
 /// </summary>
 /// <param name="accuracy"> Desired Accuracy setting </param>
 /// <param name="language"> Language of text on image used for OCR model </param>
 /// <param name="enableTimer"> Set enable Timer to true to measure scan time for diagnostic purposes </param>
 public OCR(Accuracy accuracy = Accuracy.High, string language = "eng", bool enableTimer = false)
 {
     _timer = new Stopwatch();
     if (enableTimer)
     {
         _timer.Start();
     }
     Tesseract.OcrEngineMode mode = Tesseract.OcrEngineMode.OEM_TESSERACT_CUBE_COMBINED;
     switch (accuracy)
     {
         case Accuracy.Low:
             mode = Tesseract.OcrEngineMode.OEM_TESSERACT_ONLY;
             break;
         case Accuracy.Medium:
             mode = Tesseract.OcrEngineMode.OEM_CUBE_ONLY;
             break;
         case Accuracy.High:
             mode = Tesseract.OcrEngineMode.OEM_TESSERACT_CUBE_COMBINED;
             break;
     }
     _tesseract = new Tesseract("tessdata", language, mode);
     //"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
     _tesseract.SetVariable("tessedit_unrej_any_wd", "T");
     //_tesseract.SetVariable("tessedit_char_whitelist","abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWZ0123456789.,");
     _text = null;
     _chars = null;
     _confidence = -1;
 }
Example #2
0
        public Form1()
        {
            InitializeComponent();

            ocr = new Tesseract();
            ocr.SetVariable("tessedit_char_whitelist", "1234567890");
            ocr.Init(@"D:\", "eng", OcrEngineMode.TesseractOnly);
        }
Example #3
0
        /// <summary>
        /// Create a license plate detector
        /// </summary>
        /// <param name="dataPath">
        /// The datapath must be the name of the parent directory of tessdata and
        /// must end in / . Any name after the last / will be stripped.
        /// </param>
        public LicensePlateDetector(String dataPath)
        {
            //create OCR engine
#if __IOS__ || __ANDROID__
            //LSTM mode requires the native binary to be build with libtiff
            //Open CV's iOS build disables libtiff in the build process
            //For iOS, we will use TessractOnly mode
            //Android build is also having issues with the LSTM engine
            //For Android, we will also use Tesseract Only mode.
            InitOcr(dataPath, "eng", OcrEngineMode.TesseractOnly);
#else
            InitOcr(dataPath, "eng", OcrEngineMode.TesseractLstmCombined);
#endif
            _ocr.SetVariable("tessedit_char_whitelist", "ABCDEFGHIJKLMNOPQRSTUVWXYZ-1234567890");
        }
Example #4
0
        public BotCV(IntPtr win, int Hmin, int Smin, int Vmin, int Hmax, int Smax, int Vmax)
        {
            this.Hmin = Hmin;
            this.Hmax = Hmax;
            this.Smin = Smin;
            this.Smax = Smax;
            this.Vmin = Vmin;
            this.Vmax = Vmax;

            sc          = new ScreenCapture();
            winDiscript = win;

            try
            {
                tess = new Emgu.CV.OCR.Tesseract(@"", "eng", OcrEngineMode.TesseractOnly);
                tess.SetVariable("tessedit_char_whitelist", ".0123456789");
            }
            catch (Exception te)
            {
                Console.WriteLine(te.Message);
                tess = null;
            }
        }
Example #5
0
 /// <summary>
 /// Create a license plate detector
 /// </summary>
 /// <param name="dataPath">
 /// The datapath must be the name of the parent directory of tessdata and
 /// must end in / . Any name after the last / will be stripped.
 /// </param>
 public LicensePlateDetector(String dataPath)
 {
    //create OCR engine
    _ocr = new Tesseract(dataPath, "eng", OcrEngineMode.TesseractCubeCombined);
    _ocr.SetVariable("tessedit_char_whitelist", "ABCDEFGHIJKLMNOPQRSTUVWXYZ-1234567890");
 }
Example #6
0
 /// <summary>
 /// Create a license plate detector
 /// </summary>
 public LicensePlateDetector()
 {
     //create OCR engine
     _ocr = new Tesseract("tessdata", "eng", Tesseract.OcrEngineMode.OEM_TESSERACT_CUBE_COMBINED);
     _ocr.SetVariable("tessedit_char_whitelist", "ABCDEFGHIJKLMNOPQRSTUVWXYZ-1234567890");
 }
Example #7
0
        static void Main(string[] args)
        {
            var files = Directory.GetFiles(@"d:\raw\classified\");

            //var img = new Image<Rgb, byte>(files[0]);
            var img = new Image<Emgu.CV.Structure.Gray, byte>(@"d:\raw\classified\test.jpg");

            var _ocr = new Tesseract(@"D:\", "eng", OcrEngineMode.TesseractCubeCombined);
            _ocr.SetVariable("tessedit_char_whitelist", "1234567890");

            _ocr.Recognize(img);

            var result = _ocr.GetCharacters();
        }
Example #8
0
        private void button5_Click(object sender, EventArgs e)
        {
            var _ocr = new Tesseract(@"D:\", "eng", OcrEngineMode.TesseractCubeCombined);
            _ocr.SetVariable("tessedit_char_whitelist", "1234567890");

            _ocr.Recognize(_inputArray);

            var result = _ocr.GetCharacters().ToList();

            var sb = new StringBuilder();

            result.ForEach(c => sb.Append(c.Text));

            label1.Text = sb.ToString();
        }
Example #9
0
 public RecognatorBrains()
 {
     //_ocr = new Emgu.CV.OCR.Tesseract("C:/Users/sedgu/Documents/emgucv-windesktop 3.2.0.2682/Emgu.CV.Example/LicensePlateRecognition/obj/Debug/tessdata", "eng", OcrEngineMode.TesseractOnly);
     InitOcr(Directory.GetCurrentDirectory() + "\\", "eng", OcrEngineMode.TesseractCubeCombined);
     _ocr.SetVariable("tessedit_char_whitelist", "ABEKMHOPCTXY-1234567890");
 }