Need help building Tesseract for OpenCv, Where are the include files?

41 views
Skip to first unread message

Mich Po

unread,
Oct 3, 2018, 3:28:51 PM10/3/18
to tesseract-ocr

I'm trying to build OpenCV with the Tesseract OCR module to use on a raspberry pi.

There is very little information online on how to build this, and what is available is very incomplete.

I'm building using Visual Studio 2017 on windows 10 using the VisualGDB plugin for cross compilation.


I tried downloading and building Tesseract I cloned https://github.com/tesseract-ocr/tess...

But there is no include folder anywhere int he sources. There is an src folder that contains headers and source files, but no include folder anywhere.

Do I need to build tesseract first? And when its built, it creates lib and include files?

I tried to build tesseract, but it required leptonica. I was able to build leptonica. but I cannot manage to include it in the Tesseract cmake.

I added the lines 

add_subdirectory(${CMAKE_SOURCE_DIR}/../leptonica) 

add_subdirectory(${CMAKE_SOURCE_DIR}/../leptonica/build) 

find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED CONFIG)

But I'm getting errors: 

add_subdirectory not given a binary directory but the given source C:\opencv\tesseract\CMakeLists.txt 

Could not find a package configuration file provided by "Leptonica" C:\opencv\tesseract\CMakeLists.txt



My directory structure is as follows: 


Tesseract git repository located in  C:\opencv\tesseract

Tesseract build directory  C:\opencv\tesseract\build

Leptonica repository located in  C:\opencv\leptonica

Leptonica build directory in  C:\opencv\leptonica\build (contains LeptonicaConfig.cmake, 

Leptonica library files, (libleptonica.so, libleptonica.so.1.77.0, libleptonica.so.5.3.0) are in C:\opencv\leptonica\build\src



Can anyone please help me figure out what lines I need to add to the CMakeLists.txt for Tesseract or Leptonica in order to get Tesseract to build correctly? 

Or any other files I need to edit?


Do I need to install anything else to build? I'm trying to avoid using pkg-config or anything else that will make it more complicated.


Thank you,



Shree Devi Kumar

unread,
Oct 3, 2018, 3:37:50 PM10/3/18
to tesser...@googlegroups.com, Egor Pugin

--
You received this message because you are subscribed to the Google Groups "tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-oc...@googlegroups.com.
To post to this group, send email to tesser...@googlegroups.com.
Visit this group at https://groups.google.com/group/tesseract-ocr.
To view this discussion on the web visit https://groups.google.com/d/msgid/tesseract-ocr/73780003-f81b-4bfa-9975-d32c68d2f8dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

____________________________________________________________
भजन - कीर्तन - आरती @ http://bhajans.ramparivar.com

Mich Po

unread,
Oct 3, 2018, 4:20:43 PM10/3/18
to tesseract-ocr
Yes, that's what I was describing in the body of my question:

I added these lines to Tesseract CMakeLists.txt

add_subdirectory(${CMAKE_SOURCE_DIR}/../leptonica) 

add_subdirectory(${CMAKE_SOURCE_DIR}/../leptonica/build) 

find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED CONFIG)

Inside CMakeLists.txt I see the lines: 

if(NOT EXISTS ${PROJECT_SOURCE_DIR}/.cppan)
    if (NOT Leptonica_DIR AND NOT MSVC)
        find_package(PkgConfig REQUIRED)
        pkg_check_modules(Leptonica REQUIRED lept>=${MINIMUM_LEPTONICA_VERSION})
        link_directories(${Leptonica_LIBRARY_DIRS})
    else()

        find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED CONFIG)
    endif()
else()
    if (STATIC)
        set(CPPAN_BUILD_SHARED_LIBS 0)
    else()
        set(CPPAN_BUILD_SHARED_LIBS 1)
    endif()
    add_subdirectory(.cppan)
endif()


I'm trying to build without using cppan and pkg-config. I never used these tools before, and I know they will create more problems, especially when cross-compiling.
I'm trying to just use the existing CMake find-package function. It should work since its already part of the if-else block.

        find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED CONFIG)
 
So I commented the entire block above out and included just the  find_package line.


Again, there are no instructions anywhere, and I'm not trained to use CMake, cppan, or pkg-config in school. 

I need to know the exact thing I need to add to the CMakeLists.txt for Tesseract in order to build with Leptonica, (Or without if that's even possible) so that I can use it in open-cv.

I've been reading cmake documentation https://cmake.org/cmake-tutorial/  but it doesn't help me with these two specific programs. 
There must be only 1 or 2 lines I need to add in order to compile it, and since creators of Tesseract designed it to require Leptonica, they must know what it is missing.,

Thank you,
Reply all
Reply to author
Forward
0 new messages