-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest_binarize.py
60 lines (48 loc) · 1.47 KB
/
test_binarize.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# pylint: disable=import-error
import os
import shutil
import pytest
from tests.base import assets, main
from ocrd import Resolver
from ocrd_kraken.binarize import KrakenBinarize
from ocrd_utils.logging import setOverrideLogLevel
setOverrideLogLevel('DEBUG')
PARAM_JSON = assets.url_of('param-binarize.json')
@pytest.fixture()
def workspace(tmpdir):
if os.path.exists(tmpdir):
shutil.rmtree(tmpdir)
workspace = Resolver().workspace_from_url(
assets.path_to('kant_aufklaerung_1784/data/mets.xml'),
dst_dir=tmpdir,
download=True
)
return workspace
# def test_param_json(self):
# workspace = resolver.workspace_from_url(assets.url_of('SBB0000F29300010000/data/mets_one_file.xml'), dst_dir=WORKSPACE_DIR)
# run_processor(
# KrakenBinarize,
# resolver=resolver,
# workspace=workspace,
# parameter=PARAM_JSON
# )
def test_binarize_regions(workspace):
proc = KrakenBinarize(
workspace,
input_file_grp="OCR-D-GT-PAGE",
output_file_grp="OCR-D-IMG-BIN-KRAKEN",
parameter={'level-of-operation': 'region'}
)
proc.process()
workspace.save_mets()
def test_binarize_lines(workspace):
proc = KrakenBinarize(
workspace,
input_file_grp="OCR-D-GT-PAGE",
output_file_grp="OCR-D-IMG-BIN-KRAKEN",
parameter={'level-of-operation': 'line'}
)
proc.process()
workspace.save_mets()
if __name__ == "__main__":
main(__file__)