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

segment-line: validate intersection with parent #120

Merged
merged 2 commits into from
Apr 8, 2020
Merged
Changes from 1 commit
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
14 changes: 13 additions & 1 deletion ocrd_tesserocr/segment_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,19 @@ def process(self):
line_poly = Polygon(line_polygon)
if not line_poly.within(region_poly):
# this could happen due to rotation
line_poly = line_poly.intersection(region_poly).convex_hull
interline = line_poly.intersection(region_poly)
if interline.is_empty:
continue # ignore this line
if hasattr(interline, 'geoms'):
# is (heterogeneous) GeometryCollection
area = 0
for geom in interline.geoms:
if geom.area > area:
bertsky marked this conversation as resolved.
Show resolved Hide resolved
area = geom.area
interline = geom
if not area:
continue
line_poly = interline.convex_hull
line_polygon = line_poly.exterior.coords
line_polygon = coordinates_for_segment(line_polygon, region_image, region_coords)
line_points = points_from_polygon(line_polygon)
Expand Down