From 4a1ef5ca27f4a9f5eb5d466a45adc4acbdff8b66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Cl=C3=A9rice?= Date: Mon, 10 Jun 2024 08:44:29 +0200 Subject: [PATCH] Fixes serialization of dummy boxes Fixes #611 --- kraken/serialization.py | 4 ++-- kraken/templates/alto | 2 +- kraken/templates/pagexml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kraken/serialization.py b/kraken/serialization.py index fb2b8ef69..639f09d48 100644 --- a/kraken/serialization.py +++ b/kraken/serialization.py @@ -152,8 +152,8 @@ def serialize(results: 'Segmentation', reg = reg_dict[record.regions[0]] regs_with_lines.add(reg.id) region = {'id': reg.id, - 'bbox': max_bbox([reg.boundary]), - 'boundary': [list(x) for x in reg.boundary], + 'bbox': max_bbox([reg.boundary]) if reg.boundary else [], + 'boundary': [list(x) for x in reg.boundary] if reg.boundary else [], 'tags': reg.tags, 'lines': [], 'type': 'region' diff --git a/kraken/templates/alto b/kraken/templates/alto index 9d648b1e9..6e093c42f 100644 --- a/kraken/templates/alto +++ b/kraken/templates/alto @@ -107,7 +107,7 @@ {% if loop.previtem and loop.previtem.type == 'line' %} {% endif %} - + diff --git a/kraken/templates/pagexml b/kraken/templates/pagexml index 6274eaf64..417c8538b 100644 --- a/kraken/templates/pagexml +++ b/kraken/templates/pagexml @@ -39,7 +39,7 @@ {% endif %} - + {% if entity.boundary %}{% endif %} {%- for line in entity.lines -%} {{ render_line(line) }} {%- endfor %}