
今天給大家介紹一個超級簡單且強大的OCR文本識別工具:easyocr.
這個模塊支持70多種語言的即用型OCR,包括中文,日文,韓文和泰文等。
下面是這個模塊的實戰(zhàn)教程。

1.準備
請選擇以下任一種方式輸入命令安裝依賴:
1. Windows 環(huán)境 打開 Cmd (開始-運行-CMD)。
2. MacOS 環(huán)境 打開 Terminal (command+空格輸入Terminal)。
3. 如果你用的是 VSCode編輯器 或 Pycharm,可以直接使用界面下方的Terminal.
pip install easyocr它會安裝除了模型文件之外的所有依賴,模型文件則會在運行代碼的時候下載。
對于Windows,如果在安裝 Torch 或 Torchvision 時報錯了,請按照https://pytorch.org 的官方說明安裝 Torch 和 Torchvision。
如果你想使用顯卡進行計算,你需要搜索下載CUDA,并在Pytorch網(wǎng)站上,確保選擇正確的CUDA版本。如果僅打算在CPU模式下運行,請選擇CUDA = None。
2.實戰(zhàn)教程
這個模塊用起來真的非常簡單,三行代碼完事了:
import easyocr
reader = easyocr.Reader(['ch_sim','en'])
result = reader.readtext('test.png')運行的過程中會安裝所需要的模型文件,像下面這樣:

不過它的下載速度非常慢,而且經(jīng)常會失敗,因此這里給出第二個解決方案:先下載好模型文件,再將其放置到所需要的位置:
上滑查看更多
文字檢測模型(CRAFT)(必須)
https:///go/?url=https://github.com/JaidedAI/EasyOCR/releases/download/pre-v1.1.6/craft_mlt_25k.zip
中文(簡體)模型(識別中文必須)
https:///go/?url=https://github.com/JaidedAI/EasyOCR/releases/download/pre-v1.1.6/chinese_sim.zip
中國(傳統(tǒng))模型
https:///go/?url=https://github.com/JaidedAI/EasyOCR/releases/download/pre-v1.1.6/chinese.zip
拉丁模型
https:///go/?url=https://github.com/JaidedAI/EasyOCR/releases/download/pre-v1.1.6/latin.zip
日本模型
https:///go/?url=https://github.com/JaidedAI/EasyOCR/releases/download/pre-v1.1.6/japanese.zip
韓文模型
https:///go/?url=https://github.com/JaidedAI/EasyOCR/releases/download/pre-v1.1.6/korean.zip
泰文模型
https:///go/?url=https://github.com/JaidedAI/EasyOCR/releases/download/pre-v1.1.6/thai.zip
阿拉伯文模型
https:///go/?url=https://github.com/JaidedAI/EasyOCR/releases/download/pre-v1.1.6/arabic.zip




