Ask Your Question
2

Error building opencv extra modules in CMake on Win10

asked 2017-07-07 19:09:32 -0600

I rarely ask questions, I like the puzzle of solving things myself, but this one has had me stumped for two weeks and I am going in circles!

I'll put the short question first and give the detail of what I have tried below.

I am trying to compile 'webcam_demo.cpp' for character recognition but have encountered a chain of errors, I have fixed all but one.. the root cause.

When generating the opencv + extra modules project in CMake I get the following error; "WARNING: Target "opencv_text" requests linking to directory "C:/Program Files/Tesseract-OCR/lib/". Targets may link only to libraries. CMake is dropping the item." If I ignore the error and continue to build the project I get a similar error in VS2017.

Due to technical limitations of Win Vista and VS2010, I recently upgraded to Windows 10 32bit and Visual Studio 2017.

I installed opencv-3.2.0-vc14, opened webcam_demo.cpp in VS2017 and found a list of include errors, google to the rescue.. ish (due to numerous similar but different issues on google it took a few attempts to resolve each issue in turn getting a step closer until I pieced together the following from fresh)

Installed VS2017.
Installed CMake 3.9.0-rc5 win32 x86 (win installer).
Installed Tesseract 3.02.02 including dev files (win installer) (the installer skipped some additional downloads as no longer available, so I sourced the missing .h files from a backup and put them in the correct location).
Downloaded opencv_contrib-3.2.0.zip.
Downloaded opencv-3.2.0.zip.
Created folders C:\opencv\opencv-3.2.0\; C:\opencv\opencv_contrib-3.2.0\; C:\opencv\opencv32build.
Extracted the source files into the respective directories.
Checked "C:\Program Files\Tesseract-OCR" was in the Windows/system/environment variables/path.

If you are with me this far, well done :)

Opened CMake GUI, filled in the Source and Build directories.
Hit Configure.
In the freshly populated Variables List I then entered paths for; "CMake_install_prefix", "Executable_output_path", "Lept_library", "Opencv_config_file_include_dir", "Opencv_extra_modules_path", "Tesseract_incude_dir", "Tesseract_library", and some Python directories.
Hit Configure.
"Configure done" no warnings, Tesseract = YES.

Great so far I thought...

Hit Generate and I received the following error (six times in a row); "WARNING: Target "opencv_text" requests linking to directory "C:/Program Files/Tesseract-OCR/lib/". Targets may link only to libraries. CMake is dropping the item."

Having read through the CMakeCache.txt in my build folder I found an oddity that I had not noticed in the CMake configure output text, looking at CMake again I found the variable for extra dependencies read; "Extra dependencies: comctl32 gdi32 ole32 setupapi ws2_32 vfw32 C:/Program Files/Tesseract-OCR/lib/"

Is the reference to the Tesseract Lib folder the issue? should it refer to a specific .lib file instead?
I have not found this answer anywhere, nor have I found a way to change this reference.

Is there and error in the opencv_text CMakeLists.txt?
set(the_description "Text Detection and Recognition") ocv_define_module(text opencv_ml opencv_imgproc opencv_core opencv_features2d OPTIONAL opencv_highgui WRAP python) if(NOT CMAKE_CROSSCOMPILING ...
(more)

edit retag flag offensive close merge delete

Comments

it seems to want the path to the tesseract libs, not to the containing folder only. so something like:

C:/Program Files/Tesseract-OCR/lib/leptsomething.lib
berak gravatar imageberak ( 2017-07-08 02:22:35 -0600 )edit

Can you tell me please How did you install tesseract 3.02.02 using win installer? @SmegsALot

SarahM gravatar imageSarahM ( 2017-08-10 09:57:30 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2017-07-08 14:23:48 -0600

updated 2017-07-09 17:24:47 -0600

Thank you Berak, the obvious was right in front of my eyes, where 'include' was asking for a directory I thought the same for the lib directory, what was needed was just one specific library file.

Unlike the CMake configuration value for the 'Include' path that points to a directory, the path for the 'Tesseract Library' and Lept Library' must point to specific .lib files as below;

Tesseract_INCLUDE_DIR = C:\Program Files\Tesseract-OCR\include\

Lept_LIBRARY = C:\Program Files\Tesseract-OCR\lib\liblept168.lib

Tesseract_LIBRARY = C:\Program Files\Tesseract-OCR\lib\libtesseract302.lib

You may need to change the path if you have not used the default installation location for Tesseract, you may also need to change the version number part of the .lib files if you have installed a different version.

If you are unable to find the .lib files you may need to install Tesseract with the 'Developer files' option selected, or download them separately.

Ensuring these three paths are populated in the configuration may also help resolve the 'Tesseract = NO' issue that can occur if any one of these three paths are not populated.

/Mike

edit flag offensive delete link more

Comments

How do you build leptonica ?

LBerger gravatar imageLBerger ( 2017-07-12 03:47:19 -0600 )edit
1

I downloaded Tesseract 3.02.02, windows installer version and extra files from here link text The two files are "tesseract-ocr-setup-3.02.02.exe" and "tesseract-3.02.02-win32-lib-include-dirs.zip" First run the .exe, during installation when given options, tick the box for developer files; these include Leptonica source files. Once the install has finished, unzip the .zip file and copy the contents to the matching Tesseract installation directory. Some of the files will be the same but some will be extra source files. That will be Tesseract and source files for Tesseract and Leptonica on your system. There are lots of videos on youtube and guides on google for how to use CMake to build opencv with extra modules inc Tess and Lept

SmegsALot gravatar imageSmegsALot ( 2017-07-12 17:20:49 -0600 )edit
1

Alternatively, the Leptonica files are available separately from link text The source files include Headers, Libraries and pre built .dll files. Instructions for building and using Leptonica can be found here link text Happy reading :)

SmegsALot gravatar imageSmegsALot ( 2017-07-12 17:27:47 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2017-07-07 19:09:32 -0600

Seen: 1,575 times

Last updated: Jul 09 '17