Issue
I need to crop an image in order to get only footer informations. With this informations I get the position of the text found (with pytesseract) but with the footer-only image. So when I work with the full image, I need to have the position updated. For now here is what I have :
Crop image :
from wand.image import Image as Img
from wand.color import Color
with Img(filename=img, resolution=300) as pic:
pic.compression_quality = 100
pic.background_color = Color("white")
pic.alpha_channel = 'remove'
heightRatio = int(pic.height / 3 + pic.height * 0.1)
pic.crop(0, int(pic.height - heightRatio), pic.width, pic.height)
pic.save(filename=jpgName)
After that, I my text with the position like {0: {x1,y1}, 1: {x2,y2}}
and I have the following code to try to get the position like I didn't crop the image :
position[0][0] = line.position[0][0]
position[1][0] = line.position[1][0]
position[0][1] = line.position[0][1] + heightRatio
position[1][1] = line.position[1][1] + heightRatio
But when I show the position on the full image, it doesn't fit at all..
Any idea ?
Thanks in advance
Solution
I finally found the answer : The crop function was the issue. Using this parameters are better :
pic.crop(width=pic.width, height=int(pic.height - self.heightRatio), gravity='south')
Answered By - Nathan Cheval
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.