22 lines
930 B
Python
22 lines
930 B
Python
import sys, json, contextlib, io
|
|
sys.path.insert(0, ".")
|
|
from pathlib import Path
|
|
import smart_extractor as se
|
|
from _lines import separator_barriers, detect_separator_lines
|
|
|
|
D = Path("output/AndhraJyothi_Siddipet District_20260602_20260603_144919/pages")
|
|
png = D / "page_001.png"
|
|
regs0 = json.loads((D / "page_001.regions.json").read_text())["regions"]
|
|
with contextlib.redirect_stdout(io.StringIO()):
|
|
regs = se.drop_masthead_regions(regs0, "andhra_jyothi", 1, png)
|
|
|
|
res = detect_separator_lines(png)
|
|
print(f"=== {len(res['h'])} raw horizontal lines ===")
|
|
for L in sorted(res["h"], key=lambda d: d["y1"]):
|
|
print(f" H y={L['y1']:>5} x[{L['x1']:>4}..{L['x2']:>4}] len={L['len']:>4} gray={L['gray']}")
|
|
|
|
print("\n=== separator_barriers (after filters) ===")
|
|
bars = separator_barriers(str(png), regs)
|
|
for L in sorted(bars, key=lambda d: d["y"]):
|
|
print(f" bar y={L['y']:>5} x[{L['x1']:>4}..{L['x2']:>4}] mc={L.get('mc')}")
|