如何在 C++ 控制台应用程序 Visual Studio 2022 中使用 Tesseract 作为 Nuget 包

问题描述 投票:0回答:1

我的目标是使用 C++ 中的 Tesseract 和 VStudio 2022 中的 Nuget 包从输入图像中提取数字和文本。

我下载了 tesseract 5.2.0(右键单击项目 -> 管理 Nuget 包 -> 浏览)作为 Nuget 包 5.2.0

但是当我将超正方体包含为:

#include <iostream>
#include <tesseract/baseapi.h>
#include <leptonica/allheaders.h>


int main() {
    tesseract::TessBaseAPI* api = new tesseract::TessBaseAPI();
    if (api->Init(nullptr, "eng")) {
        fprintf(stderr, "Could not initialize Tesseract.\n");
        exit(1);
    }

    // Open an image 
    Pix* image = pixRead("D:/tools/img.png");
    api->SetImage(image);

    // Perform OCR
    char* outText = api->GetUTF8Text();
    std::cout << "OCR Output:\n" << outText << std::endl;

    // Release resources
    api->End();
    delete[] outText;
    pixDestroy(&image);

    return 0;
}

它给了我这些错误。

我还阅读了THIS并安装了运行时64,但没有工作。

有谁知道如何使用 tesseract 与 C++ 作为 Nuget 包或任何解决方法。

c++ visual-studio nuget ocr tesseract
1个回答
0
投票

这是因为您使用的软件包不支持本机/C++代码,您可以在此处查看NuGet库中的软件包Tesseract页面:

宇宙立方

对于支持本机/C++ 的包,这是一个示例:

Microsoft.Web.WebView2

您可以下载它们并查看所有它们,您尝试使用的第一个包是.Net 环境的经典 NuGet 包(Nuget 包通常这样做。)。

如您所见,Tesseract 包的内容不包含 .h 文件。这就是为什么你无法在你的 C++ 项目中引用它。

从NuGet Gallery中,我们还可以得到这样的信息:

宇宙立方:

Microsoft.Web.WebView2

© www.soinside.com 2019 - 2024. All rights reserved.