#!/user/bin/env python # coding=utf-8 """ @project : ocr_paddle @author : huyi @file : test.py @ide : pycharm @time : 2021-11-15 14:56:20 """ from paddleocr import paddleocr, draw_ocr # paddleocr目前支持的多语言语种可以通过修改lang参数进行切换 # 例如`ch`, `en`, `fr`, `german`, `korean`, `japan` ocr = paddleocr(use_angle_cls=true, use_gpu=false, lang="ch") # need to run only once to download and load model into memory img_path = './data/2.jpg' result = ocr.ocr(img_path, cls=true) for line in result: # print(line[-1][0], line[-1][1]) print(line) # 显示结果 from pil import image image = image.open(img_path).convert('rgb') boxes = [line[0] for line in result] txts = [line[1][0] for line in result] scores = [line[1][1] for line in result] im_show = draw_ocr(image, boxes, txts, scores, font_path='./fonts/simfang.ttf') im_show = image.fromarray(im_show) im_show.save('result.jpg')