1. 图像文字位置检测 git上下载源码 https://github.com/eragonruan/text-detection-ctpn
因为默认是gpu版本的,修改为不用gpu有几个坑
先参考 https://github.com/eragonruan/text-detection-ctpn/issues/43
把需要注释的几个地方注释掉
然后修改setup.py, 用下面这段代码整个替换掉
from Cython.Build import cythonize
import numpy as np
from distutils.core import setup
from distutils.extension import Extension
try:
numpy_include = np.get_include()
except AttributeError:
numpy_include = np.get_numpy_include()
ext_modules = [
Extension(
'bbox',
sources=['bbox.c'],
include_dirs = [numpy_include]
),
Extension(
'cython_nms',
sources=['cython_nms.c'],
include_dirs = [numpy_include]
)
]
setup(
ext_modules=ext_modules
)
运行:
python setup.py build_ext --include-dirs=/anaconda2/envs/chinese-ocr/lib/python2.7/site-packages/numpy/core/include
include-dirs 换成自己的numpy地址,将build完之后的.so文件copy到utils文件夹下
运行demo需要下载 https://github.com/eragonruan/text-detection-ctpn/releases checkpoint文件,就是用已经训练好的模型,解压 到text-detection-ctpn的主目录,然后到主目录运行python ./ctpn/demo.py,即可将demo下的图片进行标注
2.文字识别
Git地址:https://github.com/xiaofengShi/CHINESE-OCR/blob/master/demo.py