dcsimg
Results 1 to 35 of 35

Thread: Optical Character Recognition

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    9

    Question Optical Character Recognition

    Hello, everyone, I'm working on the task to create a character recognition application.
    I use zhang Suen algorithm, does anyone know that algorithm??
    if anyone know, please let me know the workings of the algorithm and how these algorithms transform into coding??
    help me please...

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,057

    Re: Optical Character Recognition

    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    9

    Re: Optical Character Recognition

    oh,thank you very much Bonnie West..
    i'll try this.

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    9

    Re: Optical Character Recognition

    help me again please.
    I have made zhang Suen algorithm running and I can change the image to black and white.
    I want to display the results of OCR text in a text box.
    does anyone know how to display the text of the input image??

    here is my project :
    project

  5. #5
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,057

    Re: Optical Character Recognition

    Quote Originally Posted by eijdaites View Post
    does anyone know how to display the text of the input image??
    If you had searched this forum first, you might have come across this recent thread.

    Quote Originally Posted by eijdaites View Post
    here is my project :
    Whenever possible, please attach your project in your post rather than forcing us to download it from another site.

    Anyway, most of the JPG images that you have are too blurry. I doubt they can be successfully converted by any decent OCR software.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  6. #6

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    9

    Re: Optical Character Recognition

    I have uploaded my project in me*****re, therefore I've included the link.
    I would like to make their own OCR software not to compare with existing software.

    I just need to do the pattern recognition of letters and took it into the text box.

    anyway thanks for your suggestion.

  7. #7
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,057

    Re: Optical Character Recognition

    Quote Originally Posted by eijdaites View Post
    I have uploaded my project in me*****re, therefore I've included the link.
    What I meant was, instead of telling us to download your project from an external site, you can save us some time if your project was directly attached to your post. See this post for an attachment example. You can attach your project by clicking the Go Advanced button and then click the Manage Attachments button.

    Quote Originally Posted by eijdaites View Post
    I would like to make their own OCR software not to compare with existing software.

    I just need to do the pattern recognition of letters and took it into the text box.
    Just so you know, Optical Character Recognition means pixels in an image are analyzed for patterns that resembles characters/letters/numbers/symbols/etc. You can probably imagine that such a task isn't easy at all to program. That's why there aren't any 100% fool-proof OCR software yet. The last thread I linked to was the best I could find, so if that wasn't good enough for you, well then, good luck with your search!
    Last edited by Bonnie West; Jul 14th, 2013 at 07:16 AM.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  8. #8
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Optical Character Recognition

    If your going to create your own good luck it won't be an easy task. I'm sure it took them years to make good OCR (thats probably 100's of programmers together). Bonnie was just trying to give you a quick way out of your problem. And also, we don't like to open other sites, that's why there is a way to attach in this forum, why use another site? It's a lot more simple to use one site (this one). Also even if you do create an OCR, how many different kind of fonts is out there, new ones everyday probably. Also people handwritting, captcha, it's a hard task to do. Good luck with your project! I guess you could try to make one for only one type of font, which would be lame

  9. #9

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    9

    Re: Optical Character Recognition

    ok
    I apologize for the issues that link I gave

    for the application, I want to make a very simple OCR application.
    applications can only read one type of font and just read the characters A - Z, a - z, 0-9.

  10. #10
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Optical Character Recognition

    Eijdaites

    Well, that seems reasonable.
    What will the "image" be?
    ,, BMP file?
    ,, JPEG file?
    ,, something else?

    Spoo

  11. #11

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    9

    Re: Optical Character Recognition

    for the picture, I want to bmp and jpeg format.
    Can you help me?

  12. #12
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Optical Character Recognition

    Eijdaites

    Possibly, but if so, only with BMP ... not JPEG.

    The reason is that my approach would involve "reading" the BMP file header
    and parsing the BMP file. The problem with JPEGs is that they are compressed,
    and I do not know how to recover the "lost" compressed data.

    Further, I have no idea what the Zhang Suen algorithm is.

    So, if you need to use JPEG and Zhang Suen, then, sorry, I doubt I can help.
    But, if BMP only is ok and you are willing to try to develop a new algorithm, then possibly .. but it will be complex.

    Spoo

  13. #13

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    9

    Re: Optical Character Recognition

    Okay, I'll make the OCR application and insert an image with bmp format.

    I have made ​​zhang Suen algorithm for thinning the picture, I just need to read the pattern and issued the results

    program that I gave above is wrong, I'll re-attach my program later.

    thank you

  14. #14
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Optical Character Recognition

    I have created a little demo, not for the recognition, but for dividing letters. (a start)

    It will find the first letter of the first picturebox and add it to a second picturebox.
    I did not do for the next letters, but if the text is simple and normal, you could offset from previous character positions (right position) and get next character positions.
    Once you can get the characters one by one you could then do the recognition part. It will be a lot easier to compare 1 letter at a time.

    Here is the little project I made so far, haven't had time to work too much on it. Hopefully it can give you an idea. I will tell you this again, an OCR has a lot more then letter recognition, it has to "try" and divide each letters and then match it with the correct letter (or one that looks like the most '%').
    For the demo project, click Load Picture, then click Find/Copy First Letter and you will see the letter appear in Picture2.

    I'm not sure yet how to compare, I was thinking to save the alphabet (one font only) and then match pixel per pixel to the image being scanned and the one with the highest percentage (the most similar pixels) would be the one my OCR would choose.
    This is far from being a real OCR, I just hope it gives you (or others) an idea of how a very simple OCR works and hopefully they will share their ideas or make another project to share on this Forum!


    Note:
    I did not create code for MonoChrome or GrayScale... came from this link
    http://www.vbforums.com/showthread.p...lack-and-white
    Attached Files Attached Files

  15. #15
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Optical Character Recognition

    Also PSC is a good place to get an idea on how to do anything, even OCR. I haven't look at them yet but here...
    http://www.planetsourcecode.com/vb/s...xtCriteria=ocr

    Some programmers on that website knows a lot more than I do, but their code might be complicated to understand.

  16. #16
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Optical Character Recognition

    Max

    I'm not sure yet how to compare, I was thinking to save the alphabet (one font only) and then match pixel per pixel to the image being scanned and the one with the highest percentage (the most similar pixels) would be the one my OCR would choose.
    Yes, I had very similar thoughts regarding the issue (comparing) and possible
    solution (pixel-by-pixel matching). Seems doable, but will no doubt be a challenge.
    However, once a means can be devised to do the first alphabet letter, the rest
    should fall into place pretty quickly.

    Spoo

  17. #17
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Optical Character Recognition

    I tested everyone of those OCR apps from the link Max posted. Most don't work or don't work very well. A couple are fairly nice and do a decent job but all you need is one to help you get started.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  18. #18
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Optical Character Recognition

    Quote Originally Posted by Spoo View Post
    Max



    Yes, I had very similar thoughts regarding the issue (comparing) and possible
    solution (pixel-by-pixel matching). Seems doable, but will no doubt be a challenge.
    However, once a means can be devised to do the first alphabet letter, the rest
    should fall into place pretty quickly.

    Spoo
    Yeah, I figured it would be hard to do. Since I do not have much time anymore working very long hours, and no access to pc I can't help much anymore or make big projects.
    I think what we have in mind would work spoo, but that will only work on one kind of font! (well maybe more than 1 if they are similar)

    I'll try to figure out how to compare the pixels one of these days, I've always wanted to make an OCR from scratch. I'm not 100% sure on how to implement the comparing yet!
    We should all work together on this one, even if the end product is not excellent, it would give an idea to a lot of people using this forum.

    I think it's a good project to work on, just like jmsrickland's sound wave project!

  19. #19
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Optical Character Recognition

    Quote Originally Posted by jmsrickland View Post
    I tested everyone of those OCR apps from the link Max posted. Most don't work or don't work very well. A couple are fairly nice and do a decent job but all you need is one to help you get started.
    You should post the one that you liked the most, so I don't have to download them all!
    I have so much VB6 crap on my computer and can't get rid of it! Like a VB6 Hoarder.
    Or just let me know which one to download.

  20. #20
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Optical Character Recognition

    I'm going to go back and test them again and I'll upload the ones that have decent output.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  21. #21
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Optical Character Recognition

    Quote Originally Posted by Max187Boucher View Post
    I think what we have in mind would work spoo, but that will only work on one kind of font! (well maybe more than 1 if they are similar)
    That would be a good place to start .. one font only, say Courier.
    Recall that in post #9, the OP is only interested in one font.

    Spoo

  22. #22

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    9

    Re: Optical Character Recognition

    Okay, thank you for all sugestion.

    please give comment on the project.
    I made ​​zhang Suen algorithm to make the process of thining but I do not understand how to call the function that I created.


    here is my project :
    Attached Files Attached Files
    Last edited by eijdaites; Jul 18th, 2013 at 01:17 PM.

  23. #23
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Optical Character Recognition

    Here's one of the apps I downloaded from Max's link.

    I made a few changes to it but did not alter in any way the original scanning code

    It works very nicely but from my testing I found that not all fonts are supported

    Run the project and follow the directions
    Attached Files Attached Files


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  24. #24
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Optical Character Recognition

    Quote Originally Posted by jmsrickland View Post
    Here's one of the apps I downloaded from Max's link.

    I made a few changes to it but did not alter in any way the original scanning code

    It works very nicely but from my testing I found that not all fonts are supported

    Run the project and follow the directions
    Did not work for me, how did you get it to work? See picture below.
    Name:  orc-test.jpg
Views: 816
Size:  49.7 KB

  25. #25
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Optical Character Recognition

    You loaded up "Fixedsys 9.bmp" so after you do that you need to click on Change Font and set the current font to Fixedsys at 9 points.

    If you load the other bitmap file it is called "Courier 12.bmp" you must click on Change Font and set the current font to Courier at 12 points.

    I'm thinking if the name of the font, it's style, and it's size is known ahead of time, like in the image file name or some other way, then the code could be changed to get this info, set picText to this font then you could eliminate the Change Font function
    Last edited by jmsrickland; Jul 18th, 2013 at 10:25 PM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  26. #26
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Optical Character Recognition

    Quote Originally Posted by jmsrickland View Post
    You loaded up "Fixedsys 9.bmp" so after you do that you need to click on Change Font and set the current font to Fixedsys at 9 points.

    If you load the other bitmap file it is called "Courier 12.bmp" you must click on Change Font and set the current font to Courier at 12 points.

    I'm thinking if the name of the font, it's style, and it's size is known ahead of time, like in the image file name or some other way, then the code could be changed to get this info, set picText to this font then you could eliminate the Change Font function
    I tried it again like you said and still does not read it! Are you using windows 7? maybe because of resolution? mine is 1366 * 768 pixel

  27. #27
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Optical Character Recognition

    I'm using XP and screen resolution of 1280 x 720

    By looking at the picture you attached it appears that it loads the image file and displays it in the Picturebox correctly so I don't know why the program is not reading the pixels from that Picturebox and giving you the correct results if you are indeed changing the font to the correct font name, regular style, and the correct point size.

    Go into cmdScan_Click() and put in the code you see below in red. Now run the project again but only click on Scan button, nothing else. This was the original code but I commented it out because I wanted to load different bitmaps with text to test a variety.

    Code:
    Private Sub cmdScan_Click()
     Dim ctl As PictureBox
     Dim lX As Long, lY As Long
     Dim lLine() As Long
     Dim lPower() As Long
     Dim lPicWidth As Long
     Dim lPicHeight As Long
     Dim lvLine As Long
     Dim sReturn As String
     Dim sOutput As String
     Dim lskip As Long
      
     lPower() = fcnGetPower()
      
     Set ctl = picText
    
     With ctl
       .Cls
       .Picture = Nothing
    
       'create the picture with the text
       ctl.Print "...Hello! I just like to know how things work..."
       ctl.Print "abcdefghijklmnopqrstuvwxyz"
       ctl.Print UCase$("abcdefghijklmnopqrstuvwxyz")
       ctl.Print "!@#$%^&*()"
       ctl.Print "1234567890"
       ctl.Refresh
       
       DoEvents
       
       .ScaleMode = vbPixels
      
       'get the values
       lPicWidth = .ScaleWidth - 1
       lPicHeight = .ScaleHeight - 1
      '
      '
      '
      '
    End Sub
    Last edited by jmsrickland; Jul 19th, 2013 at 10:33 PM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  28. #28
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Optical Character Recognition

    It works now, I played around with the font too, some font are better than others, but it does work.

  29. #29
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Optical Character Recognition

    Quote Originally Posted by jmsrickland View Post
    Go into cmdScan_Click() and put in the code you see below in red.
    This is what I get. (Fixedsys 9 works fine, except it looses the spaces between words)
    Attached Images Attached Images  

  30. #30
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Optical Character Recognition

    Fixedsys 9:
    Attached Images Attached Images  

  31. #31
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Optical Character Recognition

    I don't know what you are doing, Max, but it works perfectly for me and it looks like it also works for Doogle.

    I pointed out in my post that it wont support all fonts. I have played around with several fonts and it works great and with other fonts it doesn't. I'm going to do a deeper test on this however so far I know it works with the two bitmaps I included. You can make other bitmaps with text using other fonts and point sizes and see what works the best. But first you got to get this straightened out because you picture you included just isn't what it does with me. My results look exactly like the picture Doogle posted.
    Attached Images Attached Images   
    Last edited by jmsrickland; Jul 20th, 2013 at 12:22 AM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  32. #32
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Optical Character Recognition

    I get same results as Doogle! it works but not at it's best, like you jmsrickland.

    Doogle has the exact same results as me, I tried changing fonts/font size and it gets better or worst depends on the font.

    But the thing is that it works at least, will have to study the code, had a quick look but did not understand it yet.

  33. #33
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Optical Character Recognition

    Did you notice the image I posted? The results are exactly the same as the bitmap as far as spacing between letters and Doogle's had no spacing between the letters. The 2nd image I posted is Courier 12 and it too is exactly the same as the bitmap except no line to line spacing but that's to be expected.

    I have no explanation why you two do not get perfect results like I do.

    I have a suggestion. Make your own bitmaps, instead of using the ones I included, and use them for testing and see what results you get.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  34. #34
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Optical Character Recognition

    I will in a bit (hopefully tonight haha)

  35. #35
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Optical Character Recognition

    Here's another app that's decent enough. It does one character only but it is rather accurate and you can teach it to learn the characters. I did some modifications to it to make it easier to use but I didn't change any of the text recognition logic.
    Attached Files Attached Files


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width