vb.net Aspose.OCR - 从Image中提取文本

时间:2012-08-22 17:38:16

标签: vb.net winforms bitmap aspose

我试图通过Aspose.OCR从图片中提取文字,
我的代码:

Const resourceFileName As String = "c:\2011.08.05 v1.1 Aspose.OCR.Resouces.zip"
        Dim uploadedImage As String = "c:\ConvertMeToText.bmp"
        Try
            'Create OcrEngine instance and assign 
            'image, language and image configuration
            Dim ocr As New OcrEngine()
            ocr.Image = ImageStream.FromFile(uploadedImage)

            ocr.Languages.AddLanguage(Language.Load("english"))
            ocr.Config.NeedRotationCorrection = True
            ocr.Config.UseDefaultDictionaries = True
            Dim fileStream As New FileStream(resourceFileName, FileMode.Open)
            ocr.Resource = fileStream
            Try
                If ocr.Process() Then
                    TextBox1.Text = ocr.Text.ToString()
                End If
            Catch ex As Exception
                MsgBox("Exception: " & ex.Message)
            End Try
            fileStream.Close()
            ocr = Nothing
        Catch ex As Exception
           MsgBox("Exception: " & ex.Message)
        End Try


例外:      ZipEntry :: ReadHeader():位置0x00000000

处的错误签名(0x00000100)

1 个答案:

答案 0 :(得分:1)

我的名字是Nayyer,我是Aspose的支持开发人员/技术推广人员。

从异常开始,Aspose.OCR版本和资源文件版本看起来有些不同。每个Aspose.OCR版本都使用一个单独的resources.zip文件,如果您尝试使用Aspose.OCR v1.0.0和2011.08.05 v1.1 Aspose.OCR.Resouces.zip,那么您可能会遇到类似的异常。您可以尝试使用最新版本的Aspose.OCR v.1.1.0,其兼容资源文件可通过this link获取。