def getTestImage(img,size):
size = int(size)
(x,y) = np.shape(img)
left,right,bottom,top = x,0,y,0
count = 0
for i in range(x):
for j in range(y):
if img[i][j] == 255:
left = min(left,i)
right = max(right,i)
top = max(top,j)
bottom = min(bottom,j)
count = count + 1
if count == 0:
return img
img = img[left:right,bottom:top]
cv2.imwrite('template.jpg',img)
return img
# Divides the grid into 9x9 = 81 cells and does OCR on each after processing it
评论列表
文章目录