Skip to content

fixing https://github.com/qurator-spk/eynollah/issues/169 : This fix actually resolves the error. Additionally, the contour with intersections no longer appears in the results.#221

Draft
kba wants to merge 1 commit into
OCR-D:masterfrom
vahidrezanezhad:master

Conversation

@kba
Copy link
Copy Markdown
Member

@kba kba commented Jul 15, 2025

For discussion: @vahidrezanezhad has a workaround for the multipolygon issue where eynollah produces polygons with self-intersections.

…r. Additionally, the contour with intersections no longer appears in the results.
@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 15, 2025

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.36%. Comparing base (c65b345) to head (67be590).

Files with missing lines Patch % Lines
ocrd_tesserocr/common.py 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #221      +/-   ##
==========================================
- Coverage   58.45%   58.36%   -0.09%     
==========================================
  Files          12       12              
  Lines        1372     1374       +2     
  Branches      323      325       +2     
==========================================
  Hits          802      802              
- Misses        434      435       +1     
- Partials      136      137       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@bertsky bertsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see how this would help – as a workaround.

But really, this is not the way to fix this. The code above in particular tries to avoid yielding multiple geometries – by finding the best path through all parts and connecting them with little "bridges". So if that failed, for some reason, we must fix that directly.

Could you please provide me with the input polygons that caused this?

Comment thread ocrd_tesserocr/common.py
jointp = unary_union(polygons)

if isinstance(jointp, MultiPolygon):
jointp = max(jointp.geoms, key=lambda p: p.area) # Choose the largest polygon
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One simple way to share example polygon data is by using Shapely's wkt serialization, which can easily be printed, plotted, re-imported etc. So here, e.g. if you do...

Suggested change
jointp = max(jointp.geoms, key=lambda p: p.area) # Choose the largest polygon
for geom in jointp.geoms:
print(geom.wkt)
jointp = max(jointp.geoms, key=lambda p: p.area) # Choose the largest polygon

...and then send me the stdout, that would really help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants