使用ASP.NET C#将OCR映像转换为文本 [英] OCR image to text using ASP.NET C#

查看:77
本文介绍了使用ASP.NET C#将OCR映像转换为文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

An exception of type 'System.Runtime.InteropServices.COMException' occurred in App_Web_w2y32yvw.dll but was not handled in user code

Additional information: Retrieving the COM class factory for component with CLSID {40942A6C-1520-4132-BDF8-BDC1F71F547B} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).





我尝试了什么:





What I have tried:

protected void save_Click(object sender, EventArgs e)
    {
        string filePath = Server.MapPath("~/Uploads/" + Path.GetFileName(FileUpload1.PostedFile.FileName));
        FileUpload1.SaveAs(filePath);
        string extractText = this.ExtractTextFromImage(filePath);
        lblText.Text = extractText.Replace(Environment.NewLine, "<br>");
    }

    private string ExtractTextFromImage(string filePath)
    {
        Document modiDocument = new Document();
        modiDocument.Create(filePath);
        modiDocument.OCR(MiLANGUAGES.miLANG_ENGLISH);
        MODI.Image modiImage = (modiDocument.Images[0] as MODI.Image);
        string extractedText = modiImage.Layout.Text;
        modiDocument.Close();
        return extractedText;
    }

推荐答案

未注册课程的哪一部分难以理解?错误告诉您,您尝试创建实例的COM类在计算机上不存在。



为了使此代码能够为您服务必须在Web服务器上安装Office。



另外,请记住,MODI在Web应用程序中不能很好地工作。
What part of "Class not registered" is hard to understand? The error is telling you that the COM class you're trying to create an instance of doesn't exist on the machine.

In order for this code to work you have to install Office on the web server.

Also, keep in mind that MODI doesn't work very well in a web application.

这篇关于使用ASP.NET C#将OCR映像转换为文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆