21 lines
634 B
Python
21 lines
634 B
Python
from PIL import Image
|
|
import numpy as np
|
|
from paddleocr import PaddleOCR
|
|
|
|
ocr = PaddleOCR(use_textline_orientation=True, lang='en')
|
|
image = Image.open('/app/config/test_img.jpeg').convert('RGB')
|
|
img_arr = np.array(image)
|
|
res_list = list(ocr.predict(img_arr))
|
|
|
|
texts = res_list[0].get('rec_texts', [])
|
|
dt_polys = res_list[0].get('dt_polys', [])
|
|
|
|
for idx, (text, poly) in enumerate(zip(texts, dt_polys)):
|
|
if 'BB05032027' in text or 'BB' in text:
|
|
print(f"Match: {text}")
|
|
print("Raw poly:")
|
|
print(poly)
|
|
print("Pts computed:")
|
|
pts = [(float(p[0]), float(p[1])) for p in poly]
|
|
print(pts)
|