def search_min_area_rect(self, image_path): contours = self.get_contours(image_path) regions = [] for con in contours: cv2.approxPolyDP(con, 3, True) #box = region.rect(cv2.boundingRect(con)) box = region.rotated_rect(cv2.minAreaRect(con)) regions.append(box) return regions
def search_bounding_boxies(self, image_path): contours = self.get_contours(image_path) regions = [] for con in contours: cv2.approxPolyDP(con, 3, True) center, radius = cv2.minEnclosingCircle(con) cir = region.circle(center, radius) cvrot = cv2.fitEllipse(con) eli = region.ellipse(cvrot) box = region.rect(cv2.boundingRect(con)) rot = region.rotated_rect(cv2.minAreaRect(con)) logging.debug("area: cir={}, box={}, rot={}, eli={}".format( cir.area, box.area, rot.area, eli.area)) regions.append(self.choose_region_by_area(cir, box, rot)) return regions