macos下用brew安装了tesseract,如何配置简体中文的识别库?我已经下载chi_sim.traineddata
在 macOS 下通过 Homebrew 安装 Tesseract 后,配置简体中文识别库(
chi_sim.traineddata)非常简单。你只需要将下载好的文件放到 Tesseract 指定的语言数据目录中即可。1. 将语言包放入指定目录
由于你是通过 Homebrew 安装的,Tesseract 默认的语言数据存放路径通常是
/opt/homebrew/share/tessdata(如果是较旧的 Intel 芯片 Mac,路径可能是 /usr/local/share/tessdata)。查了一下
/opt/homebrew/share/tessdata的真实路径是 /opt/homebrew/Cellar/tesseract/5.5.2/share/tessdata,所以将文件拷贝到了/opt/homebrew/Cellar/tesseract/5.5.2/share/tessdata目录下。2. 验证语言包是否配置成功
在终端中输入以下命令,查看 Tesseract 当前支持的语言列表:
tesseract --list-langs
这里并不会显示出来,因为tesseract读的是/opt/homebrew/share/tessdata,需要软链接一下:
cd /opt/homebrew/share/tessdata/
ln -s ../../Cellar/tesseract/5.5.2/share/tessdata/chi_sim.traineddata chi_sim.traineddata
哎!其实就是挺脱裤子放屁的!直接将chi_sim.traineddata放在/opt/homebrew/share/tessdata也不是不行!
3. 使用
tesseract input.png -l chi_sim+eng result.txt
浙公网安备 33010602011771号