From 062456c25f078c3296c927640eb977dc828631ad Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 28 Dec 2020 14:35:59 +0100 Subject: export-carriage: double decker support --- lib/export-carriage.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/export-carriage.py b/lib/export-carriage.py index 88797b2..a0f6571 100755 --- a/lib/export-carriage.py +++ b/lib/export-carriage.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import numpy as np +import os import subprocess import sys @@ -43,8 +44,19 @@ def main(infile, *outfiles): ys = list() for o in objects: - if o.is_path() and o.h > 2 and o.h < 4 and o.w > 10: + if o.is_path() and o.h > 2 and o.h < 4 and o.w > 9: ys.append(o.y) + + ys = np.array(ys, dtype=np.int64) + + if "double_decker_export" in os.environ: + # the first object is the "svg2" element describing the entire document + split = objects[0].h * 0.6 + if os.environ["double_decker_export"] == "lower": + ys = ys[ys >= split] + else: + ys = ys[ys <= split] + bins = np.bincount(ys) candidates = list(filter(lambda i: bins[i] > 2, range(len(bins)))) -- cgit v1.2.3