验证码ORC

调用微软的Microsoft Office Document Imaging的类库

源代码如下:

public MODI.Document _MODIDocument;
private void SetImage(string filename)
{

// Bitmap nump = new Bitmap();
// Bitmap myBitmap1 = new Bitmap(new fa;
// set the image..
try
{
_MODIDocument = new MODI.Document();
_MODIDocument.Create(filename);
//axMiDocView1.Document = _MODIDocument;
//axMiDocView1.Refresh();
}
catch (System.Runtime.InteropServices.COMException ee)
{
MessageBox.Show(ee.Message);
}
}

public string Analyse()
{
string texts = "";
if (_MODIDocument == null) return texts;
try
{
// add event handler for progress visualisation
//_MODIDocument.OnOCRProgress += new MODI._IDocumentEvents_OnOCRProgressEventHandler(this.ShowProgress);

// the MODI call for OCR
// _MODIDocument.OCR(_MODIParameters.Language,_MODIParameters.WithAutoRotation,_MODIParameters.WithStraightenImage);
_MODIDocument.OCR(MODI.MiLANGUAGES.miLANG_CHINESE_SIMPLIFIED, true, true);

//this.textBox1.Text = (_MODIDocument.Images[0] as MODI.Image).Layout.Text;
//MessageBox.Show((_MODIDocument.Images[0] as MODI.Image).Layout.Text);
texts = (_MODIDocument.Images[0] as MODI.Image).Layout.Text;
//statusBar1.Text = "Ready.";

_MODIDocument.Close(false);
_MODIDocument = null;

}
catch (Exception ee)
{
// simple exception "handling"
MessageBox.Show(ee.Message);
}
return texts;
}

 

你可能感兴趣的:(验证码)