我在用pytesseractpython 中的模块,pytesseract从图像中识别文本,但它不适用于包含复杂数学公式(例如根、推导、积分数学问题或方程)的图像.
代码2.py
# Import modules
from PIL import Image
import pytesseract
import cv2
# Include tesseract executable in your path
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
# Create an image object of PIL library
image = Image.open('23.jpg')
# img = cv2.imread('123.jpg')
# pass image into pytesseract module
# pytesseract is trained in many languages
image_to_text = pytesseract.image_to_string(image, lang='eng+equ')
image_to_text1 = pytesseract.image_to_string(image)
# Print the text
print(image_to_text)
# print(image_to_text1)
# workon digits
Output:
242/33
2x
2x+3X
2X+3x=4
2x?-3x +1=0
(x-1)(x+1) =x2-1
(x+2)/((x+3)(x-4))
7-4=3
V(x/2) =3
2xx—343=6x—3 (x#3)
Jeeta =e* +e
dy 2
S=2?-3
dz ¥
dy = (a? — 3)dx
输入图像 https://i.stack.imgur.com/0WEQl.jpg
要使用 MATH 语言,您应该为 tesseract 安装正确的语言。在你的情况下,它是“equ”https://github.com/tesseract-ocr/tessdata/raw/3.04.00/equ.traineddata https://github.com/tesseract-ocr/tessdata/raw/3.04.00/equ.traineddata。可用语言的完整列表位于https://tesseract-ocr.github.io/tessdoc/Data-Files https://tesseract-ocr.github.io/tessdoc/Data-Files
我不熟悉 Windows 的 tesseract 语言安装。但有一个文档位于https://github.com/tesseract-ocr/tesseract/wiki https://github.com/tesseract-ocr/tesseract/wiki :
如果您想使用其他语言,请下载适当的培训
data,使用 7-zip 解压,然后将 .traineddata 文件复制到
'tessdata' 目录,可能是 C:\Program Files\Tesseract-OCR\tessdata
首先尝试仅使用 cli (不使用 pyhton )处理图像,因为 cli 有完整的选项列表可供调整。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)