In [8]: import pytesseract
In [9]: from PIL import Image
In [10]: balIm = Image.open('wC62s.png')
In [11]: pytesseract.image_to_string(balIm, config=' psm 6')
Out[11]: '0.03,'
0 Orientation and script detection (OSD) only.
1 Automatic page segmentation with OSD.
2 Automatic page segmentation, but no OSD, or OCR.
3 Fully automatic page segmentation, but no OSD. (Default)
4 Assume a single column of text of variable sizes.
5 Assume a single uniform block of vertically aligned text.
6 Assume a single uniform block of text.
7 Treat the image as a single text line.
8 Treat the image as a single word.
9 Treat the image as a single word in a circle.
10 Treat the image as a single character.
11 Sparse text. Find as much text as possible in no particular order.
12 Sparse text with OSD.
13 Raw line. Treat the image as a single text line,
bypassing hacks that are Tesseract-specific.
尝试将页面分割模式(PSM)设置为模式6,这将设置OCR以检测单个统一的文本块
具体而言,请:
这会给你你所需要的。事实上,我试着在你的图片上运行这个,它给了我我想要的。请注意,我首先下载了您在上面提供的图像,并在本地计算机上脱机读取图像:
作为最后的注释,如果你看到TestSerAt对你来说不是很有效,请考虑尝试他们的页面分割模式来帮助提高准确性:https://tesseract-ocr.github.io/tessdoc/ImproveQuality#page-segmentation-method。为了完整起见,我将在下面向您提供此信息
运行
image_to_string
时,指定一个输入参数config
,该参数接受要在其中操作的PSM。尝试一下这些,直到你的形象。确保在执行之前在config
参数中使用psm
相关问题 更多 >
编程相关推荐