简体   繁体   中英

OCR text extraction from user interfaces image

I am currently using Pytesseract to extract text from images like Amazon, ebay, (e-commerce) etc to observe certain patterns. I do not want to use a web crawler since this is about recognising certain patterns from the text on such sites. The image example looks like this:

图片示例

However every website looks different so template matching wouldn't help as well. Also the image background is not of the same colour.

The code gives me about 40% accuracy. But if I crop the images into smaller size, it gives me all the text correctly.

Is there a way to take in one image, crop it into multiple parts and then extract text? The preprocessing of images does not help. What I have tried is using: rescaling, removing noise, deskewing, skewing, adaptiveThreshold, grey scale,otsu, etc but I am unable to figure out what to do.

try:
    from PIL import Image
except ImportError:
    import Image
import pytesseract
# import pickle


def ocr_processing(filename):
    """
    This function uses Pillow to open the file and Pytesseract to find string in image.
    """
    text = pytesseract.image_to_data(Image.open(
        filename), lang='eng', config='--psm 6')
    # text = pytesseract.image_to_string(Image.open(
    # filename), lang='eng', config ='--psm 11')
    return text

Just for a recommendation if you have a lot of text and you want to detect it through OCR (example image is above), "Keras" is a very good option. Much much better than pytesseract or using just EAST. It was a suggestion provided in the comments section. It was able to trace 98.99% of the text correctly.

Here is the link to the Keras-ocr documentation: https://keras-ocr.readthedocs.io/en/latest/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM