本文介绍了Tessnet2 for .Net - 退出tessocr.Init调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我试图使用Tessnet2制作ocr但是当tessocr.Init被调用时它会退出。



Hello

I am trying to make ocr using Tessnet2 but it exit when "tessocr.Init" called.

ocr = new Ocr();
using (Bitmap bmp = new Bitmap(@"C:\OCR\IMG.jpg"))
            {
                tessnet2.Tesseract tessocr = new tessnet2.Tesseract();
                tessocr.Init(null, "eng", false); //Application exit after this line.

                tessocr.GetThresholdedImage(bmp, Rectangle.Empty).Save("elo.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

                Console.WriteLine("dsadasdasd");
                ocr.DoOCRNormal(bmp, "eng");

            }
 public class Ocr
        {
            public void DumpResult(List<tessnet2.Word> result)
            {
                foreach (tessnet2.Word word in result)
                {
                    Console.WriteLine("{0} {1}", word.Confidence, word.Text);
                }
            }

            public List<tessnet2.Word> DoOCRNormal(Bitmap image, string lang)
            {
                tessnet2.Tesseract ocr = new tessnet2.Tesseract();
                ocr.Init(null, lang, false);

                List<tessnet2.Word> result = ocr.DoOCR(image, Rectangle.Empty);
                DumpResult(result);
                return result;
            }
        }

推荐答案



这篇关于Tessnet2 for .Net - 退出tessocr.Init调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 22:30