From e2ae6dbd448343ecedb7078770adf6131218c88f Mon Sep 17 00:00:00 2001 From: Konstantin Baierer Date: Tue, 23 Feb 2021 16:39:33 +0100 Subject: [PATCH] remove unused find_features_of_contours --- sbb_newspapers_org_image/eynollah.py | 1 - sbb_newspapers_org_image/unused.py | 13 +++++++++++++ sbb_newspapers_org_image/utils/contour.py | 13 ------------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/sbb_newspapers_org_image/eynollah.py b/sbb_newspapers_org_image/eynollah.py index b9d7735..a5ebee5 100644 --- a/sbb_newspapers_org_image/eynollah.py +++ b/sbb_newspapers_org_image/eynollah.py @@ -33,7 +33,6 @@ from .utils.contour import ( filter_contours_area_of_image_tables, filter_contours_area_of_image, find_contours_mean_y_diff, - find_features_of_contours, find_new_features_of_contoures, get_text_region_boxes_by_given_contours, get_textregion_contours_in_org_image, diff --git a/sbb_newspapers_org_image/unused.py b/sbb_newspapers_org_image/unused.py index 80654d4..f2c4f8d 100644 --- a/sbb_newspapers_org_image/unused.py +++ b/sbb_newspapers_org_image/unused.py @@ -3057,3 +3057,16 @@ def return_bonding_box_of_contours(cnts): boxes_tot.append(box) return boxes_tot +def find_features_of_contours(contours_main): + + areas_main = np.array([cv2.contourArea(contours_main[j]) for j in range(len(contours_main))]) + M_main = [cv2.moments(contours_main[j]) for j in range(len(contours_main))] + cx_main = [(M_main[j]["m10"] / (M_main[j]["m00"] + 1e-32)) for j in range(len(M_main))] + cy_main = [(M_main[j]["m01"] / (M_main[j]["m00"] + 1e-32)) for j in range(len(M_main))] + x_min_main = np.array([np.min(contours_main[j][:, 0, 0]) for j in range(len(contours_main))]) + x_max_main = np.array([np.max(contours_main[j][:, 0, 0]) for j in range(len(contours_main))]) + + y_min_main = np.array([np.min(contours_main[j][:, 0, 1]) for j in range(len(contours_main))]) + y_max_main = np.array([np.max(contours_main[j][:, 0, 1]) for j in range(len(contours_main))]) + + return y_min_main, y_max_main, areas_main diff --git a/sbb_newspapers_org_image/utils/contour.py b/sbb_newspapers_org_image/utils/contour.py index a4cc81a..b5002a8 100644 --- a/sbb_newspapers_org_image/utils/contour.py +++ b/sbb_newspapers_org_image/utils/contour.py @@ -26,19 +26,6 @@ def find_contours_mean_y_diff(contours_main): cy_main = [(M_main[j]["m01"] / (M_main[j]["m00"] + 1e-32)) for j in range(len(M_main))] return np.mean(np.diff(np.sort(np.array(cy_main)))) -def find_features_of_contours(contours_main): - - areas_main = np.array([cv2.contourArea(contours_main[j]) for j in range(len(contours_main))]) - M_main = [cv2.moments(contours_main[j]) for j in range(len(contours_main))] - cx_main = [(M_main[j]["m10"] / (M_main[j]["m00"] + 1e-32)) for j in range(len(M_main))] - cy_main = [(M_main[j]["m01"] / (M_main[j]["m00"] + 1e-32)) for j in range(len(M_main))] - x_min_main = np.array([np.min(contours_main[j][:, 0, 0]) for j in range(len(contours_main))]) - x_max_main = np.array([np.max(contours_main[j][:, 0, 0]) for j in range(len(contours_main))]) - - y_min_main = np.array([np.min(contours_main[j][:, 0, 1]) for j in range(len(contours_main))]) - y_max_main = np.array([np.max(contours_main[j][:, 0, 1]) for j in range(len(contours_main))]) - - return y_min_main, y_max_main, areas_main def get_text_region_boxes_by_given_contours(contours):