forked from shelfio/aws-lambda-tesseract
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile-tesseract.sh
66 lines (54 loc) · 1.67 KB
/
compile-tesseract.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
# install basic stuff required for compilation
sudo yum-config-manager --enable epel
sudo yum install -y aclocal autoconf automake cmakegcc freetype-devel gcc gcc-c++ \
git lcms2-devel libjpeg-devel libjpeg-turbo-devel autogen autoconf libtool \
libpng-devel libtiff-devel libtool libwebp-devel libzip-devel make zlib-devel
sudo yum groupinstall "Development Tools" -y
# autoconf
cd ~
wget http://babyname.tips/mirrors/gnu/autoconf-archive/autoconf-archive-2017.09.28.tar.xz
tar -xvf autoconf-archive-2017.09.28.tar.xz
cd autoconf-archive-2017.09.28
./configure && make && sudo make install
sudo cp m4/* /usr/share/aclocal/cd ~ wget http://babynam
# leptonica
cd ~
git clone https://github.com/DanBloomberg/leptonica.git
cd leptonica/
./autogen.sh
./configure
make
sudo make install
# tesseract
cd ~
git clone https://github.com/tesseract-ocr/tesseract.git
cd tesseract
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
./autogen.sh
./configure
make
sudo make install
cd ~
mkdir tesseract-standalone
# trim unneeded ~ 15 MB
strip ./tesseract-standalone/**/*
# copy files
cd tesseract-standalone
cp /usr/local/bin/tesseract .
mkdir lib
cp /usr/local/lib/libtesseract.so.4 lib/
cp /usr/local/lib/liblept.so.5 lib/
cp /usr/lib64/libjpeg.so.62 lib/
cp /usr/lib64/libwebp.so.4 lib/
cp /usr/lib64/libstdc++.so.6 lib/
# copy training data
mkdir tessdata
cd tessdata
wget https://github.com/tesseract-ocr/tessdata_fast/raw/master/eng.traineddata
# archive
cd ~
tar -zcvf tesseract.tar.gz tesseract-standalone
# download from EC2 to local machine
scp [email protected]:/home/ec2-user/tesseract.tar.gz $(pwd)
# run compress-with-brotli.sh on local machine now