The only Python package used is opencv.
Load image and get middle of image:
image = cv2.imread("../images/1538832301.jpg") image = image[300:1300, 500:1400] height, width, channels = image.shape
center = (width / 2, height / 2) angle = 87 M = cv2.getRotationMatrix2D(center, angle, 1) image = cv2.warpAffine(image, M, (height, width))
Convert to grayscale:
Blur and threshold:
Find contour of box in the middle of the image and plot in green on image. The box has a minimum of 100 pixel width and a minimum of 50 pixel height.
contours,hierarchy = cv2.findContours(thresh, 1, 2) for cnt in contours: x,y,w,h = cv2.boundingRect(cnt) if w>100 and h>50: break
Now crop image based on the points of the green box:
Increase alpha contrast of the image to see the digits and save result to disk:
The next step will be to recognize the numbers in the display.