PyOCR cannot detect clearly? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: PyOCR cannot detect clearly? (/thread-27920.html) |
PyOCR cannot detect clearly? - wood_6636 - Jun-27-2020 As you can see in the down below captures, the image cannot be nicely detected to the final result, could anyone tell me how to have a better recognition by using PyOCR ? Image Source: Final Detected image: def codeocr(): #My Code img=cv2.imread('/Users/Woodylin/Desktop/Python Learnings/Bank_Fubon_Mort_Scrapping/img_source.png') dst=cv2.fastNlMeansDenoisingColored(img,None,10,10,7,21) ret,thresh=cv2.threshold(dst,127,255,cv2.THRESH_BINARY_INV) cv2.imwrite("/Users/Woodylin/Desktop/Python Learnings/Bank_Fubon_Mort_Scrapping/final.png",thresh) from PIL import Image import sys import pyocr import pyocr.builders tools = pyocr.get_available_tools() if len(tools) == 0: print("No OCR tool found") sys.exit(1) tool = tools[0] result = tool.image_to_string( Image.open('/Users/Woodylin/Desktop/Python Learnings/Bank_Fubon_Mort_Scrapping/final.png'), builder=pyocr.builders.TextBuilder() ) return result |