Tessnet2 close program with System.AccessViolationException

75 views Asked by At
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);
    }
}

I get System.AccessViolationException here: List<tessnet2.Word> result = ocr.DoOCR(image, Rectangle.Empty);

Library tessnet2.dll for x86, with x64 the same situation.

1

There are 1 answers

0
Константин Вольный On

Problem was in picture file dimensions. Was solved after I resize picture to 250x100px