def fit_boundingRect_cpp(num_label, labelimage): rects = [] points = find_label_coord(labelimage, num_label) for i in range(num_label): pt = np.array(points[i]).reshape(-1, 2) x, y, w, h = cv2.boundingRect(pt) rects.append(np.array([[x, y], [x + w, y], [x + w, y + h], [x, y + h]])) return rects
def fit_minarearectange_cpp(num_label, labelimage): rects = [] points = find_label_coord(labelimage, num_label) for i in range(num_label): pt = np.array(points[i]).reshape(-1, 2) rect = cv2.minAreaRect(pt) rect = cv2.boxPoints(rect) rect = np.int0(rect) rects.append(rect) return rects