From ba32b3bcbed2021fe8a402fd4fa4971767167695 Mon Sep 17 00:00:00 2001 From: llocarnini Date: Wed, 26 Jan 2022 10:47:41 +0100 Subject: [PATCH] deleted some unused line of code --- table_parsing/table_parsig.py | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/table_parsing/table_parsig.py b/table_parsing/table_parsig.py index 7f558bd..e90b8b9 100644 --- a/table_parsing/table_parsig.py +++ b/table_parsing/table_parsig.py @@ -44,36 +44,6 @@ def annotate_image(image, stats): def parse_tables_in_pdf(pages): return zip(map(parse, pages), count()) -# def parse(image: np.array): -# gray_scale = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) -# th1, img_bin = cv2.threshold(gray_scale, 150, 225, cv2.THRESH_BINARY) -# img_bin = ~img_bin -# -# line_min_width = 4 -# kernel_h = np.ones((1, line_min_width), np.uint8) -# kernel_v = np.ones((line_min_width, 1), np.uint8) -# -# img_bin_h = cv2.morphologyEx(img_bin, cv2.MORPH_OPEN, kernel_h) -# img_bin_v = cv2.morphologyEx(img_bin, cv2.MORPH_OPEN, kernel_v) -# -# img_bin_final = img_bin_h | img_bin_v -# -# _, labels, stats, _ = cv2.connectedComponentsWithStats(~img_bin_final, connectivity=8, ltype=cv2.CV_32S) -# -# return labels, stats -# -# def annotate_image(image, stats): -# for x, y, w, h, area in stats[2:]: -# if w > 10 and h > 10: -# cv2.rectangle(image, (x, y), (x + w, y + h), (255, 0, 255), 2) -# -# for i, (s, v) in enumerate(zip(["x", "y", "w", "h"], [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, (255, 0, 255), 2) -# -# return image def annotate_tables_in_pdf(pdf_path, page_index=1): @@ -90,7 +60,7 @@ def annotate_tables_in_pdf(pdf_path, page_index=1): #annotate_tables_in_pdf("/home/lillian/table_parsing/pdfs/pdfs_syngenta/026c917f04660aaea4bb57d180f9598b.pdf", 4) #annotate_tables_in_pdf("/home/lillian/table_parsing/pdfs/pdfs_syngenta/8dc4a4bf9c439eb402adfa2c53ce5c0c.pdf", 8) -annotate_tables_in_pdf("/home/lillian/table_parsing/pdfs/pdfs_efsa/Quartz sand_RAR_13_Volume_3CP_Repentol6PA_B2_2021_03_24.pdf", 6) +#annotate_tables_in_pdf("/home/lillian/table_parsing/pdfs/pdfs_efsa/Quartz sand_RAR_13_Volume_3CP_Repentol6PA_B2_2021_03_24.pdf", 6) # annotate_tables_in_pdf("/home/lillian/table_parsing/pdfs/pdfs_efsa/Sulphur_RAR_18_Volume_3CP_SULFUR 80_ WG_B-8_2021-04-09.pdf", 24) # annotate_tables_in_pdf("/home/lillian/table_parsing/pdfs/pdfs_efsa/Sulphur_RAR_18_Volume_3CP_SULFUR 80_ WG_B-8_2021-04-09.pdf", 5) -#annotate_tables_in_pdf("/home/lillian/table_parsing/pdfs/pdfs_efsa/Sulphur_RAR_18_Volume_3CP_SULFUR 80_ WG_B-8_2021-04-09.pdf", 16) \ No newline at end of file +annotate_tables_in_pdf("/home/lillian/table_parsing/pdfs/Dokument6.pdf", 0) \ No newline at end of file