Home > Net >  C # use EmguCV OCR, call AccessViolationException Tesseract times
C # use EmguCV OCR, call AccessViolationException Tesseract times

Time:10-02

Private void button3_Click (object sender, EventArgs e)
{
String path=Application. StartupPath + "\ \ tessdata/";//that the path of the data source, in the run directory tessdata folder,
String language="";//that language choice,
//* judgment choose language *//
If (checkBox1. Checked & amp; & CheckBox2. Checked)//checkBox1 to identify English,
{
Language="chi_sim + eng";
}
The else
{
If (checkBox2. Checked)
{
Language="chi_sim";
}
The else
{
Language="eng".
CheckBox1. Checked=true;
}
}

_ocr=new Tesseract (path, language, OcrEngineMode. Default);
//instantiate the specified argument tessdata class,
_ocr. Recognize ();
//image,
Tesseract. Character [] characters.=_ocr GetCharacters ();// this is an error "System. AccessViolationException" type of untreated abnormalities in Emgu. CV. World. DLL, other information: try to read or write protected memory, this usually indicates other memory has been damaged,
//get identification data

Bgr drawColor=new Bgr (Color. Blue);
//create the Bgr as blue,
Foreach (Tesseract. Character c in characters)//traverse each identification data,
{
Image. The Draw (c.R egion, drawColor, 1);//draw the detected region,
}
ImageBox1. Image=Image;//draw a rectangle area images displayed
A String of text=_ocr. GetUTF8Text ();//get identification string,
RichTextBox1. Text=Text;//show for string,
//MessageBox. Show (ex. Message);
Check the working directory//MessageBox. Show (" whether there is a language pack ");

}
}

CodePudding user response:

Pictures of your address change, don't put the desktop, or downloaded from the Internet pictures will appear this kind of situation

CodePudding user response:

Sure is not a problem caused by word stock, I now also is such, don't know your last is how to solve
  •  Tags:  
  • C#
  • Related