18 lines
388 B
Python
18 lines
388 B
Python
|
import cv2
|
||
|
import easyocr
|
||
|
|
||
|
|
||
|
def easy_ocr_extraction(
|
||
|
img_path: str
|
||
|
) -> dict:
|
||
|
org_img_bgr = cv2.imread(img_path)
|
||
|
reader = easyocr.Reader(['fr', 'en'])
|
||
|
result = reader.readtext(org_img_bgr)
|
||
|
word_info = []
|
||
|
for (bbox, text, _) in result:
|
||
|
word_info.append(
|
||
|
[bbox[0][0], bbox[0][1], bbox[2][0], bbox[2][1], text]
|
||
|
)
|
||
|
|
||
|
return word_info
|