Question

How can I use OpenCV to detect all the text in an image, I want to to be able to detect "blocks" of texts individually. Then pass the the recognized blocks into tesseract. Here is an example, if I were to scan this I would want to scan the paragraphs separately, not go from left to right which is what tesseract does.

Image of the example

Was it helpful?

Solution

That would be my first test:

  • Threshold the image to get a black and white image, with the text in black
  • Erode it until the paragraph converts to a big blob. It may have lots of holes, it doesn't matter.
  • Find contours and the bounding box

If some paragraphs merge, you should erode less or dilate a little bit after the erode.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top