为 Android Studio 编译 Tesseract OCR 库

Compiling Tesseract OCR library for Android Studio

我仍然对如何构建一个使用 Tesseract OCR 的工作 tess-two Android Studio 项目感到困惑,尽管上面有几篇文章。有一个可用的预构建版本,其 "ReadMe" 的 "Usage" 部分说我们可以通过简单地将 tess-two 添加为外部依赖项来完成此操作,只需将以下行添加到 dependencies 我们应用的部分 build.gradle:

compile 'com.rmtheis:tess-two:6.0.3'

我明白这告诉 Android Studio 从发布它的远程 Maven 存储库中获取库的预构建版本,但是我们仍然是否需要将我们下载的tess-two目录的内容复制到我们全新的Android Studio项目中或克隆?

请看附件图片:我的新空白AndroidStudio项目叫做TessAndroid。在其他地方,我在下载 zip 文件后保存了完整的 tess-two 内容。除了添加到我的应用 build.gradledependencies 部分的 compile 行之外,我 是否必须复制 tess-two 文件夹(或其中的某些部分)到我的主应用程序的根目录中?

In addition to the compile line added to the dependencies section of my app's build.gradle, do I also have to copy the tess-two folder (or some parts of it) into my main app's root directory?

没有。通过将 compile 行添加到 build.gradle,您将该库代码的编译版本导入到您的项目中,并且无需将其源代码也复制到您的项目中。

您可以自己确认这一点,方法是在 Android Studio 中创建一个新项目,将库的 compile 行添加到新应用程序的 build.gradle,然后添加一行引用库中 class 的新 activity 的 onCreate 方法的代码:

TessBaseAPI baseApi = new TessBaseAPI();

将在您的项目中找到并使用 class。