how can I do optical character recognition using processing?

plz guide me on this.

Tagged:

Answers

  • edited October 11

    https://en.wikipedia.org/wiki/Optical_character_recognition

    "[OCR is the] conversion of images of [...] text into machine-encoded text."

    Essentially, you want to start with an image that has some text in it, and work out what that text is. So the first thing you need is an image with some text in it.

    Processing can be used to generate such an image. So let's start with a sketch that does that:

    void setup(){
      size(200,200);
    }
    
    void draw(){
      background( random(255), random(255), random(255) );
      fill( random(255), random(255), random(255) );
      int ts = int(random(10,64));
      textSize(ts);
      String t = "" + char(int(random('A','Z'+1)));
      text( t, random(20,width-20-textWidth(t)),random(20+ts/2,height-20-ts/2) );
      noLoop();
    }
    
    void mousePressed(){
      redraw();
    }
    

    If you run this, you will see that it generates a 200x200 pixel image that has a solid random background color and a single random capital letter of a random color somewhere in the frame. Since you are a person, you can look at the image and determine what the letter is easily (assuming the letter's color is different enough from the background). Chances are good that you have a lot of practice determining what letters are. Heck, you're doing it right now because you are reading this!

    Your task is to teach a computer to do it.

    There are many different approaches you can take to go about this (see the wiki page!). And, quite frankly, your question is so broad that you haven't even mentioned what methods you want to try to use. So tell us more. What is your approach going to be? Are you going to just implement a classical method, or do you have a crazy new tactic in mind?

  • edited October 11

    There is not a standard OCR library for Processing. You would need to find a Java OCR library and import it. For example, tesseract may have Java bindings.

    Old discussion: https://forum.processing.org/two/discussion/922/good-ocr-libraries

  • See, look, your question is so vague that I took it to mean you want to write the code to do it, and jeremydouglass took it to mean that you just want to be able to do it. So you need to give us some DETAILS.

  • I want to implement it using KNN algorithm....

  • @priyabratabasu -- re: "I want to implement it"

    it = what?

    not enough information....

  • @Chrisir --

    Yes, I know what KNN is, but to do what? Analyze handwriting samples through a laptop webcam? Process a directory of jpegs of textbook pages? Should the output be a stream of recognized letters, recognized words, or an identifier like "this font is Baskerville" or "this was probably written by Sally"...? If it is a character stream, do you want spatial maps of the locations / orientations of the letters?

    If you want to "do OCR," then I would expect that you are processing either a webcam or an image stack, and want to produce a character stream from standard text documents in which text in a single font size is all oriented one way. Of course, you could be trying to do car license plate detection. There is Not. Enough. Information.

Sign In or Register to comment.