在Windows 10上为C ++安装tesseract [英] Install tesseract for C++ on Windows 10

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

问题描述

在安装tesseract以在Windows 10上用C ++开发时遇到了问题.

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

任何人都可以提供以下指南:
1. Leptonica(tesseract要求)lib,包括
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.\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;
}

推荐答案

安装vcpkg(MS打包程序以安装基于Windows的开源项目),并使用.\vcpkg install tesseract:x64-windows-static这样的powershell命令.像Leptonica这样的依赖库将自动为您安装.可以使用.\vcpkg integrate install.

Install vcpkg ( MS packager to install windows based open source projects) and use powershell command like so .\vcpkg install tesseract:x64-windows-static. Dependency libraries like Leptonica will be auto installed for you. The tesseract can be auto integrated to your VS project using .\vcpkg integrate install.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆