Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake for Tesseract and OpenCV

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

like image 297
Muaz Usmani Avatar asked Jan 23 '26 11:01

Muaz Usmani


1 Answers

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.

like image 151
Yantao Xie Avatar answered Jan 25 '26 00:01

Yantao Xie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!