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

Fixes serialization of dummy boxes #612

Merged
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions kraken/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion kraken/templates/alto
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
{% if loop.previtem and loop.previtem.type == 'line' %}
</TextBlock>
{% endif %}
<TextBlock ID="{{ entity.id }}" HPOS="{{ entity.bbox[0] }}" VPOS="{{ entity.bbox[1] }}" WIDTH="{{ entity.bbox[2] - entity.bbox[0] }}" HEIGHT="{{ entity.bbox[3] - entity.bbox[1] }}" {% if entity.tags %}{% for type in page.region_types %}{% if type in entity.tags.values() %}TAGREFS="REGION_TYPE_{{ loop.index }}"{% endif %}{% endfor %}{% endif %}>
<TextBlock ID="{{ entity.id }}" {% if entity.bbox %}HPOS="{{ entity.bbox[0] }}" VPOS="{{ entity.bbox[1] }}" WIDTH="{{ entity.bbox[2] - entity.bbox[0] }}" HEIGHT="{{ entity.bbox[3] - entity.bbox[1] }}"{% endif %} {% if entity.tags %}{% for type in page.region_types %}{% if type in entity.tags.values() %}TAGREFS="REGION_TYPE_{{ loop.index }}"{% endif %}{% endfor %}{% endif %}>
<Shape>
<Polygon POINTS="{{ entity.boundary|sum(start=[])|join(' ') }}"/>
</Shape>
Expand Down
2 changes: 1 addition & 1 deletion kraken/templates/pagexml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</TextRegion>
{% endif %}
<TextRegion id="{{ entity.id }}" custom="structure {type:{{ entity.region_type }};}">
<Coords points="{% for point in entity.boundary %}{{ point|join(',') }}{% if not loop.last %} {% endif %}{% endfor %}"/>
{% if entity.boundary %}<Coords points="{% for point in entity.boundary %}{{ point|join(',') }}{% if not loop.last %} {% endif %}{% endfor %}"/>{% endif %}
{%- for line in entity.lines -%}
{{ render_line(line) }}
{%- endfor %}
Expand Down