My question follows this post about extracting data from a table in an image using OCR.
I'm using tesseract
to convert a table image to text. This works well except that the format of the table is not preserved. One solution is to replace the columns with some letters tesseract
would recognize and fool it into taking the table just as some text.
Here is an example of a table without columns
I use the following code to draw the columns of "QQ"
im=Image.open("file.png")
draw = ImageDraw.Draw(im)
font=ImageFont.truetype("/usr/share/fonts/gnu-free/FreeSerifBold.ttf",12)
by = font.getsize("S")[1]
col = [240,480]
px = []
for y in range(0,im.size[1],by):
for x in col:
draw.text((x,y),"QQ",font=font,fill=0)
im.save("res-file.png")
im.show()
which give me the following image
The problem is that tesseract does even recognize the QQ. I write the QQ columns in a blank page as well and tesseract didn't recognize it.
Is there a way to convert this table in png format to text using tesseract? Is there something that escaped me?