I’m trying to find my region of interest, which would be the rectangle containing the measurement numbers, I’m using opencv for that, as the red color is present in all clocks indicating the decimals, I started my code getting this color and trying to proportionally get the rest of the rectangle, however, I don’t know how to do that. Some boxes have two digits for decimals and others have three digits, after taking the rectangle, is there any way to know when this rectangle has two digits and when it has three ? this is the code i have so far.
import numpy as np import cv2 image = cv2.imread('0723370820210000024208.jpg') result = image.copy() image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV) lower = np.array([155,25,0]) upper = np.array([179,255,255]) mask = cv2.inRange(image, lower, upper) result = cv2.bitwise_and(result, result, mask=mask) #cv2.imshow('mask', mask) cv2.imshow('result', result) cv2.waitKey()
Image Original (2 digits for decimal points)
How to fix perspective ?