【发布时间】:2020-04-28 13:23:07
【问题描述】:
我需要读取热像图上的最高温度,如下图:
我使用了以下代码,这是最好的结果。 我还尝试了其他几种方法,例如:模糊、灰度、二值化等,但都失败了。
import cv2
import pytesseract
pytesseract.pytesseract.tesseract_cmd = r"C:\Users\User\AppData\Local\Tesseract-OCR\tesseract.exe"
# Load image, grayscale, Otsu's threshold
entrada = cv2.imread('IR_1546_INFRA.jpg')
image = entrada[40:65, 277:319]
#image = cv2.imread('IR_1546_INFRA.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
thresh = 255 - cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1]
# Blur and perform text extraction
thresh = cv2.GaussianBlur(thresh, (3,3), 0)
data = pytesseract.image_to_string(thresh, lang='eng', config='--psm 6')
print(data)
cv2.imshow('thresh', thresh)
cv2.waitKey()
在第一张图片中,我发现 this
在第二张图片中,我找到了this。
imagem 的布局总是一样的,也就是温度总是在同一个地方,所以我裁剪了图片,只隔离了数字。我想要(97.7 here 和 85.2 here)。
我的代码需要从这些图像中查找以始终检测此温度并生成一个从最高到最低指示的列表。
在这些图像的情况下,你对我有什么建议可以提高 pytesseract 的自信度?
注意 1:当我分析整个图像(不裁剪)时,它返回的数据甚至不存在。
注2:有些图片即使是二进制数,pytesseract(image_to_string)也不返回任何数据。
谢谢大家,对错别字深表歉意,用英文写作对我来说仍然是一个挑战。
【问题讨论】:
标签: python-3.x text ocr python-tesseract string-decoding