Tesseract to detect numbers with opencv (c++) and cmake on a raspberry pi

650 views
Skip to first unread message

Adam Richards

unread,
Sep 22, 2018, 2:50:01 AM9/22/18
to tesseract-ocr
Hi I want to use Tesseract to detect numbers in a sudoku puzzle. I already have all my opencv c++ code that will produce a Mat for every cell with a number in it, to run this I am using Cmake to generate the code. 

I was just wondering how I can install, setup and use tesseract to read the numbers from each cell within this c++ code, as I can only work out how to run it from the command line.

Zdenko Podobny

unread,
Sep 22, 2018, 3:05:07 AM9/22/18
to tesser...@googlegroups.com
Have a look at wiki APIExample.
And tesseract / tesseractmain.cpp is just example how to use tesseract library... Tesseract is also possible to build with cmake, so all you need is just to have a look at the code...

Zdenko


so 22. 9. 2018 o 8:49 Adam Richards <ajrich...@gmail.com> napísal(a):
Hi I want to use Tesseract to detect numbers in a sudoku puzzle. I already have all my opencv c++ code that will produce a Mat for every cell with a number in it, to run this I am using Cmake to generate the code. 

I was just wondering how I can install, setup and use tesseract to read the numbers from each cell within this c++ code, as I can only work out how to run it from the command line.

--
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/93a0d413-f0a2-41c4-8944-67c61b0a784f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Adam Richards

unread,
Sep 22, 2018, 9:23:28 AM9/22/18
to tesseract-ocr
I have managed to run the basic API example from the command line, however I am now trying to incorporate it into my project. 
I have added these lines to my CMakeLists.txt file:

find_package( Tesseract 3.04.01 REQUIRED )
include_directories(${Tesseract_INCLUDE_DIRS})
target_link_libraries(image ${Tesseract_LIBRARIES})

And when I try and make it I get this error:

"CMake Error at CMakeLists.txt:7 (find_package):
  Could not find a package configuration file provided by "Tesseract" with
  any of the following names:

    TesseractConfig.cmake
    tesseract-config.cmake

  Add the installation prefix of "Tesseract" to CMAKE_PREFIX_PATH or set
  "Tesseract_DIR" to a directory containing one of the above files.  If
  "Tesseract" provides a separate development package or SDK, be sure it has
  been installed."

Should there be something else I have to install or do to make this work?

Adam Richards

unread,
Sep 22, 2018, 9:23:28 AM9/22/18
to tesseract-ocr
Thank you Zdenko,

I am not overly familiar with how cmake works in compiling everything, I followed through these steps: https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html and this tutorial: https://www.youtube.com/watch?v=LglRKc2nGeY   to get everything working with opencv. However I am not exactly sure how to integrate in Tesseract with the same cmake commands.
Is there any useful tutorials or examples on how to use Tesseract with cmake?



On Saturday, September 22, 2018 at 5:05:07 PM UTC+10, zdenop wrote:

Zdenko Podobny

unread,
Sep 22, 2018, 9:48:13 AM9/22/18
to tesser...@googlegroups.com
How did you install tesseract?

Zdenko


so 22. 9. 2018 o 15:23 Adam Richards <ajrich...@gmail.com> napísal(a):

Adam Richards

unread,
Sep 22, 2018, 8:06:56 PM9/22/18
to tesseract-ocr
Pretty sure I installed with just these commands:
sudo apt install tesseract-ocr
sudo apt install libtesseract-dev
When I check the tesseract -v I get this:
tesseract 3.04.01
 leptonica-1.74.1
  libgif 5.1.4 : libjpeg 6b (libjpeg-turbo 1.5.1) : libpng 1.6.28 : libtiff 4.0.8 : zlib 1.2.8 : libwebp 0.5.2 : libopenjp2 2.1.2

Zdenko Podobny

unread,
Sep 23, 2018, 11:00:49 AM9/23/18
to tesser...@googlegroups.com
Can you check if TesseractConfig.cmake macros are included in these packages? 

Zdenko


ne 23. 9. 2018 o 2:06 Adam Richards <ajrich...@gmail.com> napísal(a):

Adam Richards

unread,
Sep 23, 2018, 6:24:32 PM9/23/18
to tesseract-ocr
I did a search on the Pi and it couldn't find A TesseractConfig.cmake file anywhere.

Where should it be exactly?

Should it automatocally come with Tesseract or do I need to download or add it?

Zdenko Podobny

unread,
Sep 24, 2018, 2:46:05 AM9/24/18
to tesser...@googlegroups.com
This means that your tesseract packages were build with autotools and they did not includes cmake support.
So you need to set your Tesseract_INCLUDE_DIRS and Tesseract_LIBRARIES manually...

Zdenko


po 24. 9. 2018 o 0:24 Adam Richards <ajrich...@gmail.com> napísal(a):
I did a search on the Pi and it couldn't find A TesseractConfig.cmake file anywhere.

Where should it be exactly?

Should it automatocally come with Tesseract or do I need to download or add it?

--
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.

Adam Richards

unread,
Sep 24, 2018, 2:56:06 AM9/24/18
to tesseract-ocr
Thank you Zdenko,

How exactly would I do this? Is it just entering the directory directly into the cmakelists.txt file?

Is there an easy way to find the location of these directories?

Adam Richards

unread,
Sep 26, 2018, 8:38:42 AM9/26/18
to tesseract-ocr
Hi Zdenko,

Sorry, I'm just still unsure how exactly to get this working? What should I be doing to set my Tesseract_INCLUDE_DIRS and Tesseract_LIBRARIES manually...

Any further help you could provide would be appreciated,

thanks,
Adam

Zdenko Podobny

unread,
Sep 26, 2018, 9:45:23 AM9/26/18
to tesser...@googlegroups.com
Just goole for help. There are plenty examples. e.g.

Zdenko


st 26. 9. 2018 o 14:38 Adam Richards <ajrich...@gmail.com> napísal(a):
Reply all
Reply to author
Forward
0 new messages