Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Fixed docstring and export as xml dim bug #586

Merged
merged 2 commits into from
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doctr/io/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down Expand Up @@ -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)})
Expand Down
10 changes: 5 additions & 5 deletions doctr/utils/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)))
Expand Down