EasyOCR
EasyOCR copied to clipboard
Box detection seems off
Take this sample code:
import cv2
import easyocr
from PIL import Image
# Initialize EasyOCR Reader
reader = easyocr.Reader(['en'])
image_path = 'imessage2.png'
image = cv2.imread(image_path)
print(f"Detecting boxes for image with dimensions (HxW): {image.shape[0]}x{image.shape[1]}")
# Use EasyOCR to detect text regions
[[horizontal_list], _] = reader.detect(image, min_size = 1, canvas_size = 2560, mag_ratio = 1, add_margin = 0.1, text_threshold = 0.5, low_text = 0.4, width_ths = 0.9, height_ths = 0.5, ycenter_ths = 0.5, slope_ths = 0.1)
for i, box in enumerate(horizontal_list):
x_min, x_max, y_min, y_max = box
# Crop the region of interest (ROI) from the image
roi = image[y_min:y_max, x_min:x_max]
roi_filename = f"boxes/box_{i}.png"
cv2.imwrite(roi_filename, roi)
With the below image imessage2.png:
No matter which width_ths, low_text, and text_threshold arguments I pass in, I keep getting a bounding box that is missing real text data:
when I increase slope_ths to 0.3 I do get "you" on there:
but no matter what I do I don't seem to get "I" on there, unless I set low_text to something really low like 0.1 but then all my other boxes are very off.
running this on MacOS Sonoma, Apple M2
I get the same problems for many items. Is there really no way to manually set the bounding boxes? I get maybe 1-5 hits for each sentence (all of them missing a few characters).