读△为负

Read △ as minus

△ 作为业务规则表示减号('-')。我怎样才能按预期阅读以下图像。

$ tesseract 1.png stdout -l eng --psm 4
£74 523

$ tesseract 2.png stdout -l eng --psm 4
a 1,794,306
$ tesseract -v
tesseract 4.1.1-rc2-22-g08899

目前,非数值以编程方式转换为“-”。但它并不总是工作,如下所示。

// Example. △ is read as '4'
tesseract x.png stdout -l eng --psm 4
474 523

OpenCV具有如下所示的搜索和替换图像功能。

  • 搜索图片

  • 输入

  • 输出

  • 代码
import cv2 as cv
import numpy as np
from matplotlib import pyplot as plt
img_rgb = cv.imread('images/input.png')
img_gray = cv.cvtColor(img_rgb, cv.COLOR_BGR2GRAY)
template = cv.imread('images/minus.png', 0)
w, h = template.shape[::-1]
res = cv.matchTemplate(img_gray, template, cv.TM_CCOEFF_NORMED)
threshold = 0.8
loc = np.where(res >= threshold)
for pt in zip(*loc[::-1]):
    cv.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (255, 255, 255), -1)
    cv.line(img_rgb, (pt[0], pt[1] + int(h / 2)),
            (pt[0] + w, pt[1] + int(h / 2)), (0, 0, 0), 2)
cv.imwrite('out/detected-minus.png', img_rgb)
  • 运行
# tesseract out/detected-minus.png stdout -l eng --psm 4
— 2,196,193
  • 参考

https://docs.opencv.org/master/d4/dc6/tutorial_py_template_matching.html