Python Forum

Full Version: PyOCR cannot detect clearly?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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:
[Image: kjQqfYX.png]

Final Detected image:
[Image: final.png]

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