Tessnet2 for .Net - 退出tessocr.Init调用 [英] Tessnet2 for .Net - exits at the tessocr.Init call

查看:96
本文介绍了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;
            }
        }

推荐答案

看一下这篇文章的回复http://stackoverflow.com/questions/2053575/tessnet2-fails-to-load [ ^ ] - 特别是第二个回复

你的Tesseract安装可能会出现问题
Have a look at the responses to this post http://stackoverflow.com/questions/2053575/tessnet2-fails-to-load[^] - in particular the 2nd response
It's likely to be a problem with your Tesseract install


试试这个对我有用。



在bin中添加testdata文件夹\ debug文件夹。问题解决了。
Try this it works for me.

Add testdata folder in your bin\debug folder. Problem solved.


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆