Issue
I'm doing small project using tesseract OCR. What I want to read is Digital Number which is generated by oven. I pre-treat the image using openCV but, tesseract can't read the image correct. eg. 194 as 794.. let me know is there any way to deal with this. thanks.
the Image which I want to read is shown below
import cv2
import numpy
img_color = cv2.imread('20190509_103247.jpg', cv2.IMREAD_COLOR)
dst = img_color.copy()
roi = img_color[1600:1800,600:1100]
dst[0:200,0:500]=roi
blur = cv2.GaussianBlur(roi,(5,5),0)
gray_dst = cv2.cvtColor(blur, cv2.COLOR_BGR2GRAY)
ret, thr = cv2.threshold(gray_dst, 70, 255,cv2.THRESH_BINARY)
canny = cv2.Canny(roi,100,255)
sobel = cv2.Sobel(gray_dst,cv2.CV_8U,1,0,3)
laplacian = cv2.Laplacian(gray_dst,cv2.CV_8U,ksize=3)
rev = cv2.bitwise_not(canny)
# blur = cv2.GaussianBlur(roi,(5,5),0)
# stencil = numpy.zeros(rev.shape).astype(rev.dtype)
# _, contours, _ = cv2.findContours(rev, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
# color = [255, 255, 255]
# cv2.fillPoly(stencil, contours, color)
# result = cv2.bitwise_and(rev, stencil)
cv2.namedWindow('Show Image')
cv2.imshow('Show Image', rev)
cv2.waitKey(0)
cv2.imwrite('savedimage.jpg', rev)
cv2.destroyAllWindows()
Solution
You can create training data that will work for your font / glyphs to improve how the numeric display gets transformed to the correct digits.
References:
- https://github.com/tesseract-ocr/tesseract/wiki/TrainingTesseract-4.00#creating-training-data
- https://github.com/DevashishPrasad/LCD-OCR
Answered By - dnozay
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.