VB调用微软Modi组件实现OCR功能


Option Explicit
'OCR的主要功能
Private Function OCRImageFile(ByVal strName As String) As Boolean
    Dim modiDocument As New MODI.Document
    Dim modiImages As New MODI.Images
    Dim modiImage As New MODI.Image
    Dim modiLayout As New MODI.Layout
    Dim ImageCount As Integer
   
    Dim i As Integer
   
    modiDocument.OCR miLANG_CHINESE_SIMPLIFIED, False, False
    Set modiImage = modiDocument.Images
   
    For i = 0 To ImageCount
        Set modiImage = modiImages.Item(i)
        Set modiLayout = modiImage.Layout
        Text1.Text = modiLayout.Text
    Next i
   
    modiDocument.Close False: Set modiDocument = Nothing
   
    If ImageCount > 0 Then
        OCRImageFile = True
    Else
        OCRImageFile = False
    End If
End Function

你可能感兴趣的:(VB调用微软Modi组件实现OCR功能)