image_org = cv2.imread("unnamed.png")
height, width = image_org.shape[:2]
# calculate the amount of pixels to crop from the border
x_border = int(width * 0.1)
y_border = int(height * 0.1)
image = image_org[y_border:height-y_border, x_border:width-x_border]
cv2_show("image", image, 600)
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cv2_show("gray_image", gray_image, 600)
blur1 = cv2.GaussianBlur(gray_image,(21,21),0)
cv2_show("blur1", blur1, 600)
# global thresholding
ret, otsu = cv2.threshold(blur1,0,255,cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU)
cv2_show("otsu", otsu, 800)
kernel = np.ones((3,3),np.uint8)
erosion = cv2.erode(otsu,kernel,iterations = 1)
cv2_show("erosion", erosion, 800)
blur = cv2.GaussianBlur(erosion,(5,5),0)
cv2_show("blur", blur, 600)
results = get_text(255-blur)
for ret in results:
print(ret[0][0])
print(ret[1][0])