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] Read Arabic text in Python with easyOCR

Discussão em 'Python' iniciado por Stack, Julho 14, 2025.

  1. Stack

    Stack Membro Participativo

    I have a problem reading the text in Arabic. I did some processing and contrast, but the text is not fully readable.

    !pip install easyocr
    !pip install --upgrade easyocr opencv-python

    import easyocr
    import cv2
    from matplotlib import pyplot as plt
    from google.colab import files
    import numpy as np
    from PIL import Image
    uploaded = files.upload()
    image_path = next(iter(uploaded))

    image = Image.open(image_path)
    image = np.array(image)


    plt.imshow(image)
    plt.axis("off")
    plt.show()

    def test_easyocr_basic(image):
    reader = easyocr.Reader(['en', 'ar'])
    result = reader.readtext(image)

    img_draw = image.copy()
    for i, (bbox, text, prob) in enumerate(result, start=1):
    print(f"{i}. [{prob:.2f}] {text}")
    top_left = tuple(map(int, bbox[0]))
    bottom_right = tuple(map(int, bbox[2]))
    cv2.rectangle(img_draw, top_left, bottom_right, (0, 255, 0), 2)
    plt.figure(figsize=(10, 10))
    plt.imshow(cv2.cvtColor(img_draw, cv2.COLOR_BGR2RGB))
    plt.axis("off")
    plt.show()

    test_easyocr_basic(image)


    [​IMG]

    Continue reading...

Compartilhe esta Página