PaddleOCR:百度OCR库

willsonlincake之家 willsonlincake之家 750 人阅读 | 0 人回复 | 2022-04-05

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
from paddleocr import PaddleOCR
import 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 = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]

for box in boxes:   
    top_left     = (int(box[0][0]), int(box[0][1]))
    bottom_right = (int(box[2][0]), int(box[2][1]))

    cv2.rectangle(mat, top_left, bottom_right, (0, 255, 0), 2)

cv2.imshow("result", mat)
cv2.waitKey(0)

https://thigiacmaytinh.com/xac-d ... anh-bang-paddleocr/
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

热门推荐