依赖
# python==3.7.3
paddleocr==2.7.0.2
paddlepaddle==2.5.2
loguru==0.7.3
from paddleocr import PaddleOCR
import cv2
import numpy as npif __name__ == '__main__':OCR = PaddleOCR(use_doc_orientation_classify=False, # 检测文档方向use_doc_unwarping=False, # 矫正扭曲文档use_textline_orientation=False) # 识别文本行方向image_path = r'C:\Users\123\Desktop\2.jpg'image = cv2.imread(image_path)result = OCR.ocr(image_path, cls=False)for box in result[0]:print(f'区域:【{box[0]}】,结果:【{box[1]}】')points = np.array(box[0], dtype=np.int32).reshape((-1, 1, 2))cv2.polylines(image, [points], isClosed=True, color=(0, 0, 255), thickness=1)cv2.imshow('', image)cv2.waitKey(0)cv2.destroyAllWindows()
源码下载
链接: https://pan.baidu.com/s/1RwxzllNdwhiICHKGpIu2wQ 提取码: cvfr