使用 tesseract OCR、Python 从不同光照条件的图像中检测数字
该图像在不同光照条件下的问题:- Img_1
适用于今天早上的图片:- Img_2
我正在尝试使用 Tesseract OCR & 从视频中提取数字。 Python 。在该视频中,每列火车上都有一个可用的火车,并且有一个车牌号,我将使用 YOLO 检测到该车牌号。一旦我拿到盘子,我就会对其进行预处理&从板中提取 no。 我能够提取它,但如果存在不同的光照条件或视频中有夜晚,那么我的预处理将无法正常工作。所以我想要一个通用逻辑来预处理图像,使其适用于所有图像,而不是某些图像。 我附上了一些试用图片。 在代码中,我仅手动提取了板的一部分,然后将其传递给 getText(image) 来执行预处理和处理。 吗?
def getText(img):
# color threshold
thresh = otsu_thresholding(img)
gray = get_grayscale(thresh)
gray[gray != 0] = 255
# second way
thresh_2 = adaptive_thresholding(get_grayscale(img), method=1)
cv2.imshow("img", img)
cv2.imshow("Thresh", thresh)
cv2.imshow("Thresh_2", thresh_2)
cv2.imshow("Gray", gray)
data = pytesseract.image_to_string(gray, lang='eng', config='--psm 6 -c tessedit_char_whitelist=0123456789')
data_2 = pytesseract.image_to_string(thresh_2, lang='eng', config='--psm 6 -c tessedit_char_whitelist=0123456789')
return data, data_2
任何人都可以帮我在将图像输入超立方体之前对其进行预处理
the problem for this image with different light condition:-
Img_1
worked for this morning image:-
Img_2
I am trying to extract numbers from the video by using Tesseract OCR & Python . in that video, there is a train available on each train there is a number plate that I will be detected by using YOLO. once I got the plate I'm preprocessing it & extract no from the plate.
I am able to extract it but if there is a different light condition or there is night in the video then my preprocessing will not work properly. so I wanted a Genral purpose Logic to preprocess images in a such way that it'll work for all images, not for some.
I have attached some images for the trial.
in the CODE I have extracted only part of the plate manually then pass it to getText(image) to perform preprocessing & extract no
def getText(img):
# color threshold
thresh = otsu_thresholding(img)
gray = get_grayscale(thresh)
gray[gray != 0] = 255
# second way
thresh_2 = adaptive_thresholding(get_grayscale(img), method=1)
cv2.imshow("img", img)
cv2.imshow("Thresh", thresh)
cv2.imshow("Thresh_2", thresh_2)
cv2.imshow("Gray", gray)
data = pytesseract.image_to_string(gray, lang='eng', config='--psm 6 -c tessedit_char_whitelist=0123456789')
data_2 = pytesseract.image_to_string(thresh_2, lang='eng', config='--psm 6 -c tessedit_char_whitelist=0123456789')
return data, data_2
Can anyone help me in pre-processing the images before feeding them to tesseract?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论