PaddleOCR——DEMO
生活随笔
收集整理的這篇文章主要介紹了
PaddleOCR——DEMO
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
項(xiàng)目地址
https://github.com/PaddlePaddle/PaddleOCR
https://gitee.com/paddlepaddle/PaddleOCR
DEMO
#!usr/bin/env python # -*- coding:utf-8 _*- """ @version: 0.0.1 @author: ShenTuZhiGang @time: 2021/01/29 10:46 @file: paddleocrdemo.py @function: @last modified by: ShenTuZhiGang @last modified time: 2021/01/29 10:46 """ import cv2 import paddleocr from PIL import Image, ImageDraw, ImageFont import numpy as np res = paddleocr.PaddleOCR(use_gpu=False).ocr(img=r'test.png')img = Image.open(r'test.png') im = np.array(img) for i in range(len(res)):cv2.rectangle(im, (int(res[i][0][0][0]), int(res[i][0][0][1])),(int(res[i][0][2][0]), int(res[i][0][2][1])), (255, 0, 0), 1)# 使用cv2.putText不能顯示中文,需要使用下面的代碼代替# cv2.putText(im, d['text'][i], (x, y-8), cv2.FONT_HERSHEY_SIMPLEX, 0.3, (255, 0, 0), 1)pilimg = Image.fromarray(im)pilimg.resize((800, 600),Image.ANTIALIAS)draw = ImageDraw.Draw(pilimg)# 參數(shù)1:字體文件路徑,參數(shù)2:字體大小font = ImageFont.truetype("simhei.ttf", 15, encoding="utf-8")# 參數(shù)1:打印坐標(biāo),參數(shù)2:文本,參數(shù)3:字體顏色,參數(shù)4:字體text, sroce = res[i][1]draw.text((res[i][0][0][0], res[i][0][0][1]), text, (255, 0, 0), font=font)im = cv2.cvtColor(np.array(pilimg), cv2.COLOR_RGB2BGR)cv2.imshow("recoText", im) cv2.waitKey(0) cv2.destroyAllWindows()參考文章
anaconda3+ paddleOCR安裝使用
與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的PaddleOCR——DEMO的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PaddleOCR——运行错误【Plea
- 下一篇: PaddleOCR——Docker环境下