c++ - 用于 Tesseract 和 OpenCV 的 CMake

标签 c++ linux opencv cmake tesseract

我是 Linux 编程新手,我正在尝试使用 TesseractUbuntu 12.10 上创建一个 OCR 应用程序和 OpenCV .到目前为止,我已经在 linux 上设置了 tesseractOpenCV 我也遵循了这个 tutorial ,在本教程中,我发现创建一个文件 CMakeList.txt 并在其中链接 OpenCV 非常容易。

现在我正在尝试用 this code 编译 tesseract-ocr 库.据我所知,我没有在 tesseract-ocr 和我的代码之间建立链接,这就是我出错的原因。

我想要和搜索的是,如果可能的话,我是否可以在一个文件中使用 CMake 链接 TesseractOpenCV。教程会很好,因为我是 Linux 的新手。提前致谢

最佳答案

我像这样写了一个 CMakeLists.txt

cmake_minimum_required (VERSION 2.6)
project (test-ocr)

# Add the including directory of the tesseract 
# and please replace with your dir.
include_directories (/home/ytxie/include)
# Add the search directory for the tesseract library 
# and please replace with your dir.
link_directories (/home/ytxie/lib)

add_executable (test-ocr test.cpp)

# link the leptonica library and the tesseract library
target_link_libraries (test-ocr lept tesseract)

我已经添加了注释,看起来很容易理解。 test.cpp 就是 that example code .

如果你想将 OpenCV 相关设置添加到这个 cmake 文件中,只需添加它们即可。如果有一些令人困惑的事情,请阅读 CMake's document .

注意:要使 test-ocr 成功运行,您应该下载 English data并将其内容复制到 /share/tessdata

关于c++ - 用于 Tesseract 和 OpenCV 的 CMake,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20382549/

相关文章:

linux - 执行bash脚本时如何显示行号

c# - 凸包中的最远点

c++ - 在哪里可以找到 C++ DNS 库?

c++ - 在 C++ 中构造数组元素在循环中调用 new 而不是 new[] 是否合法?

c++ - C++ STL 中的 find() 用法

c++ - 使用 OpenCV 和 C++ 测量模糊图像

c++ - 无法在 Linux 上构建 opencv_contrib 模块

python - 如何将 SwigPyObject 转换为 ctypes void*

linux - 在具有多个(物理)CPU 的系统上的多线程进程中,如何处理线程调度?

c - Linux 字符设备驱动程序如何检测使用它的程序何时异常退出?