Tesseract安装使用

mac


brew install Tesseract


This is a short writeup of the working process I came up with for command-line OCR of a non-OCR’d PDF with searchable PDF output on OS X, after running into a thousand little gotchas. 1

Software Installation

  1. Install homebrew (if you haven’t already).
  2. Install ImageMagick with TIFF and Ghostscript support:

    brew install --with-libtiff --with-ghostscript imagemagick
    
  3. Install Tesseract with all languages:

    brew install --all-languages tesseract
    
  4. Install pdftk server from the package installer.

Processing Workflow

I’m going to assume you have a non-OCR’d PDF you want to convert into a searchable PDF.

  1. Split and convert the PDF with ImageMagick convert:

    convert -density 300 input.pdf -type Grayscale -compress lzw -background white +matte -depth 32 page_%05d.tif
    
  2. OCR the pages with Tesseract: 2 3

    for i in page_*.tif; do echo $i; tesseract $i $(basename $i .tif) pdf; done
    
  3. Join your individual PDF files into a single, searchable PDF with pdftk4

    pdftk page_*.pdf cat output merged.pdf


convert 9.png -resize 3000% -type Grayscale input9.tif (因为像素low所以要转)


tesseract input9.tif output9 -l eng

tesseract input9.png output9   (默认是eng英文)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值