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

image_from_*: increase tolerance for size mismatch after rotation to 2px #371

Merged
merged 1 commit into from
Dec 18, 2019
Merged
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
13 changes: 7 additions & 6 deletions ocrd/ocrd/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,8 @@ def image_from_page(self, page, page_id,
[page_xywh['w'], page_xywh['h']], skew)
# FIXME we should enforce consistency here (i.e. rotation always reshapes,
# and rescaling never happens)
if not (w_new - 1.5 < page_image.width < w_new + 1.5 and
h_new - 1.5 < page_image.height < h_new + 1.5):
if not (w_new - 2 < page_image.width < w_new + 2 and
h_new - 2 < page_image.height < h_new + 2):
log.error('page "%s" image (%s; %dx%d) has not been reshaped properly (%dx%d) during rotation',
page_id, page_coords['features'],
page_image.width, page_image.height,
Expand Down Expand Up @@ -741,15 +741,16 @@ def image_from_segment(self, segment, parent_image, parent_coords,
# and rescaling never happens)
w_new, h_new = adjust_canvas_to_rotation(
[segment_xywh['w'], segment_xywh['h']], skew)
if not (w_new - 1.5 < segment_image.width < w_new + 1.5 and
h_new - 1.5 < segment_image.height < h_new + 1.5):
if not (w_new - 2 < segment_image.width < w_new + 2 and
h_new - 2 < segment_image.height < h_new + 2):
log.error('segment "%s" image (%s; %dx%d) has not been reshaped properly (%dx%d) during rotation',
segment.id, segment_coords['features'],
segment_image.width, segment_image.height,
w_new, h_new)
else:
if not (segment_xywh['w'] - 1.5 < segment_image.width < segment_xywh['w'] + 1.5 and
segment_xywh['h'] - 1.5 < segment_image.height < segment_xywh['h'] + 1.5):
# FIXME: currently unavoidable with line-level dewarping (which increases height)
if not (segment_xywh['w'] - 2 < segment_image.width < segment_xywh['w'] + 2 and
segment_xywh['h'] - 2 < segment_image.height < segment_xywh['h'] + 2):
log.error('segment "%s" image (%s; %dx%d) has not been cropped properly (%dx%d)',
segment.id, segment_coords['features'],
segment_image.width, segment_image.height,
Expand Down