From 6576ff79d4ca0585829434ad58a665fc281eeb74 Mon Sep 17 00:00:00 2001 From: Felix Date: Fri, 5 Nov 2021 09:33:53 +0100 Subject: [PATCH 1/2] fix docstring and export as xml dim bug --- doctr/io/elements.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doctr/io/elements.py b/doctr/io/elements.py index a1ea3b69ba..8b72c02c04 100644 --- a/doctr/io/elements.py +++ b/doctr/io/elements.py @@ -211,7 +211,7 @@ class Page(Element): Args: blocks: list of block elements page_idx: the index of the page in the input raw document - dimensions: the page size in pixels in format (width, height) + dimensions: the page size in pixels in format (height, width) orientation: a dictionary with the value of the rotation angle in degress and confidence of the prediction language: a dictionary with the language value and confidence of the prediction """ @@ -276,7 +276,7 @@ def export_as_xml(self, file_title: str = 'docTR - XML export (hOCR)') -> Tuple[ block_count: int = 1 line_count: int = 1 word_count: int = 1 - width, height = self.dimensions + height, width = self.dimensions language = self.language if 'language' in self.language.keys() else 'en' # Create the XML root element page_hocr = ETElement('html', attrib={'xmlns': 'http://www.w3.org/1999/xhtml', 'xml:lang': str(language)}) From 8af56dba29d7a54e74a33e6dc6f405361ac9b523 Mon Sep 17 00:00:00 2001 From: Felix Date: Fri, 5 Nov 2021 10:59:34 +0100 Subject: [PATCH 2/2] apply changes --- doctr/utils/visualization.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doctr/utils/visualization.py b/doctr/utils/visualization.py index b88c791f6a..f4e0f617f5 100644 --- a/doctr/utils/visualization.py +++ b/doctr/utils/visualization.py @@ -34,7 +34,7 @@ def rect_patch( Args: geometry: bounding box of the element - page_dimensions: dimensions of the Page + page_dimensions: dimensions of the Page in format (height, width) label: label to display when hovered color: color to draw box alpha: opacity parameter to fill the boxes, 0 = transparent @@ -80,7 +80,7 @@ def polygon_patch( Args: geometry: bounding box of the element - page_dimensions: dimensions of the Page + page_dimensions: dimensions of the Page in format (height, width) label: label to display when hovered color: color to draw box alpha: opacity parameter to fill the boxes, 0 = transparent @@ -121,7 +121,7 @@ def create_obj_patch( Args: geometry: bounding box (straight or rotated) of the element - page_dimensions: dimensions of the page + page_dimensions: dimensions of the page in format (height, width) Returns: a matplotlib Patch @@ -273,8 +273,8 @@ def synthesize_page( for word in line["words"]: # Get aboslute word geometry (xmin, ymin), (xmax, ymax) = word["geometry"] - xmin, xmax = int(w * xmin), int(w * xmax) - ymin, ymax = int(h * ymin), int(h * ymax) + xmin, xmax = int(round(w * xmin)), int(round(w * xmax)) + ymin, ymax = int(round(h * ymin)), int(round(h * ymax)) # White drawing context adapted to font size, 0.75 factor to convert pts --> pix font = get_font(font_family, int(0.75 * (ymax - ymin)))