f_label_img = cv2.imread('1.jpg')
f_label_img = cv2.cvtColor(f_label_img, cv2.COLOR_BGR2GRAY) contours, hierarchy = cv2.findContours(f_label_img, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) rect = cv2.minAreaRect(contours[0]) points = cv2.boxPoints(rect) box = np.int0(points) left_point_x = np.min(box[:, 0]) right_point_x = np.max(box[:, 0]) top_point_y = np.min(box[:, 1]) bottom_point_y = np.max(box[:, 1])