"""Evaluate a line detector (YOLO or kraken BLLA) on validation pages, and run it end to end with the A1 line recognizer. Detection: precision, recall and F1 of line boxes at IoU 0.5 and 0.75 (greedy matching by descending box score; micro over pages), recall of text pixels (ink pixels inside the ground-truth line polygons that fall inside a predicted box), mean time per page, and the per-line box scores (kept in the per-page JSONL). End to end (--read A1:long): every detected box is cut from the page (school pages: from the full-resolution photograph), read by the recognizer, and the page text is compared with the reference lines: reading-order page CER (M28 of eval_spec.json: lines sorted by (centre_y // 15, centre_x), joined by one space) and order-free page CER (hypothesis and reference lines matched one to one by minimum edit distance with the Hungarian method; unmatched hypothesis lines count as insertions, unmatched reference lines as deletions: metric M29 of records/R5/RESEVAL/eval_spec.json, rule gap G5). Validation pages only. Usage: python -m linedet.det_eval --kind yolo --weights --pages --name