影刀离线OCR
Project description
简介
利用 onnxruntime 及 PaddleOCR 提供的模型, 对图片中的文字进行检测与识别.
使用模型
- 文字检测:
ch_PP-OCRv3_det_infer - 方向分类:
cls mobile v2 - 文字识别:
ch_PP-OCRv2_rec_infer
参考
安装
pip install ydocr
使用
import cv2
from ydocr.predict_system import TextSystem,order_onrow
text_sys = TextSystem()
# 识别单行文本
res = text_sys.ocr_single_line(cv2.imread('single_line_text.png'))
print(res)
# 批量识别单行文本
res = text_sys.ocr_lines([cv2.imread('single_line_text.png')])
print(res[0])
# 检测并识别文本
img = cv2.imread('test.png')
res = text_sys.detect_and_ocr(img)
for boxed_result in res:
print("{}, {:.3f}".format(boxed_result.ocr_text, boxed_result.score))
# 检测并识别文本(换行执行)
from ydocr.predict_system import TextSystem,order_onrow
img = cv2.imread('test.png')
res = text_sys.detect_and_ocr(img)
res = order_onrow(res)
#检测并识别文本,图片源是网络图片
from urllib.request import urlopen
def cv_imread_url(img_url):
resp = urlopen(img_url)
img = np.asarray(bytearray(resp.read()), dtype=np.uint8)
img = cv2.imdecode(img, cv2.IMREAD_COLOR)
return img
img = cv_imread_url('https://imgurl.png')
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ydocr-1.2.8.tar.gz
(17.6 MB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
ydocr-1.2.8-py3-none-any.whl
(17.7 MB
view details)
File details
Details for the file ydocr-1.2.8.tar.gz.
File metadata
- Download URL: ydocr-1.2.8.tar.gz
- Upload date:
- Size: 17.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57f078ae994dce737ceead9106984ea6b9175e7ee2b7544f67c042d045fe92e0
|
|
| MD5 |
c6de5c4dc6eef5c72074a5f23d456f60
|
|
| BLAKE2b-256 |
4590cc15a7e58a8e7b8dcedb18a0f58f85883dd3fff8cdc0a917c438670fd87e
|
File details
Details for the file ydocr-1.2.8-py3-none-any.whl.
File metadata
- Download URL: ydocr-1.2.8-py3-none-any.whl
- Upload date:
- Size: 17.7 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d92b8d357ff3221576cbf0b71207a20f2824ee30c06993ac6a8a6197ef327974
|
|
| MD5 |
9ac0a098c7ab2bd0ceeaaf4ee510f279
|
|
| BLAKE2b-256 |
55619e811867222ef9cf3e7c522848ecbe6fd03cfd74c8500a60e585cf6c3e79
|