Reputation: 2071
I am trying to ready Energy Efficiency Rating from EPC certificate using python. Usually EPC certificate comes in PDF format. I have converted PDF into image already and using pytesseract to get text from image. However I am not getting expected results.
Expected output: Current rating : 79, Potential rating : 79
What I have tried so far:
from pdf2image import convert_from_path
import pytesseract
from PIL import Image
pages = convert_from_path(r'my_file.pdf', 500)
img =pages[0].save(r'F:\Freelancer\EPC rating\fwdepcs\out.jpg', 'JPEG')
text = pytesseract.image_to_string(Image.open(r'F:\Freelancer\EPC rating\fwdepcs\out.jpg'))
However text does not capture 79.
I also tried cv2 pattern matching and shape detection, but those not worked for other reasons.
Upvotes: 1
Views: 158
Reputation: 12672
You say that you have convert this pdf to image file.
Use PIL(.crop()) or opencv to crop picture.And crop it like this:
And use PIL Image.convert("1")
,maybe tesseract can catch this number.
If not,I think you can use jTessBoxEditor to train tesseract.
Upvotes: 2