|
- Sub ll()
- Dim ModiDocument As MODI.Document
- Dim ModiImages As New MODI.Images
- Dim ModiImage As New MODI.Image
- Dim ModiLayout As New MODI.Layout
- Dim ImageCount As Integer
- Set ModiDocument = New MODI.Document
- Debug.Print ModiDocument.Images.Item(1)
- Stop
- <font size="3" color="#ff0000"> ModiDocument.OCR miLANG_CHINESE_SIMPLIFIED, False, False</font>
-
-
- End Sub
复制代码
想使用微软的OCR,没有成功.
- ''===================== 程序2
- 'Option Explicit
- '
- '利用微软OCR控件, 只需要不到10行代码就能够实现自已的OCR文字识别软件.
- '1. 添加控件,需要安装office2003, 没有安装office2003的可以从别人机子上拷贝相关文件,注册regsvr32.exe mdivwctl.dll,
- '控件一般在这个目录下:C:\Program Files\Common Files\Microsoft Shared\MODI.0, 只需要相关的几个文件就可以了, 此文件夹全部文件大概在21M左右.
- '2.工程->部件->添加这个控件:Microsoft Office Document Imaging 11.0 Type Library
- '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
- Dim Mm As New MODI.Document
- Mm.OCR miLANG_CHINESE_SIMPLIFIED, False, False
- Stop
- 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
- Private Sub tmpCommand1_Click()
- Dim bolP As Boolean
-
-
- bolP = OCRImageFile("F:\1.bmp")
- bolP = OCRImageFile("F:\6.jpg")
- End Sub
复制代码
|
|