nix dolles

This commit is contained in:
Matthias Bisping 2022-02-08 15:05:12 +01:00
parent 87cecadb44
commit f7d3e39692
3 changed files with 4 additions and 33 deletions

View File

@ -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)

View File

@ -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):

View File

@ -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