<small id='6yZOW'></small><noframes id='6yZOW'>

    • <bdo id='6yZOW'></bdo><ul id='6yZOW'></ul>

      <tfoot id='6yZOW'></tfoot>

      1. <legend id='6yZOW'><style id='6yZOW'><dir id='6yZOW'><q id='6yZOW'></q></dir></style></legend>
      2. <i id='6yZOW'><tr id='6yZOW'><dt id='6yZOW'><q id='6yZOW'><span id='6yZOW'><b id='6yZOW'><form id='6yZOW'><ins id='6yZOW'></ins><ul id='6yZOW'></ul><sub id='6yZOW'></sub></form><legend id='6yZOW'></legend><bdo id='6yZOW'><pre id='6yZOW'><center id='6yZOW'></center></pre></bdo></b><th id='6yZOW'></th></span></q></dt></tr></i><div id='6yZOW'><tfoot id='6yZOW'></tfoot><dl id='6yZOW'><fieldset id='6yZOW'></fieldset></dl></div>

        在 Windows 10 上安装 C++ tesseract

        Install tesseract for C++ on Windows 10(在 Windows 10 上安装 C++ tesseract)
        <legend id='L2ALd'><style id='L2ALd'><dir id='L2ALd'><q id='L2ALd'></q></dir></style></legend>
        • <bdo id='L2ALd'></bdo><ul id='L2ALd'></ul>

            <tbody id='L2ALd'></tbody>

          <i id='L2ALd'><tr id='L2ALd'><dt id='L2ALd'><q id='L2ALd'><span id='L2ALd'><b id='L2ALd'><form id='L2ALd'><ins id='L2ALd'></ins><ul id='L2ALd'></ul><sub id='L2ALd'></sub></form><legend id='L2ALd'></legend><bdo id='L2ALd'><pre id='L2ALd'><center id='L2ALd'></center></pre></bdo></b><th id='L2ALd'></th></span></q></dt></tr></i><div id='L2ALd'><tfoot id='L2ALd'></tfoot><dl id='L2ALd'><fieldset id='L2ALd'></fieldset></dl></div>
              • <small id='L2ALd'></small><noframes id='L2ALd'>

                <tfoot id='L2ALd'></tfoot>

                1. 本文介绍了在 Windows 10 上安装 C++ tesseract的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 Windows 10 上安装 tesseract 以使用 C++ 进行开发时遇到问题.

                  I am having problems while installing tesseract to develop in C++ on Windows 10.

                  谁能提供指南以获得:
                  1. Leptonica(tesseract需要)lib和includes
                  2. Tesseract 库和包含
                  3. 将两者都链接到项目(例如 Visual Studio)

                  所以这个例子来自 https://github.com/tesseract-ocr/tesseract/wiki/APIExample 有效:

                  Can anyone provide a guide to get:
                  1. Leptonica (required by tesseract) lib and includes
                  2. Tesseract lib and includes
                  3. Link both to project (e.g. Visual Studio)

                  so that example from https://github.com/tesseract-ocr/tesseract/wiki/APIExample works:

                  #include <tesseract/baseapi.h>
                  #include <leptonica/allheaders.h>
                  
                  int main()
                  {
                      char *outText;
                  
                      tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
                      // Initialize tesseract-ocr with English, without specifying tessdata path
                      if (api->Init(NULL, "eng")) {
                          fprintf(stderr, "Could not initialize tesseract.
                  ");
                          exit(1);
                      }
                  
                      // Open input image with leptonica library
                      Pix *image = pixRead("/usr/src/tesseract/testing/phototest.tif");
                      api->SetImage(image);
                      // Get OCR result
                      outText = api->GetUTF8Text();
                      printf("OCR output:
                  %s", outText);
                  
                      // Destroy used object and release memory
                      api->End();
                      delete[] outText;
                      pixDestroy(&image);
                  
                      return 0;
                  }
                  

                  推荐答案

                  几天来,我一直在尝试将 tesseract 库链接到我在 Visual Studio 2019 中的 c++ 项目,我终于设法做到了.我发现的任何线程甚至官方 tesseract 文档都没有完整的操作说明列表.

                  I've been trying to link tesseract library to my c++ project in Visual Studio 2019 for a couple of days and I finally managed to do it. Any thread that I found or even official tesseract documentation do not have full list of instructions on what to do.

                  我会列出我所做的,希望对某人有所帮助.我不假装这是这样做的最佳方式.

                  I'll list what I have done, hopefully it will help someone. I don't pretend its the optimal way to do so.

                  1. 官方 tesseract 文档中有一些基本技巧.转到Windows"部分.我确实安装了 swcppan 但我想没有必要.这里的主要内容是安装 vcpkg.它需要 Git 所以我安装了它.然后:

                  1. There are basic tips in official tesseract documentation. Go to "Windows" section. I did install sw and cppan but I guess it wasn't necessary. The main thing here is installing vcpkg. It requiers Git so I installed it. then:

                  <代码>>cd c:tools(我安装在c: ools,你可以选择任何目录)

                  > cd c:tools (I installed it in c: ools, you may choose any dir)

                  <代码>>git clone https://github.com/microsoft/vcpkg

                  <代码>>.vcpkgootstrap-vcpkg.bat

                  <代码>>.vcpkgvcpkg install tesseract:x64-windows-static(我用的是x64版本)

                  > .vcpkgvcpkg install tesseract:x64-windows-static (I used x64 version)

                  <代码>>.vcpkgvcpkg 集成安装

                  在这一点上,一切都应该可以了,他们说.应该包括标题,应该链接库.但没有一个对我有用.

                  At this point everything should work, they said. Headers should be included, libs should be linked. But none was working for me.

                  1. 将项目配置更改为 Release x64(如果您安装了 x86 tesseract,则为 Release x86).

                  1. Change project configuration to Release x64 (or Release x86 if you installed x86 tesseract).

                  要包含标题:转到项目属性 ->C/C++ ->一般的.将其他包含目录设置为 C: oolsvcpkginstalledx64-windows-staticinclude(或安装 vcpkg 的任何位置)

                  To include headers: Go to project properties -> C/C++ -> General. Set Additional Include Directories to C: oolsvcpkginstalledx64-windows-staticinclude (or whereever you installed vcpkg)

                  链接库:项目属性 ->链接器 ->一般的.将附加库目录设置为 C: oolsvcpkginstalledx64-windows-staticlib

                  To link libraries : project properties -> Linker -> General. Set Additional Library Directories to C: oolsvcpkginstalledx64-windows-staticlib

                  项目属性 ->C/C++ ->代码生成.将运行时库设置为 Multi-threaded(/MT).否则我会收到诸如运行时不匹配静态与 DLL"之类的错误

                  Project properties -> C/C++ -> Code Generation. Set Runtime Library to Multi-threaded(/MT). Otherwise I got errors like "runtime mismatch static vs DLL"

                  Tesseract lib 无法链接到其依赖项,因此我将已安装的所有库添加到 C: oolsvcpkginstalledx64-windows-staticlib.项目属性 ->链接器 ->输入.我将附加依赖项设置为 archive.lib;bz2.lib;charset.lib;gif.lib;iconv.lib;jpeg.lib;leptonica-1.80.0.lib;libcrypto.lib;libpng16.lib;libssl.lib;libwebpmux.lib;libxml2.lib;lz4.lib;lzma.lib;lzo2.lib;openjp2.lib;tesseract41.lib;tiff.lib;tiffxx.lib;turbojpeg.lib;webp.lib;webpdecoder.lib;webpdemux.lib;xxhash.lib;zlib.lib;zstd_static.lib;%(AdditionalDependencies)

                  Tesseract lib couldn't link to its dependcies, so I added all libs that I had installed to C: oolsvcpkginstalledx64-windows-staticlib. Project properties -> Linker -> Input. I set Additional Dependencies to archive.lib;bz2.lib;charset.lib;gif.lib;iconv.lib;jpeg.lib;leptonica-1.80.0.lib;libcrypto.lib;libpng16.lib;libssl.lib;libwebpmux.lib;libxml2.lib;lz4.lib;lzma.lib;lzo2.lib;openjp2.lib;tesseract41.lib;tiff.lib;tiffxx.lib;turbojpeg.lib;webp.lib;webpdecoder.lib;webpdemux.lib;xxhash.lib;zlib.lib;zstd_static.lib;%(AdditionalDependencies)

                  之后它终于编译并启动了.

                  And after that it finally compiled and launched.

                  但是... api->Init 返回了 -1.要使用 tesseract,您应该拥有 tessdata 目录,其中包含您需要的语言的 .traineddata 文件.

                  But... api->Init returned -1. To work with tesseract you should have tessdata directory with .traineddata files for the languages you need.

                  1. 下载tessdata.我从 官方文档 得到它.顺便说一句,就我而言,tessdata_fast 比 tessdata_best 工作得更好:)所以我下载了单曲eng"文件并将其保存为 C: oolsTesseractData essdataeng.traineddata.

                  1. Download tessdata. I got it from official docs. BTW, tessdata_fast worked better than tessdata_best for my purposes :) So I downloaded single "eng" file and saved it like C: oolsTesseractData essdataeng.traineddata.

                  然后我添加了环境变量 TESSDATA_PREFIX,其值为 C: oolsTesseractData essdata.我还将 C: oolsTesseractData 添加到 Path 变量(以防万一)

                  Then I added environment variable TESSDATA_PREFIX with value C: oolsTesseractData essdata. I also added C: oolsTesseractData to Path variables (just in case)

                  毕竟这一切终于对我有用了.

                  And after all this it is finally working for me.

                  这篇关于在 Windows 10 上安装 C++ tesseract的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to print vector#39;s data(如何打印矢量的数据)
                  Visual C++ appends 0xCC (int3) bytes at the end of functions(Visual C++ 在函数末尾附加 0xCC (int3) 字节)
                  How to use a variable inside a _T wrapper?(如何在 _T 包装器中使用变量?)
                  MSVC++ warning flags(MSVC++ 警告标志)
                  How to read file which contains uxxxx in vc++(如何在vc++中读取包含uxxxx的文件)
                  stack overflow error in C++ program(C++程序中的堆栈溢出错误)
                  • <bdo id='gIY44'></bdo><ul id='gIY44'></ul>

                        <legend id='gIY44'><style id='gIY44'><dir id='gIY44'><q id='gIY44'></q></dir></style></legend>
                      1. <i id='gIY44'><tr id='gIY44'><dt id='gIY44'><q id='gIY44'><span id='gIY44'><b id='gIY44'><form id='gIY44'><ins id='gIY44'></ins><ul id='gIY44'></ul><sub id='gIY44'></sub></form><legend id='gIY44'></legend><bdo id='gIY44'><pre id='gIY44'><center id='gIY44'></center></pre></bdo></b><th id='gIY44'></th></span></q></dt></tr></i><div id='gIY44'><tfoot id='gIY44'></tfoot><dl id='gIY44'><fieldset id='gIY44'></fieldset></dl></div>

                        <small id='gIY44'></small><noframes id='gIY44'>

                          • <tfoot id='gIY44'></tfoot>
                              <tbody id='gIY44'></tbody>