read text from image file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • veer
    New Member
    • Jul 2007
    • 198

    read text from image file

    Hello expert.
    I want to make a program in VB in which I have an image file i,e jpg, tif etc.
    How can I open this image file and read the text and generate a text file?
    If there is any idea then please send me.

    Thanks in advance.
    Last edited by Killer42; Dec 29 '07, 02:07 PM.
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    How the image file contains text?

    Still then if you want to open then use in a richtextbox. Using that control you can open any type of file even dll and exe also.
    Last edited by Killer42; Dec 29 '07, 02:07 PM.

    Comment

    • SammyB
      Recognized Expert Contributor
      • Mar 2007
      • 807

      #3
      Originally posted by veer
      hello expert
      i want to make programe in vb in which i have an image file i,e jpg, tif etc
      how i can open this image file and read the text and generate a text file .
      if there is any idea then please send me

      thaks in advance
      If you are trying to create a program like OmniPage, you have an enormous task. The characters that you see in an image file are just composed of dots called pixels, there are no ascii characters. Plus, image file formats are pretty tough. HTH --Sam

      Comment

      • veer
        New Member
        • Jul 2007
        • 198

        #4
        hello expert
        i got this code from internet searching but when i execute this code it shows the error that the "aspriseOCR.dll " file was not found but when i have no idea about how the dll file for this code is create please help me by providing some code for the following functions so that if does not show the above error
        ............... ............... ............... ............... ............... ............... ............... ..
        [CODE=VB]
        Option Explicit
        Private Declare Function OCR Lib "AspriseOCR.dll " (ByVal file As String, ByVal imageType As Long) As String
        Private Declare Function OCRBarCodes Lib "AspriseOCR.dll " (ByVal file As String, ByVal imageType As Long) As String
        Private Declare Function OCRpart Lib "AspriseOCR.dll " (ByVal file As String, ByVal imageType As Long, ByVal startX As Long, ByVal startY As Long, ByVal width As Long, ByVal height As Long) As String

        Private Sub Check1_Click()
        If Check1.Value = Checked Then
        Command4.Enable d = True
        Else
        Command4.Enable d = False
        End If
        End Sub

        Private Sub Command1_Click( )
        Dim fnum As Integer

        On Error Resume Next
        dlgOpenFile.Sho wOpen
        If Err.Number = cdlCancel Then
        ' The user canceled.
        Exit Sub
        ElseIf Err.Number <> 0 Then
        ' Unknown error.
        MsgBox "Error " & Format$(Err.Num ber) & _
        " selecting file." & vbCrLf & _
        Err.Description
        Exit Sub
        End If
        On Error GoTo 0

        ' Read the file.
        'fnum = FreeFile
        'Open dlgOpenFile.Fil eName For Input As #fnum
        'text.text = Input$(LOF(fnum ), fnum)
        'Close #fnum

        textPath.text = dlgOpenFile.Fil eNameEnd Sub

        Private Sub Command2_Click( )
        Dim ret As String
        ret = OCR(textPath.te xt, -1)
        text.text = ret
        End Sub

        Private Sub Command3_Click( )
        Dim ret As String
        ret = OCRBarCodes(tex tPath.text, -1)
        text.text = ret
        End Sub

        Private Sub Command4_Click( )
        Dim ret As String
        ret = OCRpart(textPat h.text, -1, CLng(X.text), CLng(Y.text), CLng(W.text), CLng(H.text))
        text.text = ret
        End Sub

        Private Sub Command5_Click( )
        End
        End Sub

        Private Sub Form_Load()
        dlgOpenFile.Ini tDir = App.Path
        dlgOpenFile.Dia logTitle = "Open File"
        dlgOpenFile.Fla gs = _
        cdlOFNFileMustE xist + _
        cdlOFNHideReadO nly + _
        cdlOFNLongNames + _
        cdlOFNExplorer
        dlgOpenFile.Can celError = True
        Command4.Enable d = False
        End Sub[/CODE]

        ............... ............... ............... ........
        Originally posted by SammyB
        If you are trying to create a program like OmniPage, you have an enormous task. The characters that you see in an image file are just composed of dots called pixels, there are no ascii characters. Plus, image file formats are pretty tough. HTH --Sam
        Last edited by debasisdas; Dec 24 '07, 05:49 AM. Reason: Formatted using code tags

        Comment

        • debasisdas
          Recognized Expert Expert
          • Dec 2006
          • 8119

          #5
          The referenced AspriseOCR.dll is not part of VB 6.0 . that is some thirdparty file. You need to have that file in your system to use that.

          Comment

          • veer
            New Member
            • Jul 2007
            • 198

            #6
            hello expert
            i download this file with the code but it is not working with programe
            where i will save this file or can i create my own dll file for this code if yes
            then give some tips about it

            thanks

            Originally posted by debasisdas
            The referenced AspriseOCR.dll is not part of VB 6.0 . that is some thirdparty file. You need to have that file in your system to use that.

            Comment

            • debasisdas
              Recognized Expert Expert
              • Dec 2006
              • 8119

              #7
              1.copy the file to SYSTEM32 folder
              2.register the dll with windows using REGSVR32 key.

              then try to use the control.

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                For a Declare statement, I don't think you need to register the DLL. I would recommend copying it into the same directory as your program first, to try it out. But make sure you start VB in that directory, so it is the current one.

                Comment

                • VACEPROGRAMER
                  Banned
                  New Member
                  • Nov 2007
                  • 167

                  #9
                  You are crazy!
                  Try to make a DLL and save in the same folder where VB is installed or just
                  browse from the VB.

                  VACE
                  Last edited by Killer42; Dec 31 '07, 12:03 AM.

                  Comment

                  • Killer42
                    Recognized Expert Expert
                    • Oct 2006
                    • 8429

                    #10
                    Originally posted by VACEPROGRAMER
                    You are crazy!
                    Try to make a DLL ...
                    Um... which of us are you responding to, VACEPROGRAMER?

                    Comment

                    • VACEPROGRAMER
                      Banned
                      New Member
                      • Nov 2007
                      • 167

                      #11
                      I'm reponding to veer!!
                      VACE

                      Comment

                      • veer
                        New Member
                        • Jul 2007
                        • 198

                        #12
                        please responding me about my question

                        Originally posted by VACEPROGRAMER
                        I'm reponding to veer!!
                        VACE

                        Comment

                        • Killer42
                          Recognized Expert Expert
                          • Oct 2006
                          • 8429

                          #13
                          I thought we were waiting on more detail of the latest problem. "Not working" doesn't really tell us very much.

                          Comment

                          Working...