# Tesseract（软件）

**Tesseract** 是一款开源光学字符识别（OCR）引擎，可从图像中提取印刷文字，以 Apache 2.0 许可证发布，既可直接从命令行使用，也可供程序员通过 libtesseract 的 C 和 C++ API 调用。<sup>[1](https://tesseract-ocr.github.io/tessdoc/)</sup> 它最初由惠普公司（Hewlett-Packard）于 1985 年至 1994 年间开发，2005 年开源，2006 年至 2017 年 8 月由谷歌（Google）开发，现由社区维护。<sup>[2](https://github.com/tesseract-ocr/tesseract)</sup> 第 4 版加入了 LSTM 神经网络识别引擎，当前稳定主线为第 5 版。<sup>[3](https://tesseract-ocr.github.io/tessdoc/Command-Line-Usage.html)</sup><sup> • </sup><sup>[1](https://tesseract-ocr.github.io/tessdoc/)</sup>

| 关键事实 | 详情 |
|---|---|
| 许可证与形态 | Apache 2.0；命令行程序加 libtesseract C/C++ API；无内置图形界面<sup>[1](https://tesseract-ocr.github.io/tessdoc/)</sup><sup> • </sup><sup>[2](https://github.com/tesseract-ocr/tesseract)</sup> |
| 起源 | 1985—1994 年由惠普实验室布里斯托尔（Bristol）分部与科罗拉多州格里利（Greeley）的惠普公司开发；2005 年由惠普开源<sup>[2](https://github.com/tesseract-ocr/tesseract)</sup> |
| 谷歌主导开发 | 2006 年至 2017 年 8 月由谷歌开发<sup>[2](https://github.com/tesseract-ocr/tesseract)</sup> |
| 早期地位 | 在 1995 年 UNLV 第四届 OCR 准确率年度测试中位列前三<sup>[4](https://developers.googleblog.com/announcing-tesseract-ocr/)</sup> |
| 当前版本 | 第 5 版，始于 2021 年 11 月 30 日发布的 5.0.0<sup>[1](https://tesseract-ocr.github.io/tessdoc/)</sup> |
| 识别引擎 | `--oem 1` 为 LSTM/神经网络引擎，`--oem 0` 为 Tesseract 3 的旧版引擎<sup>[3](https://tesseract-ocr.github.io/tessdoc/Command-Line-Usage.html)</sup> |
| 语言覆盖 | LSTM 引擎拥有 100 多种语言和 35 种以上文字的官方语言模型数据<sup>[5](https://tesseract-ocr.github.io/)</sup> |
| 输出格式 | 纯文本、hOCR（HTML）、PDF、仅含不可见文本的 PDF、TSV、ALTO 和 PAGE<sup>[2](https://github.com/tesseract-ocr/tesseract)</sup> |

## 历史

[Tesseract](https://www.edgepedia.org/zh/tesseract) 最初是英格兰布里斯托尔惠普实验室的一个博士研究项目，后经与[惠普](https://www.edgepedia.org/zh/hewlett-packard)科罗拉多扫描仪部门的合作项目，发展为一款准确率显著领先于当时商业 OCR 产品的引擎，但它从未成为惠普的产品。<sup>[6](https://tesseract-ocr.github.io/docs/tesseracticdar2007.pdf)</sup> 1994 年底开发停止，该引擎被送往[内华达大学拉斯维加斯分校](https://www.edgepedia.org/zh/university-of-nevada-las-vegas)（University of Nevada, Las Vegas）参加 1995 年 OCR 准确率年度测试，位列前三。<sup>[6](https://tesseract-ocr.github.io/docs/tesseracticdar2007.pdf)</sup><sup> • </sup><sup>[4](https://developers.googleblog.com/announcing-tesseract-ocr/)</sup> 此后惠普退出 OCR 业务，引擎一直闲置，直至 2005 年底在 UNLV 信息科学研究所的协助下由惠普将其开源发布。<sup>[6](https://tesseract-ocr.github.io/docs/tesseracticdar2007.pdf)</sup><sup> • </sup><sup>[4](https://developers.googleblog.com/announcing-tesseract-ocr/)</sup>

谷歌于 2006 年 8 月重新发布该引擎，并持续开发至 2017 年 8 月。<sup>[4](https://developers.googleblog.com/announcing-tesseract-ocr/)</sup><sup> • </sup><sup>[2](https://github.com/tesseract-ocr/tesseract)</sup> 2006 年发布时，Tesseract 仅支持英语，且缺少版面分析模块，因为惠普将自家的版面分析技术保留为专有技术。<sup>[4](https://developers.googleblog.com/announcing-tesseract-ocr/)</sup><sup> • </sup><sup>[6](https://tesseract-ocr.github.io/docs/tesseracticdar2007.pdf)</sup> 雷·史密斯（Ray Smith）曾领导惠普的原始工作，并撰写了 2007 年该引擎的技术概述，他担任首席开发者至 2017 年；斯特凡·魏尔（Stefan Weil）是现任首席开发者，兹登科·波多布尼（Zdenko Podobny）是维护者。<sup>[6](https://tesseract-ocr.github.io/docs/tesseracticdar2007.pdf)</sup><sup> • </sup><sup>[2](https://github.com/tesseract-ocr/tesseract)</sup>

版本历史记录了该引擎不断扩大的范围。2.00 版带来了 Unicode（UTF-8）支持、六种语言以及训练新语言的能力。<sup>[7](https://github.com/tesseract-ocr/tesseract/blob/main/doc/tesseract.1.asc)</sup> 3.00 版新增中文、日文和韩文，并引入了语言数据的单文件系统；3.02 版新增双向文本支持、单幅图像中的多语言识别以及改进的版面分析。<sup>[7](https://github.com/tesseract-ocr/tesseract/blob/main/doc/tesseract.1.asc)</sup> Tesseract 4 加入了基于 LSTM 的引擎，2021 年 11 月 30 日发布的 Tesseract 5.0.0 是当前稳定大版本的开端。<sup>[7](https://github.com/tesseract-ocr/tesseract/blob/main/doc/tesseract.1.asc)</sup><sup> • </sup><sup>[1](https://tesseract-ocr.github.io/tessdoc/)</sup>

## 架构与用法

Tesseract 是一个命令行程序，一般形式为 `tesseract imagename outputbase [-l lang] [--oem ocrenginemode] [--psm pagesegmode] [configfile...]`。<sup>[2](https://github.com/tesseract-ocr/tesseract)</sup> 最简单的调用 `tesseract imagename outputbase` 使用英语作为默认语言、页面分割模式 3（全自动页面分割，不做方向检测）和纯文本输出。<sup>[3](https://tesseract-ocr.github.io/tessdoc/Command-Line-Usage.html)</sup> 多种语言可用 `-l eng+deu` 组合，语言的顺序会影响输出和处理时间。<sup>[3](https://tesseract-ocr.github.io/tessdoc/Command-Line-Usage.html)</sup>

页面分割模式（`--psm`）告诉引擎预期何种图像，从模式 0（仅做方向和文字种类检测）到模式 3（全自动页面分割，默认值），再到模式 7 至 10（将图像视为单行、单词或单个字符）。<sup>[8](https://tesseract-ocr.github.io/tessdoc/ImproveQuality.html)</sup> 语言和文字模型存储在 `traineddata` 文件中，置于 tessdata 目录下，可通过 `TESSDATA_PREFIX` 环境变量或 `--tessdata-dir` 选项定位。<sup>[3](https://tesseract-ocr.github.io/tessdoc/Command-Line-Usage.html)</sup>

Tesseract 可读取由 Leptonica 图像处理库处理的图像格式，包括 PNG、JPEG 和 TIFF，并依赖 Leptonica，后者使用 BSD 双条款许可证。<sup>[2](https://github.com/tesseract-ocr/tesseract)</sup> 在启用多线程支持构建时，处理单幅图像通常使用四个 CPU 核心；设置 `OMP_THREAD_LIMIT=1` 可限制为单核，在批量 OCR 大量图像时反而能获得更好的吞吐量。<sup>[7](https://github.com/tesseract-ocr/tesseract/blob/main/doc/tesseract.1.asc)</sup>

## LSTM 引擎与旧版引擎

Tesseract 4.00 引入了基于 LSTM（长短期记忆）网络的神经网络识别引擎，在文档图像上的准确率显著高于此前版本，代价是所需计算能力大幅增加；在复杂语言上，它实际上可能比旧版引擎更快。<sup>[9](https://tesseract-ocr.github.io/tessdoc/tess5/TrainingTesseract-5.html)</sup> LSTM 引擎专注于行识别，而 Tesseract 3 的旧版引擎通过识别字符模式工作；`--oem 0` 选择旧版引擎，该引擎需要包含旧版模型的 traineddata 文件，例如来自 tessdata 仓库的文件。<sup>[7](https://github.com/tesseract-ocr/tesseract/blob/main/doc/tesseract.1.asc)</sup><sup> • </sup><sup>[3](https://tesseract-ocr.github.io/tessdoc/Command-Line-Usage.html)</sup>

官方 traineddata 数据集以多种变体分发：tessdata 仓库包含同时支持两种引擎的模型，而在谷歌训练的 tessdata_best 和 tessdata_fast 仅包含可用于 `--oem 1` 的 LSTM 模型。<sup>[5](https://tesseract-ocr.github.io/)</sup>

## 训练

Tesseract 可针对新语言、文字或字体重新训练。在 LSTM 工作流中，训练数据以 `.lstmf` 文件提供，这是包含图像及对应 UTF-8 文本转写的序列化记录，由 tif/box 文件对生成；边界框只需标注到文本行级别，这使得从现有图像构建训练数据更为容易。<sup>[9](https://tesseract-ocr.github.io/tessdoc/tess5/TrainingTesseract-5.html)</sup> `lstmtraining` 程序用一个缓慢的训练步骤取代了旧版流程中的聚类步骤（mftraining、cntraining 和 shapeclustering），字体可以自由混合，而不必分别训练。<sup>[9](https://tesseract-ocr.github.io/tessdoc/tess5/TrainingTesseract-5.html)</sup> 训练器会写出检查点文件，因此训练可以停止和恢复，任何检查点都可用 `--stop_training` 标志转换为完整的 `traineddata` 文件。<sup>[9](https://tesseract-ocr.github.io/tessdoc/tess5/TrainingTesseract-5.html)</sup>

项目文档带有一则实用警告：除非目标使用非常特殊的字体或一种新语言，否则重新训练 Tesseract 不太可能有帮助，识别效果往往只需对输入图像做预处理即可改善。<sup>[9](https://tesseract-ocr.github.io/tessdoc/tess5/TrainingTesseract-5.html)</sup> 对于 Tesseract 5，使用旧的 `tesstrain.sh` 脚本进行训练不受支持，取而代之的是使用独立的 tesstrain 仓库中的 Python 脚本。<sup>[9](https://tesseract-ocr.github.io/tessdoc/tess5/TrainingTesseract-5.html)</sup>

## 实际中的图像质量与准确率

Tesseract 在识别前通过 Leptonica 进行内部图像处理，但结果在很大程度上取决于输入质量。它在至少 300 dpi 的图像上效果最佳，内部使用大津算法（Otsu）对图像进行二值化（Tesseract 5.0.0 中加入了自适应大津法和 Sauvola 方法），并且对倾斜、噪点、缺失或过大的边框以及反色图像较为敏感。<sup>[8](https://tesseract-ocr.github.io/tessdoc/ImproveQuality.html)</sup>

基准测试结果反映了这种敏感性。[挪威国防研究所](https://www.edgepedia.org/zh/norwegian-defence-research-establishment)的托马斯·赫格哈默（Thomas Hegghammer）在 2022 年的一项研究中，将 Tesseract 与 Amazon Textract 和 Google Document AI 在 322 页英文和 100 页阿拉伯文扫描件上进行比较（扫描件经复制并添加了人工噪声）；基于服务器的处理器开箱即用的准确率明显更高，而 Tesseract 对噪声明显更为敏感，仅在无噪声的英文文档上具有竞争力。<sup>[10](https://link.springer.com/article/10.1007/s42001-021-00149-1)</sup> 在该研究使用的硬件上——一台 12 核 4.3 GHz、64 GB 内存的 Linux 台式机——Tesseract 处理每页阿拉伯文耗时 17 秒，每页英文耗时 2 秒。<sup>[10](https://link.springer.com/article/10.1007/s42001-021-00149-1)</sup> 一项 2025 年的档案保存研究报告称，在干净的扫描印刷页面上准确率最高可达 93.8%，但在某些手写或含噪照片输入上准确率低于 25%。<sup>[11](https://doi.org/10.1515/pdtc-2025-0025)</sup> 实践者的报告都指向同一点：准确率主要来自为引擎提供清晰干净的图像，而非重新训练。<sup>[9](https://tesseract-ocr.github.io/tessdoc/tess5/TrainingTesseract-5.html)</sup>

## 生态系统

Tesseract 没有内置图形界面，但项目文档中列出了第三方图形前端，各种语言绑定将 libtesseract API 封装供其他语言使用。<sup>[12](https://tesseract-ocr.github.io/tessdoc/Installation.html)</sup><sup> • </sup><sup>[2](https://github.com/tesseract-ocr/tesseract)</sup> Linux 发行版将该引擎与 130 多种语言和 35 种以上文字的 traineddata 一同打包，该引擎也被嵌入其他工具中，如 OCRmyPDF 和 PyMuPDF，以它作为识别核心。<sup>[12](https://tesseract-ocr.github.io/tessdoc/Installation.html)</sup>

## References

1. [Tesseract User Manual, tessdoc](https://tesseract-ocr.github.io/tessdoc/)
2. [Tesseract Open Source OCR Engine (main repository README), GitHub](https://github.com/tesseract-ocr/tesseract)
3. [Command Line Usage, tessdoc](https://tesseract-ocr.github.io/tessdoc/Command-Line-Usage.html)
4. [Announcing Tesseract OCR, Google Developers Blog (August 30, 2006)](https://developers.googleblog.com/announcing-tesseract-ocr/)
5. [Tesseract documentation, tessdoc](https://tesseract-ocr.github.io/)
6. [Ray Smith (2007). An Overview of the Tesseract OCR Engine, ICDAR 2007](https://tesseract-ocr.github.io/docs/tesseracticdar2007.pdf)
7. [tesseract(1) man page, tesseract repository doc/tesseract.1.asc](https://github.com/tesseract-ocr/tesseract/blob/main/doc/tesseract.1.asc)
8. [Improving the quality of the output, tessdoc](https://tesseract-ocr.github.io/tessdoc/ImproveQuality.html)
9. [How to train LSTM/neural net Tesseract, tessdoc (TrainingTesseract-5)](https://tesseract-ocr.github.io/tessdoc/tess5/TrainingTesseract-5.html)
10. [Thomas Hegghammer (2022). OCR with Tesseract, Amazon Textract, and Google Document AI: a benchmarking experiment. Journal of Computational Social Science 5, 861–882](https://link.springer.com/article/10.1007/s42001-021-00149-1)
11. [Transforming Physical Archives into Searchable Digital Libraries (2025), Preservation, Digital Technology & Culture](https://doi.org/10.1515/pdtc-2025-0025)
12. [Introduction and Installation, tessdoc](https://tesseract-ocr.github.io/tessdoc/Installation.html)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Development tools and collaboration infrastructure › Frameworks, libraries, and APIs › Graphics and multimedia APIs

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/tesseract-software

English original: https://www.edgepedia.org/tesseract-software
