我是 Linux 编程新手,我正在尝试使用 Tesseract 在 Ubuntu 12.10
上创建一个 OCR 应用程序和 OpenCV .到目前为止,我已经在 linux 上设置了 tesseract
和 OpenCV
我也遵循了这个 tutorial ,在本教程中,我发现创建一个文件 CMakeList.txt
并在其中链接 OpenCV 非常容易。
现在我正在尝试用 this code 编译 tesseract-ocr
库.据我所知,我没有在 tesseract-ocr
和我的代码之间建立链接,这就是我出错的原因。
我想要和搜索的是,如果可能的话,我是否可以在一个文件中使用 CMake
链接 Tesseract
和 OpenCV
。教程会很好,因为我是 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/