From decaa7b69f2bbee9c6947d50f55c5906319798ff Mon Sep 17 00:00:00 2001 From: "Gerber, Mike" Date: Mon, 3 Feb 2020 14:03:01 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Use=20polygon=5Ffrom=5Fx0y0x1y1?= =?UTF-8?q?=20to=20build=20word/glyph=20polygon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ocrd_calamari/recognize.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ocrd_calamari/recognize.py b/ocrd_calamari/recognize.py index ca68ebe..c5dba59 100644 --- a/ocrd_calamari/recognize.py +++ b/ocrd_calamari/recognize.py @@ -17,7 +17,11 @@ from ocrd_models.ocrd_page import ( WordType, GlyphType, CoordsType, to_xml ) -from ocrd_utils import getLogger, concat_padded, coordinates_for_segment, points_from_polygon, MIMETYPE_PAGE +from ocrd_utils import ( + getLogger, concat_padded, + coordinates_for_segment, points_from_polygon, polygon_from_x0y0x1y1, + MIMETYPE_PAGE +) from ocrd_calamari.config import OCRD_TOOL, TF_CPP_MIN_LOG_LEVEL @@ -111,9 +115,7 @@ class CalamariRecognize(Processor): word_start = word_positions[0].global_start word_end = word_positions[-1].global_end - # XXX Maybe use version in ocrd_tesserocr - h = line_image.height - polygon = [(word_start, 0), (word_end, 0), (word_end, h), (word_start, h)] + polygon = polygon_from_x0y0x1y1([word_start, 0, word_end, line_image.height]) points = points_from_polygon(coordinates_for_segment(polygon, None, line_coords)) word = WordType(id='%s_word%04d' % (line.id, word_no), Coords=CoordsType(points)) @@ -123,9 +125,7 @@ class CalamariRecognize(Processor): glyph_start = p.global_start glyph_end = p.global_end - # XXX Maybe use version in ocrd_tesserocr - h = line_image.height - polygon = [(glyph_start, 0), (glyph_end, 0), (glyph_end, h), (glyph_start, h)] + polygon = polygon_from_x0y0x1y1([glyph_start, 0, glyph_end, line_image.height]) points = points_from_polygon(coordinates_for_segment(polygon, None, line_coords)) glyph = GlyphType(id='%s_glyph%04d' % (word.id, glyph_no), Coords=CoordsType(points))