Skip to content
/ tr Public
forked from myhub/tr

Free Offline OCR 离线的中文文本检测+识别SDK

License

Notifications You must be signed in to change notification settings

feenn/tr

This branch is 42 commits ahead of, 264 commits behind myhub/tr:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
myhub
Nov 21, 2020
34997c1 · Nov 21, 2020

History

42 Commits
Jun 4, 2020
Nov 21, 2020
Jun 24, 2020
Jun 4, 2020
Jun 4, 2020
Jun 25, 2020
Nov 15, 2020
Nov 21, 2020
Jun 5, 2020
Jun 24, 2020
Jun 6, 2020
Jun 24, 2020

Repository files navigation

tr - Text Recognition

一款针对扫描文档的离线文本识别SDK,核心代码全部采用C++开发,并提供Python接口

更新说明

  • c++接口支持
  • 支持Windows系统
  • 添加python2支持
  • 去除opencv-python、Pillow依赖,降低部署难度
  • 支持多线程
  • 支持GPU

Contact

Email: [email protected]

Requirements

  • Windows 7+/Ubuntu 16.04/Ubuntu 18.04
  • python2/python3,需要安装numpy
  • Windows系统需要安装VC_redist.x64.exe

GPU版本安装说明

如果对速度有要求,推荐安装GPU版本
要使用GPU版本,复制tr_gpu文件夹里面的文件到tr文件夹
注意: 需要先安装CUDA 10.1以及cuDNN 7.6.5

若不想安装CUDA/cuDNN,可以使用docker部署

docker pull mcr.microsoft.com/azureml/onnxruntime:v1.3.0-cuda10.1-cudnn7
sudo nvidia-docker run -v /path/to/tr:/path/to/tr --rm -it mcr.microsoft.com/azureml/onnxruntime:v1.3.0-cuda10.1-cudnn7

Install

  • 安装方法一
git clone https://github.com/myhub/tr.git
cd ./tr
sudo python setup.py install
  • 安装方法二
sudo pip install git+https://github.com/myhub/tr.git@master

Test

python2 demo.py               # python2兼容测试     
python3 test.py               # 可视化测试
python3 test-multi-thread.py  # 多线程测试

关联项目

  • 若需要Web端调用,推荐参考TrWebOCR

Python Example

import tr

# detect text lines, return list of (cx, cy, width, height, angle)
print(tr.detect("imgs/web.png", tr.FLAG_RECT))

# detect text lines with angle, return list of (cx, cy, width, height, angle)
print(tr.detect("imgs/id_card.jpeg", tr.FLAG_ROTATED_RECT))

# recognize text line, return (text, confidence)
print(tr.recognize("imgs/line.png"))

# detect and recognize text lines with angle, return list of ((cx, cy, width, height, angle), text, confidence)
print(tr.run("imgs/id_card.jpeg"))

C++ Example

tr_init(0, 0, "crnn.bin", NULL);

#define MAX_WIDTH		512
int unicode[MAX_WIDTH];
float prob[MAX_WIDTH]; 

auto ws = tr_recognize(0, (void *)"line.png", 0, 0, 0, unicode, prob, MAX_WIDTH);

tr_release(0);

效果展示


About

Free Offline OCR 离线的中文文本检测+识别SDK

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%