在照片中查找文本
scene-text的Python项目详细描述
场景文本检测与识别
这个项目包场景文本算法易于使用。照片中的场景比扫描文档中的场景更难进行文本检测和识别。后者主要被称为ocr,是一个很好解决的问题。请注意,由于使用了深度学习算法,文本检测和识别速度相当慢,特别是在仅使用CPU的机器上,以及对于包含大量单词的图像。精确度已达到令人印象深刻的水平,但仍低于人类的表现。目前,有以下算法可用。
EAST用于检测,其中实现主要从Jan Zdenek复制。
MORAN用于识别,其中实现主要是从Canjie Luo复制的。
安装:
pip install scene_text
python的基本用法:
import cv2
# The first import after installation can take a little longer as it downloads
# pre-trained models and compiles some native code.
from scene_text import AllWordsRecognizer
# initialize models
pipeline = AllWordsRecognizer()
# read an image
img = cv2.imread('path/to/my/image/file')[:, :, ::-1]
# detect and recognize all words in the image
words, boxes = pipeline.get_all_words(img)
命令行的基本用法:
scene_text my/input/image/folder my/output/folder
如果你对复杂的依赖关系有困难,请尝试Docker:
docker build -t scene_text .
docker run --rm -i -t -v ${PWD}:/scene_text scene_text
# ...