# -*- coding: utf-8 -*-
# 只读本目录合成输入，不联网、不修改设备。
import csv
from pathlib import Path
for r in csv.DictReader((Path(__file__).parent/'synthetic.csv').open(encoding='utf-8-sig')):
    sx,sy,sw,sh,bx,by,bw,bh=(int(r[k]) for k in ['safe_x','safe_y','safe_w','safe_h','box_x','box_y','box_w','box_h'])
    inside=bx>=sx and by>=sy and bx+bw<=sx+sw and by+bh<=sy+sh
    assert inside==(r['expected_inside']=='yes')
    print(r['orientation'],'包含' if inside else '越界')
print('仅验证合成矩形，不验证文字渲染、遮挡或可读性。')
