推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
codelover2016
V2EX  ›  Python

Python 有什么无脑 OCR 库能搞掂下面这种图片么?

  •  
  •   codelover2016 ·
    liguobao · Jan 23, 2019 · 5156 views
    This topic created in 2844 days ago, the information mentioned may be changed or developed.

    基本没有噪点的图片,很纯净的数字.

    20 replies  •  2019-01-26 18:48:38 +08:00
    zzj0311
    zzj0311
    Jan 23, 2019 via Android
    1
    那么规整 mask 套不就完了。。
    nicevar
    nicevar
    Jan 23, 2019
    2
    直接调用 tesseract 就行了,或者用百度的 ocr 也行,这种简单的数字一天能有 5w 次免费额度
    lsvih
    lsvih
    Jan 23, 2019
    3
    tesseract
    xiumie
    xiumie
    Jan 23, 2019
    4
    tesseract py
    codelover2016
    codelover2016
    OP
    Jan 23, 2019
    5
    @nicevar @xiumie @lsvih tesseract 我试过,没出来...
    好惨.
    codelover2016
    codelover2016
    OP
    Jan 23, 2019
    6
    @zzj0311 mask 是哪个库?
    Geno1024
    Geno1024
    Jan 23, 2019
    7
    😐直接打字符像素点的匹配不就是了……
    Vegetable
    Vegetable
    Jan 23, 2019 via iPhone
    8
    @codelover2016 这个绝对 tesseract 绝对可以的,甚至不需要训练。
    注意一下参数,纯数字,单行,英语。具体参数不记得了。
    nicevar
    nicevar
    Jan 23, 2019
    9
    @codelover2016 这种纯数字太简单了,你需要 tessdata,python 用 pytesseract 库就行了
    tomczhen
    tomczhen
    Jan 24, 2019
    10
    这种程度的 tesseract 绝对可以了,之前弄着玩了一下,比这个复杂多了的也有 70%的正确率。
    ioven
    ioven
    Jan 24, 2019
    11
    百度、腾讯、搜狗的 ocr 都能识别
    liberize
    liberize
    Jan 24, 2019
    12
    tesseract 参数你没设对吧,这种 100%识别率吧
    linap
    linap
    Jan 24, 2019 via Android
    13
    分割成相同宽度,取 5 个特征点,搞定
    locoz
    locoz
    Jan 24, 2019
    14
    这种简单的纯数字可以切片好直接对比像素点,比 OCR 的效率还高
    codelover2016
    codelover2016
    OP
    Jan 25, 2019
    15
    @liberize 能不能伸手党要个代码...
    codelover2016
    codelover2016
    OP
    Jan 25, 2019
    16
    @locoz 这个非常有道理...
    liberize
    liberize
    Jan 26, 2019
    17
    @codelover2016

    $ cat test.py

    import pytesseract
    from PIL import Image

    img = Image.open('test.jpg')
    print pytesseract.image_to_string(img, lang='eng', config='-psm 6 digits')


    $ cat digits

    tessedit_char_whitelist 0123456789
    debug_file /dev/null

    $ python test.py
    659208134

    digits 文件放到 .py 相同目录(也许可以写到代码里,自己研究吧)
    liberize
    liberize
    Jan 26, 2019
    18
    额,少复制了一个 7,实际结果是对的,你自己试试把
    liberize
    liberize
    Jan 26, 2019
    19
    模板匹配也可以,代码稍微多点,自己写吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1936 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 08:11 · PVG 16:11 · LAX 00:11 · JFK 03:11
    ♥ Do have faith in what you're doing.