我使用 python 和 keras ocr。我希望 keras 只识别数字,所以在管道中我这样做。
recognizer = keras_ocr.recognition.Recognizer(alphabet="0123456789")
pipeline = keras_ocr.pipeline.Pipeline(recognizer=recognizer)
Run Code Online (Sandbox Code Playgroud)
但它并没有像超立方体白名单那样将字母转换为数字并提高识别质量。
所以这些数字根本不被识别。
使用默认字母表结果更好。但有些数字与字母混淆。然而,将字母更改为数字,如“replace("O", "0")”是一个非常糟糕的主意。
识别功能很简单,复制一下:)
_image = keras_ocr.tools.read(_path)
plt.figure(figsize=(10, 20))
plt.imshow(_image)
prediction = pipeline.recognize([_image])[0]
fig, axs = plt.subplots(1, figsize=(10, 20))
keras_ocr.tools.drawAnnotations(image=_image, predictions=prediction, ax=axs)
plt.show()
Run Code Online (Sandbox Code Playgroud)