Tesseract安装使用

来源:互联网 发布:淘宝店铺买家采集 编辑:程序博客网 时间:2024/06/07 15:22

mac


brew install Tesseract


↳ Command-Line OCR with Tesseract on Mac OS X

tags: ocr

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英文)
0 0
原创粉丝点击