def get_bounding_rect(contour): rect = cv2.minAreaRect(contour) box = cv2.boxPoints(rect) return np.int0(box)