-3

Let me explain the task by an example,

There is an image named demo1.jpeg and it has a whole article written on it. It's not handwritten. It's digital.

What I want is to find the location of a specific word on that image. Like x,y coordinates of a text on it.

For example, If I were to find each and every occurrence of the word "awesome" on it, I should get an array of all occurrence of that word.

Any suggestion with a demo would be dearly appreciated.

Thanks.

ChiragMS
  • 495
  • 5
  • 12
  • This looks like a duplicate of https://stackoverflow.com/questions/10947399/how-to-implement-and-do-ocr-in-a-c-sharp-project – Kai Nov 16 '19 at 05:27
  • @Kai There is no requirement on that question to find a location of the occurrence. I'm not asking for a simple OCR processing on an image. – ChiragMS Nov 16 '19 at 05:33

1 Answers1

2

I'm using Tesseract for solving this. It can be very helpful. Here is an example

 PageIteratorLevel myLevel = PageIteratorLevel.Word;
        TesseractEngine engine = new TesseractEngine("./tessdata", "eng");
        var page = engine.Process(bitmap, PageSegMode.Auto);
        using (var iter = page.GetIterator())
        {
            iter.Begin();
            do
            {
                if (iter.TryGetBoundingBox(myLevel, out var rect))
                {
                    var curText = iter.GetText(myLevel);
                    if (curText == "awesome") //Here is your text
                    {
                        //Get rect.X1, rect.Y1, 
                    }
                }
            } while (iter.Next(myLevel));
        }

I hope this help you

Dilshod K
  • 2,924
  • 1
  • 13
  • 46
  • This might work. Im gonna create a demo from this. I'll mark it as an answer afterwards. Thanks. Really appreciate it. – ChiragMS Nov 16 '19 at 09:55
  • @Dllshod This worked fine but looks like its tesseract is not returning an accurate result. For example if I take a screenshot of this screen (stackoverflow), Tesseract wont return accurate result of the text that is visible on my screen right now. Can you help me how to improve the accuracy for this? – ChiragMS Nov 18 '19 at 08:24