问题描述
我是新的Linux编程,我正在尝试使用和 。到目前为止我已经设置 tesseract
和 OpenCV
在linux上我也跟着这,在本教程中,我发现很容易,我们创建一个文件 CMakeList .txt
并链接OpenCV。
现在我试图编译 tesseract-ocr
图书馆与。因为我知道我没有在 tesseract-ocr
和我的代码之间的链接,这就是为什么我有错误。
我想要并搜索的是如果我可以链接 Tesseract
和 OpenCV
在一个文件中使用
CMake
(如果可能)。一个教程将是好的,因为我是Linux的全新。提前感谢
解决方案
我这样写了一个 CMakeLists.txt b
cmake_minimum_required(VERSION 2.6)
project(test-ocr)
#添加tesseract的包含目录
#,请替换为你的dir。
include_directories(/ home / ytxie / include)
#添加tesseract库
#的搜索目录,请替换为您的目录。
link_directories(/ home / ytxie / lib)
add_executable(test-ocr test.cpp)
#链接leptonica库和tesseract库
target_link_libraries(test-ocr lept tesseract)
我添加了评论,看起来很容易理解。 test.cpp 只是。
如果您要将OpenCV相关设置添加到此cmake文件中,只需添加它们即可。如果有些混乱的事情,请阅读。
注意:要使 test-ocr 成功运行,您应该下载,并将其内容复制到 / share / tessdata p>
I am new to Linux programming, I am trying create an OCR application on Ubuntu 12.10
using Tesseract and OpenCV. So far I have setup tesseract
and OpenCV
on linux also I have followed this tutorial, in this tutorial I found it very easy that we create one file CMakeList.txt
and link OpenCV in it.
Now I am trying to compile tesseract-ocr
library with this code. As I know I did not make a link between tesseract-ocr
and my code and thats why I am having errors.
All I want and searching for is if I can link Tesseract
and OpenCV
using CMake
in one file, if it is possible. A tutorial would be good as I am totally new to Linux. Thanks in advance
解决方案 I wrote a CMakeLists.txt like this
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)
I've add comments and it seems easy to understand. The test.cpp is just the that example code.
And if you want to add OpenCV relating setting into this cmake file, just add them. If there are some confusing things please read the CMake's document.
NOTE: to make the test-ocr run successfully, you should download the English data and copy it's content into the /share/tessdata.
这篇关于CMake为Tesseract和OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!