JaidedAI / EasyOCR

Ready-to-use OCR with 80+ supported languages and all popular writing scripts including Latin, Chinese, Arabic, Devanagari, Cyrillic and etc.
https://www.jaided.ai
Apache License 2.0
23.88k stars 3.12k forks source link

check my code please, it doesnt recognise all letters #1286

Closed tierline1 closed 2 months ago

tierline1 commented 2 months ago
import easyocr
import argparse
import numpy as np
import cv2
import pygetwindow as gw
import pyautogui
from matplotlib import pyplot as plt

path = "result.png" 

def draw_bounding_boxes(image, detections, threshold=0.25):
    for bbox, text, score in detections:
        if score > threshold:
            cv2.rectangle(image, tuple(map(int, bbox[0])), tuple(map(int, bbox[2])), (0, 255, 0), 5)
            cv2.putText(image, text, tuple(map(int, bbox[0])), cv2.FONT_HERSHEY_COMPLEX_SMALL, 0.65, (255, 0, 0), 2)

img = cv2.imread(path)
reader = easyocr.Reader(['ru'])
result = reader.readtext(img)

threshold = 0.25

draw_bounding_boxes(img, result, threshold)
plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGBA))

plt.show()

str=""
for (bbox, text, prob) in result:
    text = text.lower()
    match text:
        case '0':
            text = "о"
        case '6':
            text = "ь"
        case '₽':
            text = "р"
    str = str+text
print(str.replace(" ", ""))

result on the picture result

1
tierline1 commented 2 months ago

find out that paragraph=False, text_threshold=0.6 helped

tierline1 commented 2 months ago

closed