gpt4 book ai didi

python - 使用 pytesseract 时如何设置配置 load_system_dawg 以改善结果?

转载 作者:行者123 更新时间:2023-12-03 17:29:24 26 4
gpt4 key购买 nike

我试图通过使用 pytesseract 配置更改参数来改善结果。我想知道是否有可能按照 https://github.com/tesseract-ocr/tesseract/wiki/ImproveQuality#page-segmentation-method 中的规定更改 load_system_dawg 和 load_freq_dawg因为我想要得到的单词并不是真正的英语,而是像 XYZ ### 和其他一些独特的字母序列这样的坐标。看截图

minecraft screenshot

我可以调整 --psm 的配置,但是如果我尝试 --load_system_dawg 0 会得到没有这样的命令行参数或文件不存在的错误。我不知道,似乎值得一试......

params = r'--psm 11'
string = pytesseract.image_to_string(img, config = params)

我假设没有办法通过 python 来做到这一点,但如果我能被指示如何更改它,我会很感激,因为我对 C++ 了解不多。这个改动会通过pytesseract初始化吗?此外,我还尝试更改用户模式,但不确定这是否是更好的方法

最佳答案

您需要了解以下内容:

  • thresholding using cv2.inRange
  • Arithmetic Operations on Images .
  • Page segmentation methods

  • 例如,如果您应用阈值图像将变为:
    enter image description here
    下次申请 bitwise_not :
    enter image description here
    现在,如果您阅读(假设图像是一个统一的文本块。):
    Hinecratt 1.14.4 1.14.4 / vanilla Javea: 136 51 64bit
    68 fps (8 chunk updates) T: inf vsune fancy-clouds veo Hem: 4ah 8757 2648NE
    Integrated server @ 11 ms ticks, 13 tx, 735 rx Allocated: 814% 1664M6
    C: 1615376 (5) 0: 15, pC: G66, pu: 6, ab: Se
    c afte oe CPU: 16% AND Fiyzen 7 L786 ECight-Core Processor
    Client Chunk Cache: 1659, 75 Display: 1926%1880 CHVIOIA Corporation?
    ServerChunkCache: S734 GeForce OTA 1666 606/PCle/55E2
    ninecrattoverworld FC: a 4.6.4 HVIDIA 431.68
    42: S6L641 / 11.66668 ¢ 361.939 Targeted Block
    Block: S61 11 361 Hinecrattiron_ore
    Chunk: 13 11 3 in 18 @ 22
    Facing: west (Towards negative 43 095.4 7 15.79 Targeted Fluid
    Client Light: 11 (8 sky, 11 block? ninecrattempty
    Server Light: (8 sky, 11 black?
    CHS: 67 MH: 67
    5H 3:67 0: 67 M: 67 ML: 67
    Biome: minecrattdesert
    Local Difficulty: 165 7/7 6.66 (Day 243
    Looking at block: 295 16 361
    Looking at liquid: 295 16 361
    Sounds: 37247 + a7G
    Debug: Pie Cehittl: hidden FPS + TPS Caltl: hidden
    For hele: press Fa + oO
    代码:
    import cv2
    import numpy as np
    import pytesseract

    # Load the image
    img = cv2.imread("sPQDo1c.png")

    # Convert to the HSV color-space
    hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)

    # Threshold
    thr = cv2.inRange(hsv, np.array([0, 0, 214]), np.array([179, 0, 225]))

    # Bitwise-not
    bnt = cv2.bitwise_not(thr)

    # OCR
    print(pytesseract.image_to_string(bnt, config="--psm 6"))

    # Display
    cv2.imshow("", bnt)
    cv2.waitKey(0)
    我正在使用 pytesseract 版本 0.3.7

    关于python - 使用 pytesseract 时如何设置配置 load_system_dawg 以改善结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57454134/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com