0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Tesseract5のvcpkg install 2022/05/29

Posted at

Tesseract5のvcpkg install 2022/05/29

この記事について

windows C#/C++などから、Tesseract 5.1.0 を使ってみたくなっていろいろ調べた結果、
vcpkgからだと4.1.1で止まっていました。
vcpkgのプルリクを見ると、linux版のCI途中で止まっているようですが、
(この辺りは私も疎いので頑張って欲しいとしか言えません。)
今回はwindows環境なのでできていると信じて、トライしてみました。

※プルリクは22/4/24で止まっているので、そのうち正式に対応するかもしれませんが、
 それまでのつなぎとして使います。
 5.0.1は1年以上前のプルリクが反映されない感じだったので、メモにもなるかと。

環境

  • Winodws11 Pro
  • vscode (tesseract リポジトリやSHA512などを修正するためだけ。)

参考

vcpkgのtesseract 5.1.0 プルリク

手順

1.vcpkgのインストール

コマンドプロンプトから。


cd c:\
git clone https://github.com/microsoft/vcpkg
.\vcpkg\bootstrap-vcpkg.bat

2.tesseract5用にリポジトリやcmake設定の編集


cd c:\vcpkg\ports\tesseract
code .

この中から、portfile.cmakeを次のように編集します。
※パッチを消してしまっていいのかわかりませんが、治っていると信じてやってみます。

Before(修正、消すもの)


4~8行目

    REF 4.1.1
    SHA512 017723a2268be789fe98978eed02fd294968cc8050dde376dee026f56f2b99df42db935049ae5e72c4519a920e263b40af1a6a40d9942e66608145b3131a71a2
    PATCHES
        fix-tiff-linkage.patch
        fix-timeval.patch # Remove this patch in the next update

42行目
  vcpkg_cmake_config_fixup(CONFIG_PATH cmake)
55行目
  vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/tesseract.pc" "-ltesseract41" "-ltesseract41d")
59~68行目 if("training-tools" IN_LIST FEATURES)内削除

After(変更、追加)


4~8行目 書き換え
    REF c2a3efe2824e1c8a0810e82a43406ba8e01527c4 #5.1.0
    SHA512 a9a6a2d49d5e4aa10b48d45e8334c70e370d4e22418ae1fed55a29f6523790c2e1ec96c54f0ba110bf0358cd111bda5291d165aa7f66c51f229c9c70876c72ee
    PATCHES
        #fix-tiff-linkage.patch
        #fix-timeval.patch # Remove this patch in the next update

37行目 vcpkg_cmake_configure 追記
  -DSW_BUILD=OFF
42行目 書き換え
  vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/tesseract)
55行目 書き換え
  vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/tesseract.pc" "-ltesseract50" "-ltesseract50d")
62行目 追記
  file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

次にvcpkg.jsonを次のように直します。


  "version": "4.1.1",
↓
  "version": "5.1.0",

書き換えたらコマンドプロンプトから、


cd ..\..\versions\
code .

でbaseline.jsonとt-\tesseract.jsonを書き換えます。
baseline.json


    "tesseract": {
      "baseline": "4.1.1",
      "port-version": 10
    },
↓ 書き換え
    "tesseract": {
      "baseline": "5.1.0",
      "port-version": 0
    },

tessract.json追記するだけ。


    {
      "git-tree": "0564372cd4f15e6e3b06184eb8f6e03c1fd36b63",
      "version": "5.1.0",
      "port-version": 0
    },

3. tesseractのビルド

設定が終わったら、同じくコマンドプロンプトから。


cd c:\vcpkg\
.\vcpkg.exe install tesseract:x64-windows

でtesseractをビルド
終わったら、


.\vcpkg.exe integrate install

で。

4.確認

c:\vcpkg\installed\x64-windows
内に、tesseract周りのものができているので、tesseractのバージョンを確認


c:\vcpkg\installed\x64-windows\tools\tesseract\tesseract.exe --version

tesseract 5.1.0
 leptonica-1.82.0 (May 29 2022, 22:27:30) [MSC v.1932 LIB Release x64]
  libgif 5.2.1 : libjpeg 6b (libjpeg-turbo 2.1.3) : libpng 1.6.37 : libtiff 4.3.0 : zlib 1.2.12 : libwebp 1.2.2 : libopenjp2 2.5.0
 Found AVX2
 Found AVX
 Found FMA
 Found SSE4.1

お疲れ様でした。

参考

https://github.com/microsoft/vcpkg/pull/24114
https://tesseract-ocr.github.io/tessdoc/
https://eddiehexorz.com/opencv-tesseract-ocr-setup-for-c-in-visual-studio/

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?