From f7d3e396921c04f7d463db7d7b858f7294313937 Mon Sep 17 00:00:00 2001 From: Matthias Bisping Date: Tue, 8 Feb 2022 15:05:12 +0100 Subject: [PATCH] nix dolles --- vidocp/layout_detection.py | 1 + vidocp/table_parsing.py | 7 +++---- vidocp/utils/draw.py | 29 ----------------------------- 3 files changed, 4 insertions(+), 33 deletions(-) diff --git a/vidocp/layout_detection.py b/vidocp/layout_detection.py index d559df0..1d49684 100644 --- a/vidocp/layout_detection.py +++ b/vidocp/layout_detection.py @@ -23,6 +23,7 @@ def find_layout_boxes(image: np.array): contours = cv2.findContours(img_bin_final, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) contours = imutils.grab_contours(contours) + for c in contours: peri = cv2.arcLength(c, True) approx = cv2.approxPolyDP(c, 0.04 * peri, True) diff --git a/vidocp/table_parsing.py b/vidocp/table_parsing.py index 580b2f3..2ead96c 100644 --- a/vidocp/table_parsing.py +++ b/vidocp/table_parsing.py @@ -6,10 +6,9 @@ import cv2 import numpy as np from pdf2image import pdf2image -from vidocp.utils.display import show_mpl, show_cv2 -from vidocp.utils.draw import draw_stats, draw_rectangles -from vidocp.utils.filters import is_large_enough -from vidocp.utils.post_processing import remove_isolated, xywh_to_vecs, xywh_to_vec_rect, vecs_to_vec_rect, adjacent1d +from vidocp.utils.display import show_mpl +from vidocp.utils.draw import draw_rectangles +from vidocp.utils.post_processing import xywh_to_vecs, xywh_to_vec_rect, adjacent1d, remove_isolated def add_external_contours(image, img): diff --git a/vidocp/utils/draw.py b/vidocp/utils/draw.py index 7b23f0d..2f7ef06 100644 --- a/vidocp/utils/draw.py +++ b/vidocp/utils/draw.py @@ -30,32 +30,3 @@ def draw_rectangles(image, rectangles, color=None, annotate=False): annotate_rect(x, y, w, h) return image - - -def draw_stats(image, stats, annotate=False): - - keys = ["x", "y", "w", "h"] - - def annotate_stat(x, y, w, h): - - for i, (s, v) in enumerate(zip(keys, [x, y, w, h])): - anno = f"{s} = {v}" - xann = int(x + 5) - yann = int(y + h - (20 * (i + 1))) - cv2.putText(image, anno, (xann, yann), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 255, 0), 2) - - def draw_stat(stat): - - x, y, w, h, area = stat - - cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2) - - if annotate: - annotate_stat(x, y, w, h) - - image = copy_and_normalize_channels(image) - - for stat in stats[2:]: - draw_stat(stat) - - return image