TesseractをWindowsにインストールする
#tesseract #windows #機械学習 #備忘
下記の記事から切り出した
動画の機械学習についておべんきょ
OpenCVと同じように、事前にTesseractをインストールしておく必要がある
GitHub - tesseract-ocr/tessdoc: Tesseract documentation
tesseract-ocrのバイナリからwindows向けのを取る
Home · UB-Mannheim/tesseract Wiki · GitHub
https://scrapbox.io/files/67a0e10f8d05d7dcaf4df975.png
https://scrapbox.io/files/67a0e117ce5afca39293dfcd.png
https://scrapbox.io/files/67a0e11c19c133d0589fcb4f.png
https://scrapbox.io/files/67a0e121fd58bda2b78c7d80.png
https://scrapbox.io/files/67a0e12a4a75e312892d2fd6.png
https://scrapbox.io/files/67a0e13455a120d84d5b91d8.png
https://scrapbox.io/files/67a0e15c48b4d4234a16e42e.png
https://scrapbox.io/files/67a0e16a674093be1325f3f8.png
https://scrapbox.io/files/67a0e186a1523bcf3254c607.png
https://scrapbox.io/files/67a0e1948c1b08708c9a27b8.png
https://scrapbox.io/files/67a0e1a0a1523bcf3254c6c3.png
https://scrapbox.io/files/67a0e1a53047b548fe8071d3.png
これでインストールできているので、バージョンを確認
$ /c/tesseract/tesseract --version
tesseract v5.5.0.20241111
leptonica-1.85.0
libgif 5.2.2 : libjpeg 8d (libjpeg-turbo 3.0.4) : libpng 1.6.44 : libtiff 4.7.0 : zlib 1.3.1 : libwebp 1.4.0 : libopenjp2 2.5.2
Found AVX2
Found AVX
Found FMA
Found SSE4.1
Found libarchive 3.7.7 zlib/1.3.1 liblzma/5.6.3 bz2lib/1.0.8 liblz4/1.10.0 libzstd/1.5.6
Found libcurl/8.11.0 Schannel zlib/1.3.1 brotli/1.1.0 zstd/1.5.6 libidn2/2.3.7 libpsl/0.21.5 libssh2/1.11.0
インストーラーにはPATHに追加する動きがなかったので、明示的に指定してversionを確認してる
この後のことも考えてPATHは通しておいたら、下記のコマンドでバージョン確認できる
$ tesseract --version
また、 tesseract\tessdata に jpn.traineddata と jpn_vert.traineddata があることを確認しておく
$ tesseract --list-langs
List of available languages in "C:\tesseract/tessdata/" (6):
eng
jpn
jpn_vert
osd
script\Japanese
script\Japanese_vert
ちゃんとjpnがある
基本的に実行は tesseract imagename outputbase [options...] [configfile...] の形
-l オプションで言語を指定できるので、 -l jpn として日本語を指定
他にも -psm みたいな大事なオプションもあるけど、それは後々で
あとはバウンディボックスの位置も取得出来たらいいかな?
ってことで、TSV形式でバウンディボックスの位置を取れるオプションを付ける
tessedit_create_tsv=1
$ tesseract data_01.jpg output.txt -l jpn -c tessedit_create_tsv=1 --psm 6
いったんここまででtesseractの動きは確認できる
更新履歴
2025/02/05 元記事から切り出し