Microsoft Visual Studio 2010做的C#微软MODI从图片识别文字(OCR)实例(需要引用Microsoft Office Document Imaging 12.0 Type Library Com组件),主要代码:
try
{
MODI.Document doc = new MODI.Document();
doc.Create(sAbsFile);
MODI.Image image;
MODI.Layout layout;
switch (iLanguageMode)
{
case 0:
doc.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
break;
case 1:
doc.OCR(MODI.MiLANGUAGES.miLANG_CHINESE_SIMPLIFIED, true, true);
break;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < doc.Images.Count; i++)
{
image = (MODI.Image)doc.Images[i];
layout = image.Layout;
sb.Append(layout.Text);
}
return sb.ToString();
}
catch (Exception ex)
{
return "【Error】" + ex.Message.ToString();
}
2019-12-21 20:59:03
57KB
VS2010
1