我計劃在我的項目中使用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