我计划在我的项目中使用OCR并搜索更多OCR方法,但我没有找到任何正确的方法。最后我听说了MODI,我试了一下。当在C#中使用Microsoft Office 2013时出现MODI OCR错误
Retrieving the COM class factory for component with CLSID {40942A6C-1520-4132-BDF8-BDC1F71F547B} failed due to the following error: 80040154
我使用Microsoft Office 2013
和visual studio 2012
:但它抛出下面的错误。
我使用的代码如下:
private void button1_Click(object sender, EventArgs e)
{
CheckFileType(@"E:\\");
}
public void CheckFileType(string directoryPath)
{
IEnumerator files = Directory.GetFiles(directoryPath).GetEnumerator();
while (files.MoveNext())
{
//get file extension
string fileExtension = Path.GetExtension(Convert.ToString(files.Current));
//get file name without extenstion
string fileName=Convert.ToString(files.Current).Replace(fileExtension,string.Empty);
//Check for JPG File Format
if (fileExtension == ".jpg" || fileExtension == ".JPG") // or // ImageFormat.Jpeg.ToString()
{
try
{
//OCR Operations ...
MODI.Document md = new MODI.Document();
md.Create(Convert.ToString(files.Current));
md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
MODI.Image image = (MODI.Image)md.Images[0];
//create text file with the same Image file name
FileStream createFile = new FileStream(fileName + ".txt",FileMode.CreateNew);
//save the image text in the text file
StreamWriter writeFile = new StreamWriter(createFile);
writeFile.Write(image.Layout.Text);
writeFile.Close();
}
catch (Exception)
{
MessageBox.Show("This Image hasn't a text or has a problem",
"OCR Notifications",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
谁能帮我在这?是基于Microsoft Office版本的问题还是我需要进行任何更改?这是更好的OCR DLL吗? 谢谢..
感谢,但这个问题取决于我的视觉工作室和操作系统的版本。它在Visual Studio 2008中工作得很好,但在vs2012中我们必须做出一些改变 – yasmuru
嗨xpertgun,你能写出我想在vs2012中做什么改变吗? 我也有同样的问题。 – m2pathan