⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmmain.frm

📁 人工智能OCR文字识别程序非常好的一个序,研究ocr的可以
💻 FRM
📖 第 1 页 / 共 3 页
字号:
                
                arrTagData(i - 1) = ""
                arrRawData(i - 1) = ""
   
            Else
            
                strbuttonRecognised = ""
                intMaxMatch = 0
                intCounter = 0
                c = 0
                
                Open Filename_Database For Input As #1
                While Not EOF(1)
buttonRecognise_SkipLine:
                a = 190
                b = 190
                d = 0
                intMatch = 0
                Me.AppTemplateArea.Cls
                    If EOF(1) Then
                        GoTo buttonRecognise_FileClose
                    End If
                    Input #1, arrRawData(c)
                    If Len(arrRawData(c)) < 102 Then
                        GoTo buttonRecognise_SkipLine
                    End If
                    arrTagData(c) = Mid(arrRawData(c), 1, 1)
                    arrRawData(c) = Mid(arrRawData(c), 3)
        '            Debug.Print arrRawData(c)
                    
                    For i = 1 To 10
                    For j = 1 To 10
                        If Mid(arrRawData(c), d + 1, 1) = vbBlack Then
        '                    userTemplateArea.PSet (i, j)
                            AppTemplateArea.PSet (a, b)
        '                    userTemplateArea.Circle (a, b), 110
        '                    AppTemplateArea.Line (a - 110, b - 110)-(a + 110, b - 110)
        '                    AppTemplateArea.Line (a + 110, b - 110)-(a + 110, b + 110)
        '                    AppTemplateArea.Line (a + 110, b + 110)-(a - 110, b + 110)
        '                    AppTemplateArea.Line (a - 110, b + 110)-(a - 110, b - 110)
        '                    Debug.Print ""
                            If Mid(strData, d + 1, 1) = vbBlack Then
                                intMatch = intMatch + 1
                            Else
                                intMatch = intMatch - 1
                            End If
                        Else
                            If Mid(strData, d + 1, 1) <> vbBlack Then
                                intMatch = intMatch + 1
                            Else
                                intMatch = intMatch - 1
                            End If
                        End If
                        d = d + 1
                        b = b + (Me.AppTemplateArea.Height - 200) / 10
                    Next j
                    b = 190
                    a = a + (Me.AppTemplateArea.Width - 200) / 10
                    Next i
                    If intMaxMatch < intMatch Then
                        intMaxMatch = intMatch
                        strbuttonRecognised = arrTagData(c)
                        intCounter = c
                        Me.progressRecognition.Value = intMaxMatch
                        If intMaxMatch > 90 Then
                            GoTo buttonRecognise_FileClose
                        End If
                    End If
                    c = c + 1
                Wend
buttonRecognise_FileClose:
                Close #1
            End If
    End If
    
    Me.buttonRecognise.Enabled = False
    Me.progressRecognition.Value = 0
    
    If strbuttonRecognised <> "" Then
        AppTemplateArea.Cls
        
        With AppTemplateArea
        .ForeColor = vbWhite
        
        End With
        
        
        a = 190
        b = 190
        d = 0
        For i = 1 To 10
        For j = 1 To 10
            If Mid(arrRawData(intCounter), d + 1, 1) = vbBlack Then
                AppTemplateArea.PSet (a, b)
                AppTemplateArea.Line (a - 110, b - 110)-(a + 110, b - 110)
                AppTemplateArea.Line (a + 110, b - 110)-(a + 110, b + 110)
                AppTemplateArea.Line (a + 110, b + 110)-(a - 110, b + 110)
                AppTemplateArea.Line (a - 110, b + 110)-(a - 110, b - 110)
            End If
            d = d + 1
            b = b + (Me.AppTemplateArea.Height - 200) / 10
        Next j
        b = 190
        a = a + (Me.AppTemplateArea.Width - 200) / 10
        Next i
    End If
    
    If strbuttonRecognised <> "" Then
        'The highest posible of drawn character is buttonRecognised as   'X'
        Me.textResult.Caption = intMaxMatch & "% Match with character '" & strbuttonRecognised & "'"
        Me.textResult.ToolTipText = intMaxMatch & "%"
        '& " , " & intMaxMatch & "%"
        
        Me.DrawWidth = 2
        
  
    End If
    

End Sub

Private Sub buttonLearn_Click()

    Me.TeachLabelText.FontBold = False
    Me.TeachLabelText.Caption = "Enter a character to be buttonLearn"
    
    
    Me.buttonLearn.Visible = False
    Me.buttonRecognise.Visible = False
    Me.buttonClearScreen.Visible = False
  
    
    Me.buttonLearnConfirm.Visible = True
    Me.buttonLearnCancel.Visible = True
    Me.inputLearnCharacter.Visible = True

    Me.inputLearnCharacter.Text = ""
    Me.inputLearnCharacter.SetFocus
    Me.buttonLearnConfirm.Enabled = False
    
End Sub

Private Sub GraspRawData()
Dim bool1stScan As Boolean
Dim ax As Integer
Dim ay As Integer
Dim bx As Integer
Dim by As Integer

bool1stScan = True
strData = ""

c = 0

Me.userTemplateArea.Cls
For i = 1 To userDrawArea.Width Step 100
    For j = 1 To userDrawArea.Height Step 100
        If userDrawArea.Point(i, j) = vbBlack Then
            userTemplateArea.PSet (i, j)
            If Not bool1stScan Then
                If i < ax Then
                    ax = i
                    End If
                If i > bx Then
                    bx = i
                    End If
                If j < ay Then
                    ay = j
                    End If
                If j > by Then
                    by = j
                    End If
            Else
                bool1stScan = False
                ax = i
                bx = i
                ay = j
                by = j
            End If
        End If
Next j, i

'MsgBox ""

If bx - ax <> 0 And by - ay <> 0 Then

    a = 190
    b = 190
    
    Me.userTemplateArea.Cls
    For i = ax To bx - (bx - ax) / 10 Step (bx - ax) / 10
        For j = ay To by - (by - ay) / 10 Step (by - ay) / 10
            If userDrawArea.Point(i, j) = vbBlack Then
                userTemplateArea.PSet (a, b)
    '''            userTemplateArea.Circle (a, b), 110
                userTemplateArea.Line (a - 110, b - 110)-(a + 110, b - 110)
                userTemplateArea.Line (a + 110, b - 110)-(a + 110, b + 110)
                userTemplateArea.Line (a + 110, b + 110)-(a - 110, b + 110)
                userTemplateArea.Line (a - 110, b + 110)-(a - 110, b - 110)
    '                    userTemplateArea.FillStyle = vbSolid
    '                    userTemplateArea.FillColor = vbBlack
    '                    userTemplateArea.fil
    '            RawData(c) = userDrawArea.Point(i, j)
                strData = strData & userDrawArea.Point(i, j)
                c = c + 1
            Else
    '            RawData(c) = 1
                strData = strData & 1
                c = c + 1
            End If
            b = b + (Me.userTemplateArea.Height - 200) / 10
        Next j
        b = 190
        a = a + (Me.userTemplateArea.Width - 200) / 10
    Next i

End If

End Sub


Private Sub inputLearnCharacter_GotFocus()
    Me.inputLearnCharacter.SelStart = 0
    Me.inputLearnCharacter.SelLength = Len(Me.inputLearnCharacter.Text)
End Sub

Private Sub inputLearnCharacter_KeyUp(KeyCode As Integer, Shift As Integer)
    
    If Len(Me.inputLearnCharacter.Text) = 1 Then
        Me.buttonLearnConfirm.Enabled = True
        Me.buttonLearnConfirm.SetFocus
    ElseIf Len(Me.inputLearnCharacter.Text) > 1 Then
        Me.inputLearnCharacter.Text = ""
        Me.buttonLearnConfirm.Enabled = False
    Else
        Me.buttonLearnConfirm.Enabled = False
    End If
    
End Sub

Private Function StatusWindow(Optional ByVal strBuffer As String) As String
Dim Status_OpenButton As String
Dim Status_buttonLearnButton As String
Dim Status_buttonLearnConfirmButton As String
Dim Status_buttonLearnCancelButton As String
Dim Status_buttonRecogniseButton As String
Dim Status_buttonClearScreenButton As String
Dim Status_ExitButton As String
Dim Status_DrawArea As String
Dim Status_DatabaseArea As String
Dim Status_DataArea As String
Dim Status_Form As String
    
    Status_OpenButton = "Tips && Help : Open File - Just click the Open button to open FILE then type in your FILENAME - Try it..."
    Status_buttonLearnButton = "Tips && Help : buttonLearn - Just click the buttonLearn button to buttonLearn then type in your buttonLearn CHARACTER - Try it..."
    Status_buttonLearnConfirmButton = "Tips && Help : Confirm the character ENTER in the textbox is match with the drawn character in the Draw Area."
    Status_buttonLearnCancelButton = "Tips && Help : Mispressed or Give up or Do not want to buttonLearn."
    Status_buttonRecogniseButton = "Tips && Help : buttonRecognise Text - Just click the this button to buttonRecognise drawn character then the buttonRecognised character will display at the BOTTOM. Try it..."
    Status_buttonClearScreenButton = "Tips && Help : Clear Screen - Just click the this button to CLEAR screen then continue to draw character. Try it..."
    Status_ExitButton = "Tips && Help : Exit this software."
    Status_DrawArea = "Tips && Help : Your mouse pointer is in the Draw Area, just Click and drag to draw a character..."
    Status_DatabaseArea = "Tips && Help : This is Database Area, which it will display a buttonRecognised character from the database when you click buttonRecognise Button."
    Status_DataArea = "Tips && Help : This Data Area act as a buffer storage of Draw Area when user draw in Draw Area or to retrieve database data when user click Open Button."
    Status_Form = "Tips && Help : Thanks for using this software. Just move the mouse to the Draw Area, then drag the mouse when you want to draw a character to be buttonRecognised. Nice Try ..."
    
    Select Case strBuffer
    Case "OpenButton": strBuffer = Status_OpenButton
    Case "buttonLearnButton": strBuffer = Status_buttonLearnButton
    Case "buttonLearnConfirmButton": strBuffer = Status_buttonLearnConfirmButton
    Case "buttonLearnCancelButton": strBuffer = Status_buttonLearnCancelButton
    Case "buttonRecogniseButton": strBuffer = Status_buttonRecogniseButton
    Case "buttonClearScreenButton": strBuffer = Status_buttonClearScreenButton
    Case "ExitButton": strBuffer = Status_ExitButton
    Case "DrawArea": strBuffer = Status_DrawArea
    Case "DatabaseArea": strBuffer = Status_DatabaseArea
    Case "DataArea": strBuffer = Status_DataArea
    Case "Form": strBuffer = Status_Form
    End Select
    
    StatusWindow = strBuffer

End Function

Private Function BinToDec(strBin As String) As Integer

i = Len(strBin)
While i > 0
    If Mid(strBin, i, 1) = "1" Then
        BinToDec = BinToDec + 2 ^ (Len(strBin) - i)
    End If
    i = i - 1
Wend

End Function

Private Function DecToBin(intDec As Integer, intDigit As Integer) As String
Dim intTemp As Integer

While intDec > 0 And intDigit > 0
    intDigit = intDigit - 1
    intTemp = intDec Mod 2
    If intTemp Then
        DecToBin = "1" & DecToBin
        intDec = (intDec - 1) / 2
    Else
        DecToBin = "0" & DecToBin
        intDec = intDec / 2
    End If
Wend

While intDigit
    intDigit = intDigit - 1
    DecToBin = "0" & DecToBin
Wend

End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -