Tessnet2使用System.AccessViolationException关闭程序

时间:2019-07-08 13:08:15

标签: c# tessnet2

private void Recognize()
{
    Bitmap image = new Bitmap(@"C:\OCRTest\test.jpg");
    pictureBox1.Image = image;
    tessnet2.Tesseract ocr = new tessnet2.Tesseract();
    ocr.SetVariable("tessedit_char_whitelist", "0123456789");
    ocr.Init(@"C:\Users\user1\source\repos\Prog1\tessdata\", "eng", false); // To use correct tessdata
    List<tessnet2.Word> result = ocr.DoOCR(image, Rectangle.Empty);
    foreach (tessnet2.Word word in result)
    {
        textBox1.Text = string.Format("{0} : {1}", word.Confidence, word.Text);
    }
}

我在这里得到System.AccessViolationException:List<tessnet2.Word> result = ocr.DoOCR(image, Rectangle.Empty);

x86的tessnet2.dll库与x64的情况相同。

1 个答案:

答案 0 :(得分:0)

问题出在图片文件尺寸上。将图片调整为250x100px后解决了