Beispiel #1
0
		public static List<tessnet2_32::tessnet2.Word> DoOcrNormal(Bitmap image, string lang)
        {
			tessnet2_32::tessnet2.Tesseract ocr = new tessnet2_32::tessnet2.Tesseract();
            ocr.Init(null, lang, false);
			List<tessnet2_32::tessnet2.Word> result = ocr.DoOCR(image, Rectangle.Empty);
            DumpResult(result);
            return result;
        }
Beispiel #2
0
		static void Main32()
		{
			// Code usage sample
			Ocr32 ocr = new Ocr32();
			using(Bitmap bmp = new Bitmap(@"D:\temp\ocr\b1.bmp"))
			{
				tessnet2_32::tessnet2.Tesseract tessocr = new tessnet2_32::tessnet2.Tesseract();
				tessocr.Init(null, "eng", false);
				tessocr.GetThresholdedImage(bmp, Rectangle.Empty).Save("c:\\temp\\" + Guid.NewGuid() + ".bmp");
				// Tessdata directory must be in the directory than this exe
				Console.WriteLine("Multithread version");
				ocr.DoOcrMultiThread(bmp, "eng");
				Console.WriteLine("Normal version");
				Ocr32.DoOcrNormal(bmp, "eng");
			}
		}
Beispiel #3
0
 private static void Tesseract32()
 {
     Ocr32 ocr = new Ocr32();
     Assert.NotNull(ocr);
     using(Bitmap bmp = new Bitmap(pTestImagePath))
     {
         Assert.NotNull(bmp);
         tessnet2_32::tessnet2.Tesseract tessocr = new tessnet2_32::tessnet2.Tesseract();
         Assert.NotNull(tessocr);
         tessocr.Init(null, "eng", false);
         tessocr.GetThresholdedImage(bmp, Rectangle.Empty).Save(FileUtils.CombineWinPath(pTempDirectory, Guid.NewGuid().ToString()) + ".bmp");
         ocr.DoOcrMultiThread(bmp, "eng");
         List<tessnet2_32::tessnet2.Word> words = Ocr32.DoOcrNormal(bmp, "eng");
         Assert.NotNull(words);
     }
 }
Beispiel #4
0
        public void DoOcrMultiThread(Bitmap image, string lang)
        {
			tessnet2_32::tessnet2.Tesseract ocr = new tessnet2_32::tessnet2.Tesseract();
            ocr.Init(null, lang, false);
            // If the OcrDone delegate is not null then this'll be the multithreaded version
			ocr.OcrDone = new tessnet2_32::tessnet2.Tesseract.OcrDoneHandler(Finished);
            // For event to work, must use the multithreaded version
// ReSharper disable RedundantDelegateCreation
			ocr.ProgressEvent += new tessnet2_32::tessnet2.Tesseract.ProgressHandler(OcrProgressEvent);
// ReSharper restore RedundantDelegateCreation
            mEvent = new ManualResetEvent(false);
            ocr.DoOCR(image, Rectangle.Empty);
            // Wait here it's finished
            mEvent.WaitOne();
        }
Beispiel #5
0
 private static void InitTesseract32()
 {
     pOcr = new Ocr32();
     pTesseract = new tessnet2_32::tessnet2.Tesseract();
     ((tessnet2_32::tessnet2.Tesseract)pTesseract).Init(null, "eng", false);
 }