Skip to content
Snippets Groups Projects
Commit 4a6d6013 authored by Marc-Philipp Knechtle's avatar Marc-Philipp Knechtle
Browse files

add table bbox extraction mechanism

parent 24b99933
Branches
No related tags found
No related merge requests found
from typing import List
from docrecjson.elements import Cell
from docrecjson.commontypes import Points
from docrecjson.elements import Cell, Table
import docrecutils.polygon_creations as polygon_creations
......@@ -31,3 +32,14 @@ def get_table_coordinates_from_cells(cells: List[Cell]) -> list:
min_y = min(all_y_values)
return polygon_creations.span_polygon((min_x, max_y), (max_x, min_y))
def get_table_bbox(table: Table):
"""
:param: table: table to extract the coordinates from
:return: [top_left_x, top_left_y, bottom_right_x, bottom_right_y]
"""
table_coordinates: Points = table.get_table_coordinates()
x_values = [x[0] for x in table_coordinates]
y_values = [x[0] for x in table_coordinates]
return [min(x_values), min(y_values), max(x_values), max(y_values)]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment