Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
docrecJSON-utilities
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marc-Philipp Knechtle
docrecJSON-utilities
Commits
4a6d6013
Commit
4a6d6013
authored
2 years ago
by
Marc-Philipp Knechtle
Browse files
Options
Downloads
Patches
Plain Diff
add table bbox extraction mechanism
parent
24b99933
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docrecutils/tables.py
+13
-1
13 additions, 1 deletion
docrecutils/tables.py
with
13 additions
and
1 deletion
docrecutils/tables.py
+
13
−
1
View file @
4a6d6013
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
)]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment