-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Hi,
first of all thank you very much for this very useful kraken wrapper!
I encountered the following error when running the ocrd-kraken-segment command and setting the region to table:
21:02:36.551 ERROR ocrd.processor.base - Failure on page P_1781_057: 'TableRegionType' object has no attribute 'get_MapRegion'
Traceback (most recent call last):
File "/home/xy/workbench/projects/ocrd_yolo/.venv/lib/python3.10/site-packages/ocrd/processor/base.py", line 710, in process_workspace_handle_page_task
task.result()
File "/home/xy/workbench/projects/ocrd_yolo/.venv/lib/python3.10/site-packages/ocrd/processor/base.py", line 124, in result
return self.fn(*self.args, **self.kwargs)
File "/home/xy/workbench/projects/ocrd_yolo/.venv/lib/python3.10/site-packages/ocrd/processor/base.py", line 1157, in _page_worker
_page_worker_processor.process_page_file(*input_files)
File "/home/xy/workbench/projects/ocrd_yolo/.venv/lib/python3.10/site-packages/ocrd/processor/base.py", line 809, in process_page_file
result = self.process_page_pcgts(*input_pcgts, page_id=page_id)
File "/home/xy/workbench/projects/ocrd_yolo/.venv/lib/python3.10/site-packages/ocrd_kraken/segment.py", line 149, in process_page_pcgts
self._process_page(page_image, page_coords, region, page_id, zoom)
File "/home/xy/workbench/projects/ocrd_yolo/.venv/lib/python3.10/site-packages/ocrd_kraken/segment.py", line 202, in _process_page
res = self.predictor(page_id, page_image, getmask())
File "/home/xy/workbench/projects/ocrd_yolo/.venv/lib/python3.10/site-packages/ocrd_kraken/segment.py", line 173, in getmask
page.get_MapRegion() +
AttributeError: 'TableRegionType' object has no attribute 'get_MapRegion'. Did you mean: 'get_MathsRegion'?
The error is thrown on this line: https://github.com/OCR-D/ocrd_kraken/blob/master/ocrd_kraken/segment.py#L173
I fixed it locally for now by handling the regions creation in the else clause (type is a TableRegionType) and commenting the call get_MapRegion:
...
if isinstance(page, PageType):
regions = (page.get_TextRegion() +
page.get_ImageRegion() +
page.get_LineDrawingRegion() +
page.get_GraphicRegion() +
page.get_ChartRegion() +
page.get_MapRegion() +
page.get_MathsRegion() +
page.get_ChemRegion() +
page.get_MusicRegion() +
page.get_AdvertRegion() +
page.get_NoiseRegion() +
page.get_UnknownRegion() +
page.get_CustomRegion())
if len(regions) == 0:
return None
if page.Border is None:
border = BorderType(CoordsType(points="0,0 0,%d %d,%d %d,0" % (
page.get_imageHeight(), page.get_imageWidth(),
page.get_imageHeight(), page.get_imageWidth())))
else:
border = page.Border
poly = coordinates_of_segment(border, page_image, page_coords)
else:
regions = (page.get_TextRegion() +
page.get_ImageRegion() +
page.get_LineDrawingRegion() +
page.get_GraphicRegion() +
page.get_ChartRegion() +
# Commenting this this page.get_MapRegion() +
page.get_MathsRegion() +
page.get_ChemRegion() +
page.get_MusicRegion() +
page.get_AdvertRegion() +
page.get_NoiseRegion() +
page.get_UnknownRegion() +
page.get_CustomRegion())
...
But I'm not really sure if this would be a long-term solution.
Best regards,
Constantin
Metadata
Metadata
Assignees
Labels
No labels