CMake for Tesseract and OpenCV

2019-05-10 06:15发布

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

1条回答
爷的心禁止访问
2楼-- · 2019-05-10 06:23

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.

查看更多
登录 后发表回答