我可以使用什么策略对 Magic the Gathering 角文本进行 OCR?

What strategy can I use to OCR Magic the Gathering corner text?

我需要识别万智牌纸牌左下角的文字(上次设计)。举个例子:

如果文字是这样的 我想检索以下文本:

198/280 U
M20 EN

(在这个例子中我不需要卡片作者姓名 - Lake Hurwitz)

我可以使用什么 OCR 库?我在没有任何调整的情况下尝试使用 Tesseract,但结果不正确。对已经做这些事情的项目有什么建议或 link 吗?

您可以通过对图像进行一些清理来使用 tesseract (3.04.01) 制作它 就像下面的代码

import numpy as np
import cv2

def prepro(zone, prefix):
    filename = 'stackmagic.png'
    oriimg = cv2.imread(filename)

    #keep the interesting part
    (a,b,c,d) = zone
    text_zone = oriimg[a:b, c:d]
    height, width, depth = text_zone.shape

    #resize it to be bigger (so less pixelized)
    H = 50
    imgScale = H/height
    newX,newY = text_zone.shape[1]*imgScale, text_zone.shape[0]*imgScale
    newimg = cv2.resize(text_zone,(int(newX),int(newY)))

    #binarize it
    gray = cv2.cvtColor(newimg, cv2.COLOR_BGR2GRAY)
    th, img = cv2.threshold(gray, 130, 255, cv2.THRESH_BINARY);

    #erode it
    kernel = np.ones((1,1),np.uint8)
    erosion = cv2.erode(img,kernel,iterations = 1)
    cv2.imwrite(prefix+'_ero.png', erosion)

    cv2.imshow("Show by CV2",erosion)
    cv2.waitKey(0)


prepro((16,27, 6,130), 'upzone')
prepro((27,36, 6,130), 'downzone')

来自你的cropped image 你得到

上部:

及下半部分:

而且 tesseract 似乎确实能够提取

xx$ tesseract upzone_ero.png stdout
198/ 280 U

xx$ tesseract downzone_ero.png stdout
M20 ~ EN Duluu Hun-nu

请注意,我们无法提取 Luke,但希望您对 him/it 不感兴趣 :)

还有其他工具,但那是广告内容并且是主观的..