Skip to content

Commit 6848eb6

Browse files
LaurentBergeralalek
authored andcommitted
Merge pull request #1361 from LaurentBerger:TesseractInstall
How to install tesseract on windows (#1361)
1 parent a43864f commit 6848eb6

File tree

2 files changed

+126
-0
lines changed

2 files changed

+126
-0
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
Tesseract (master) installation by using git-bash (version>=2.14.1) and cmake (version >=3.9.1){#tutorial_install_tesseract}
2+
===============================================================
3+
4+
-# We assume you installed opencv and opencv_contrib in c:/lib using [this tutorials](http://docs.opencv.org/master/d3/d52/tutorial_windows_install.html#tutorial_windows_gitbash_build]
5+
6+
-# You must download [png lib](https://sourceforge.net/projects/libpng/files/libpng16/1.6.32/lpng1632.zip/download) and [zlib](https://sourceforge.net/projects/libpng/files/zlib/1.2.11/zlib1211.zip/download).
7+
Uncompress lpngx.y.zz in folder lpng and zlib in folder zlib. lpng and zlib must be in same folder as opencv and opencv_contrib.
8+
save this script with name installpngzlib.sh in c:/lib
9+
@code{.bash}
10+
#!/bin/bash
11+
myRepo=$(pwd)
12+
CMAKE_CONFIG_GENERATOR="Visual Studio 14 2015 Win64"
13+
RepoSource=zlib
14+
mkdir Build/$RepoSource
15+
pushd Build/$RepoSource
16+
cmake . -G"Visual Studio 14 2015 Win64" \
17+
-DCMAKE_INSTALL_PREFIX:PATH="$myRepo"/install/zlib -DINSTALL_BIN_DIR:PATH="$myRepo"/install/zlib/bin \
18+
-DINSTALL_INC_DIR:PATH="$myRepo"/install/zlib/include -DINSTALL_LIB_DIR:PATH="$myRepo"/install/zlib/lib "$myRepo"/"$RepoSource"
19+
cmake --build . --config release
20+
cmake --build . --target install --config release
21+
cmake --build . --config debug
22+
cmake --build . --target install --config debug
23+
popd
24+
RepoSource=lpng
25+
mkdir Build/$RepoSource
26+
pushd Build/$RepoSource
27+
cp "$myRepo"/"$RepoSource"/scripts/pnglibconf.h.prebuilt "$myRepo"/"$RepoSource"/pnglibconf.h
28+
cmake . -G"Visual Studio 14 2015 Win64" \
29+
-DZLIB_INCLUDE_DIR:PATH="$myRepo"/install/zlib/include -DZLIB_LIBRARY_DEBUG:FILE="$myRepo"/install/zlib/lib/zlibstaticd.lib \
30+
-Dld-version-script:BOOL=OFF -DPNG_TESTS:BOOL=OFF -DAWK:STRING= \
31+
-DZLIB_LIBRARY_RELEASE:FILE="$myRepo"/install/zlib/lib/zlibstatic.lib -DCMAKE_INSTALL_PREFIX="$myRepo"/Install/"$RepoSource" \
32+
"$myRepo"/"$RepoSource"
33+
cmake --build . --config release
34+
cmake --build . --target install --config release
35+
cmake --build . --config debug
36+
cmake --build . --target install --config debug
37+
popd
38+
@endcode
39+
-# In git command line enter the following command :
40+
@code{.bash}
41+
./installpngzlib.sh
42+
@endcode
43+
44+
-# save this script with name installTesseract.sh in c:/lib
45+
@code{.bash}
46+
#!/bin/bash
47+
function MAJGitRepo
48+
{
49+
if [ ! -d "$myRepo/$1" ]; then
50+
echo "clonning ${1}"
51+
git clone $2
52+
mkdir Build/$1
53+
else
54+
echo "update $1"
55+
cd $1
56+
git pull --rebase
57+
cd ..
58+
fi
59+
}
60+
echo "Installing leptonica and tesseract"
61+
myRepo=$(pwd)
62+
CMAKE_CONFIG_GENERATOR="Visual Studio 14 2015 Win64"
63+
64+
MAJGitRepo leptonica https://github.com/DanBloomberg/leptonica.git
65+
RepoSource=leptonica
66+
pushd Build/$RepoSource
67+
cmake -G"$CMAKE_CONFIG_GENERATOR" -DCMAKE_INSTALL_PREFIX="$myRepo"/Install/leptonica "$myRepo/$RepoSource"
68+
echo "************************* $Source_DIR -->debug"
69+
cmake --build . --config release
70+
cmake --build $RepoSource --target install --config release
71+
popd
72+
73+
RepoSource=tesseract
74+
MAJGitRepo $RepoSource https://github.com/tesseract-ocr/tesseract.git
75+
pushd Build/$RepoSource
76+
cmake -G"$CMAKE_CONFIG_GENERATOR" -DBUILD_TRAINING_TOOLS:BOOL=OFF -DCMAKE_INSTALL_PREFIX="$myRepo"/Install/tesseract -DLeptonica_DIR:PATH="$myRepo"/Install/leptonica/cmake -DPKG_CONFIG_EXECUTABLE:BOOL=OFF "$myRepo"/"$RepoSource"
77+
echo "************************* $Source_DIR -->release"
78+
cmake --build . --config release
79+
cmake --build . --target install --config release
80+
81+
popd
82+
RepoSource=opencv
83+
pushd Build/$RepoSource
84+
CMAKE_OPTIONS='-DBUILD_PERF_TESTS:BOOL=OFF -DBUILD_TESTS:BOOL=OFF -DBUILD_DOCS:BOOL=OFF -DWITH_CUDA:BOOL=OFF'
85+
cmake -G"$CMAKE_CONFIG_GENERATOR" \
86+
-DTesseract_INCLUDE_DIR:PATH="${myRepo}"/Install/tesseract/include -DTesseract_LIBRARY="${myRepo}"/Install/tesseract/lib/tesseract400.lib -DLept_LIBRARY="${myRepo}"/Install/leptonica/lib/leptonica-1.74.4.lib \
87+
$CMAKE_OPTIONS -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
88+
-DINSTALL_CREATE_DISTRIB=ON -DCMAKE_INSTALL_PREFIX="$myRepo"/install/"$RepoSource" "$myRepo/$RepoSource"
89+
echo "************************* $Source_DIR -->devenv debug"
90+
cmake --build . --config debug
91+
echo "************************* $Source_DIR -->devenv release"
92+
cmake --build . --config release
93+
cmake --build . --target install --config release
94+
cmake --build . --target install --config debug
95+
popd
96+
97+
@endcode
98+
In this script I suppose you use VS 2015 in 64 bits
99+
@code{.bash}
100+
CMAKE_CONFIG_GENERATOR="Visual Studio 14 2015 Win64"
101+
@endcode
102+
and leptonica, tesseract will be installed in c:/lib/install
103+
@code{.bash}
104+
-DCMAKE_INSTALL_PREFIX="$myRepo"/install/"$RepoSource" "$myRepo/$RepoSource"
105+
@endcode
106+
with no Perf tests, no tests, no doc, no CUDA and no example
107+
@code{.bash}
108+
CMAKE_OPTIONS='-DBUILD_PERF_TESTS:BOOL=OFF -DBUILD_TESTS:BOOL=OFF -DBUILD_DOCS:BOOL=OFF -DWITH_CUDA:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF'
109+
@endcode
110+
-# In git command line enter the following command :
111+
@code{.bash}
112+
./installTesseract.sh
113+
@endcode
114+
-# now we need the language files from tesseract. either clone https://github.com/tesseract-ocr/tessdata, or copy only those language files you need to a folder (example c:\\lib\\install\\tesseract\\tessdata). If you don't want to add a new folder you must copy language file in same folder than your executable
115+
-# if you created a new folder, then you must add a new variable, TESSDATA_PREFIX with the value c:\\lib\\install\\tessdata to your system's environment
116+
-# add c:\\Lib\\install\\leptonica\\bin and c:\\Lib\\install\\tesseract\\bin to your PATH environment. If you don't want to modify the PATH then copy tesseract400.dll and leptonica-1.74.4.dll to the same folder than your exe file.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Text module {#tutorial_table_of_content_text}
2+
=====================
3+
4+
- @subpage tutorial_install_tesseract
5+
6+
*Compatibility:* \> OpenCV 3.4
7+
8+
*Author:* Laurent Berger
9+
10+
Instructions in order to properly setup tesseract on windows for the text module.

0 commit comments

Comments
 (0)