【发布时间】:2018-06-20 15:00:28
【问题描述】:
我的设置:目前我在 Windows 10 上的 Visual Studio 2017 中使用 c++。
目标:开始在我的基本 c++ 应用程序中使用 tesseract ocr。首先,为了确保我能够#include tesseract 库并编译和执行一个非常简单的程序,我正在尝试运行官方tesseract project's "APIExample" page 上提供的下面的简单测试程序。
到目前为止我所做的事情:按照this stack overflow answer 的建议,我在命令提示符下运行了vcpkg install tesseract:x64-windows 命令以及命令.\vcpkg integrate install。当我运行命令vcpkg list 时,我看到了我安装的所有包(如下图所示),但是尽管 Visual Studio 中的这种智能感知给了我错误,说它找不到运行上述测试项目的代码的包含我已经在下面发布了。是什么赋予了?我在下面提供了我的 Visual Studio 设置的屏幕截图,其中包含生成的错误和错误代码以供参考。
#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.\n");
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:\n%s", outText);
// Destroy used object and release memory
api->End();
delete[] outText;
pixDestroy(&image);
return 0;
}
【问题讨论】:
标签: c++ package installation tesseract vcpkg