OCR running error ....SOS !!!!!!!!!!!!!!!!!!!!
昨天加班到晚上11点也没搞定,急死了。。。
开发环境 Win7 + Office2007 + VisualStudio2008
其中 Office2007 已安装 MODI 组件,并且打过修复补丁,从 “Office工具” 中运行 Microsoft Office Document Imaging 识别 tif 图片中的汉字一切正常。
然后我在代码中引用了 MODI 对象进行图像文字识别,结果每次运行到 MODI.OCR(MODI.MiLANGUAGES.miLANG_CHINESE_TRADITIONAL , false , false); 就会报错: OCR running error...
百度谷歌了很多方法都没解决,比如修改计算机高级设置里的程序数据保护;还有说什么截图尺寸导致这个错误,我自己试验无论尺寸大小均会报此错误。
下面是报错代码
- C# code
private void btnTest_Click(object sender , EventArgs e){ MODI.Document md = new MODI.Document(); // The Create method grabs the picture from disk snd prepares for OCR.Create string strFileName = Environment.CurrentDirectory + "\\temp484.tif"; md.Create(strFileName); // Do the OCR [color=#FF0000][b]//断点跟踪到这里报错 md.OCR(MODI.MiLANGUAGES.miLANG_CHINESE_TRADITIONAL , false , false);[/b][/color] //lx120715 // This string will contain the text. string strText = String.Empty; // Get the first (and only image) MODI.Image image = (MODI.Image) md.Images[0]; // Get the layout MODI.Layout layout = image.Layout; // Loop through the words. for (int j = 0 ; j < layout.Words.Count ; j++) { // Get this word. MODI.Word word = (MODI.Word) layout.Words[j]; // Add a blank space to separate words. if (strText.Length > 0) { strText += " "; } // Add the word. strText += word.Text; } // Close the MODI.Document object. md.Close(false); // Create the dialog that displays // the OCRed text. ShowText st = new ShowText(); // The the dialog's text. st.m_strOCRText = strText; // Show the dialog. st.ShowDialog();}
[解决办法]
LZ 不错!