1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How to Increase Accuracy of Text Read in Images Using Microsoft Azure Computer Vision...

Discussão em 'Python' iniciado por Stack, Setembro 17, 2024.

  1. Stack

    Stack Membro Participativo

    I'm new to Microsoft Azure AI Computer Vision. I am using Cognitive Services and the Computer Vision Client in a Python Program to do two things:

    1. Extract text from a JPG Image using Optical Character Recognition (OCR)
    2. Use Cognitive Services to provide a Description of the Image

    After lots of configuration issues (and PIP installs!), I have achieved SOME results

    The Code for extracting the text from the image is:

    #Create A ComputerVision Client
    client = ComputerVisionClient(ENDPOINT, CognitiveServicesCredentials(API_KEY))

    image_path = '/Users/Owner/Documents/Bills Stuff/eBay/Images/Document_20240914_0008.jpg'

    #Use Azure AI Cognitive Services to Get the Title and Description of Image
    #For the TITLE, Use Optical Character Recognition (OCR) to Read the Text (Caption) on the Image
    with open(image_path, "rb") as image_stream:
    ocr_results=client.recognize_printed_text_in_stream(image_stream)

    if ocr_results.regions:
    for region in ocr_results.regions:
    for line in region.lines:
    print(f" Title: {' '.join([word.text for word in line.words])}")


    My second Point - the Description is working great, BUT the code above is not extracting the Text from the Image accurately at all.

    It's CLOSE, but the actual text is: "Scenic View of Horseshoe Curve on Pennsylvania Railroad"

    The Code I presented above, returns: "Inside of Horseshoe Curve on Cina Railroad"

    Is there a way to improve my code to make this result more accurate?

    Adding: If I decrease/increase the size of my image, the code picks upmore or fewer words - maybe I need to somehow give the code more time to process the image??

    Continue reading...

Compartilhe esta Página