PaddleOCR:百度OCR库
from paddleocr import PaddleOCRimport cv2
# Also switch the language by modifying the lang parameter
ocr = PaddleOCR(lang="en") # The model file will be downloaded automatically when executed for the first time
img_path ='example.jpg'
result = ocr.ocr(img_path)
# Recognition and detection can be performed separately through parameter control
# result = ocr.ocr(img_path, det=False)Only perform recognition
# result = ocr.ocr(img_path, rec=False)Only perform detection
# Print detection frame and recognition result
for line in result:
print(line)
# Visualization
mat = cv2.imread(img_path)
boxes = for line in result]
txts = for line in result]
scores = for line in result]
for box in boxes:
top_left = (int(box), int(box))
bottom_right = (int(box), int(box))
cv2.rectangle(mat, top_left, bottom_right, (0, 255, 0), 2)
cv2.imshow("result", mat)
cv2.waitKey(0)
https://thigiacmaytinh.com/xac-dinh-vi-tri-cua-text-trong-anh-bang-paddleocr/
页:
[1]