Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EasyOCR not reading Japanese text #1350

Open
TLiley2 opened this issue Dec 17, 2024 · 0 comments
Open

EasyOCR not reading Japanese text #1350

TLiley2 opened this issue Dec 17, 2024 · 0 comments

Comments

@TLiley2
Copy link

TLiley2 commented Dec 17, 2024

For some reason unknown to me EasyOCR will or will not at times read clearly legible Japanese text at random and I need help getting to the bottom of why? Can anyone help?
combine_images

img = cv2.imread(imgap)
    if img is None:
        print("Image not found at path")

    # Increase contrast
    contrast = cv2.convertScaleAbs(img, alpha=1.5, beta=1)

    # Greyscale
    gray = cv2.cvtColor(contrast, cv2.COLOR_BGR2GRAY)

    # Denoise the image with Gaussian Blur
    blurred = cv2.GaussianBlur(gray, (3, 3), 0)

    # Threshold the image (binary)
    _, threshold_img = cv2.threshold(blurred, 128, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)

    # Calculate the percentage of black pixels
    import numpy as np
    black_pixels = np.sum(threshold_img == 0)
    total_pixels = threshold_img.size
    black_ratio = black_pixels / total_pixels

    # Invert the image if black pixels dominate
    if black_ratio > 0.75:
        processed_img = cv2.bitwise_not(threshold_img)
    else:
        processed_img = threshold_img

    # Perform OCR on the processed image
    reader = easyocr.Reader(['ja'], gpu=True)
    result = reader.readtext(processed_img, text_threshold=0.6, low_text=0.2)
    print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant