Skip to content

Commit

Permalink
fix transcription interface tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mittagessen committed Oct 20, 2024
1 parent 99e8e58 commit 5a2af52
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tests/test_transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from lxml import etree
from PIL import Image

from kraken import containers
from kraken.transcribe import TranscriptionInterface

thisfile = Path(__file__).resolve().parent
Expand All @@ -18,16 +19,25 @@ class TestTranscriptionInterface(unittest.TestCase):
"""
Test of the transcription interface generation
"""
def setUp(self):
with open(resources /'records.json', 'r') as fp:
self.box_records = [containers.BBoxOCRRecord(**x) for x in json.load(fp)]

self.box_segmentation = containers.Segmentation(type='bbox',
imagename='foo.png',
text_direction='horizontal-lr',
lines=self.box_records,
script_detection=True,
regions={})

self.im = Image.open(resources / 'input.jpg')

def test_transcription_generation(self):
"""
Tests creation of transcription interfaces with segmentation.
"""
tr = TranscriptionInterface()
with open(resources / 'segmentation.json') as fp:
seg = json.load(fp)
with Image.open(resources / 'input.jpg') as im:
tr.add_page(im, seg)
tr.add_page(im = self.im, segmentation=self.box_segmentation)
fp = BytesIO()
tr.write(fp)
# this will not throw an exception ever so we need a better validator
Expand Down

0 comments on commit 5a2af52

Please sign in to comment.