首先可以通过 官网github 安装,自己源码编译,不过需要安装各种依赖,也容易出错,这里使用官方包管理器 yum
简化操作。
yum 本身自带的版本是 版本 3 ,过于老旧,很多 API 接口都不试用
[root@iZbp115r5t4hzamv0snvm1Z cim]# tesseract -v
tesseract 3.04.00
leptonica-1.72
libgif 4.1.6(?) : libjpeg 6b (libjpeg-turbo 1.2.90) : libpng 1.5.13 : libtiff 4.0.3 : zlib 1.2.7 : libwebp 0.3.0
所以通过切换仓库,安装 4.1 版本,执行命令如下:
# yum-config-manager --add-repo https://download.opensuse.org/repositories/home:/Alexander_Pozdnyakov/CentOS_7/
# sudo rpm --import https://build.opensuse.org/projects/home:Alexander_Pozdnyakov/public_key
# yum update tesseract
# yum list tesseract
# yum install tesseract
# [yum install tesseract-langpack-deu] # 可选安装
如果执行命令报以下错误:
-bash: yum-config-manager: command not found
请查看该文章:yum-config-manager 命令找不到的解决方法
具体操作流程;
[root@iZbp115r5t4hzamv0snvm1Z cim]# yum-config-manager --add-repo https://download.opensuse.org/repositories/home:/Alexander_Pozdnyakov/CentOS_7/
Loaded plugins: fastestmirror
adding repo from: https://download.opensuse.org/repositories/home:/Alexander_Pozdnyakov/CentOS_7/
[download.opensuse.org_repositories_home_Alexander_Pozdnyakov_CentOS_7_]
name=added from: https://download.opensuse.org/repositories/home:/Alexander_Pozdnyakov/CentOS_7/
baseurl=https://download.opensuse.org/repositories/home:/Alexander_Pozdnyakov/CentOS_7/
enabled=1
[root@iZbp115r5t4hzamv0snvm1Z cim]# sudo rpm --import https://build.opensuse.org/projects/home:Alexander_Pozdnyakov/public_key
[root@iZbp115r5t4hzamv0snvm1Z cim]# yum update tesseract
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* webtatic: us-east.repo.webtatic.com
download.opensuse.org_repositories_home_Alexander_Pozdnyakov_CentOS_7_ | 1.3 kB 00:00:00
download.opensuse.org_repositories_home_Alexander_Pozdnyakov_CentOS_7_/pr | 15 kB 00:00:07
download.opensuse.org_repositories_home_Alexander_Pozdnyakov_CentOS_7_ 171/171
Package(s) tesseract available, but not installed.
No packages marked for update
[root@iZbp115r5t4hzamv0snvm1Z cim]# yum list tesseract
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* webtatic: us-east.repo.webtatic.com
Available Packages
tesseract.x86_64 4.1.0+git4242-1.4 download.opensuse.org_repositories_home_Alexander_Pozdnyakov_CentOS_7_
[root@iZbp115r5t4hzamv0snvm1Z cim]# yum install tesseract
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* webtatic: us-east.repo.webtatic.com
Resolving Dependencies
--> Running transaction check
---> Package tesseract.x86_64 0:4.1.0+git4242-1.4 will be installed
--> Processing Dependency: tesseract-langpack-osd >= 3.99 for package: tesseract-4.1.0+git4242-1.4.x86_64
--> Processing Dependency: tesseract-langpack-eng >= 3.99 for package: tesseract-4.1.0+git4242-1.4.x86_64
--> Processing Dependency: liblept.so.5()(64bit) for package: tesseract-4.1.0+git4242-1.4.x86_64
--> Running transaction check
---> Package leptonica.x86_64 0:1.72-2.el7 will be updated
---> Package leptonica.x86_64 0:1.76.0-2.5 will be an update
---> Package tesseract-langpack-eng.noarch 0:4.00~git30-5.5 will be installed
---> Package tesseract-langpack-osd.noarch 0:4.00~git30-5.5 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================
Package Arch Version
Repository Size
=================================================================================================
Installing:
tesseract x86_64 4.1.0+git4242-1.4
download.opensuse.org_repositories_home_Alexander_Pozdnyakov_CentOS_7_ 1.3 M
Installing for dependencies:
tesseract-langpack-eng
noarch 4.00~git30-5.5
download.opensuse.org_repositories_home_Alexander_Pozdnyakov_CentOS_7_ 1.6 M
tesseract-langpack-osd
noarch 4.00~git30-5.5
download.opensuse.org_repositories_home_Alexander_Pozdnyakov_CentOS_7_ 3.4 M
Updating for dependencies:
leptonica x86_64 1.76.0-2.5
download.opensuse.org_repositories_home_Alexander_Pozdnyakov_CentOS_7_ 1.0 M
Transaction Summary
=================================================================================================
Install 1 Package (+2 Dependent packages)
Upgrade ( 1 Dependent package)
Total download size: 7.3 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/4): tesseract-4.1.0+git4242-1.4.x86_64.rpm | 1.3 MB 00:00:06
(2/4): leptonica-1.76.0-2.5.x86_64.rpm | 1.0 MB 00:00:07
(3/4): tesseract-langpack-eng-4.00~git30-5.5.noarch.rpm | 1.6 MB 00:00:01
(4/4): tesseract-langpack-osd-4.00~git30-5.5.noarch.rpm | 3.4 MB 00:00:02
-------------------------------------------------------------------------------------------------
Total 751 kB/s | 7.3 MB 00:00:09
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : tesseract-langpack-eng-4.00~git30-5.5.noarch 1/5
Updating : leptonica-1.76.0-2.5.x86_64 2/5
Installing : tesseract-4.1.0+git4242-1.4.x86_64 3/5
Installing : tesseract-langpack-osd-4.00~git30-5.5.noarch 4/5
Cleanup : leptonica-1.72-2.el7.x86_64 5/5
Verifying : tesseract-langpack-osd-4.00~git30-5.5.noarch 1/5
Verifying : leptonica-1.76.0-2.5.x86_64 2/5
Verifying : tesseract-langpack-eng-4.00~git30-5.5.noarch 3/5
Verifying : tesseract-4.1.0+git4242-1.4.x86_64 4/5
Verifying : leptonica-1.72-2.el7.x86_64 5/5
Installed:
tesseract.x86_64 0:4.1.0+git4242-1.4
Dependency Installed:
tesseract-langpack-eng.noarch 0:4.00~git30-5.5 tesseract-langpack-osd.noarch 0:4.00~git30-5.5
Dependency Updated:
leptonica.x86_64 0:1.76.0-2.5
Complete!
[root@iZbp115r5t4hzamv0snvm1Z cim]# yum install tesseract-langpack-deu
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* webtatic: us-east.repo.webtatic.com
Resolving Dependencies
--> Running transaction check
---> Package tesseract-langpack-deu.noarch 0:4.00~git30-5.5 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================
Package
Arch Version
Repository Size
=================================================================================================
Installing:
tesseract-langpack-deu
noarch 4.00~git30-5.5
download.opensuse.org_repositories_home_Alexander_Pozdnyakov_CentOS_7_ 763 k
Transaction Summary
=================================================================================================
Install 1 Package
Total download size: 763 k
Installed size: 1.5 M
Is this ok [y/d/N]: y
Downloading packages:
tesseract-langpack-deu-4.00~git30-5.5.noarch.rpm | 763 kB 00:00:05
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : tesseract-langpack-deu-4.00~git30-5.5.noarch 1/1
Verifying : tesseract-langpack-deu-4.00~git30-5.5.noarch 1/1
Installed:
tesseract-langpack-deu.noarch 0:4.00~git30-5.5
Complete!
[root@iZbp115r5t4hzamv0snvm1Z cim]# tesseract -v
tesseract 4.1.1-rc2-20-g01fb
leptonica-1.76.0
libjpeg 6b (libjpeg-turbo 1.2.90) : libpng 1.5.13 : libtiff 4.0.3 : zlib 1.2.7 : libwebp 0.3.0
Found AVX512BW
Found AVX512F
Found AVX2
Found AVX
Found FMA
Found SSE