Add build, deploy and test sources
This commit is contained in:
1 parent
b962581812
commit
3d1a08f230
259 files changed
+15273
No files matched your search
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
python3 - <<'EOF'
|
||||
import numpy as np
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
bmp = Image.open('/mnt/f/efi/Paravis/Boot/xor/Main1.bmp').convert('L')
|
||||
|
||||
def cmp(cropbox, text, path, size, stroke=0):
|
||||
crop = bmp.crop(cropbox)
|
||||
A = np.array(crop) < 128
|
||||
ys, xs = np.where(A)
|
||||
T = A[ys.min():ys.max()+1, xs.min():xs.max()+1]
|
||||
f = ImageFont.truetype(path, size)
|
||||
img = Image.new('L', (800, 100), 255)
|
||||
ImageDraw.Draw(img).text((20, 20), text, font=f, fill=0, stroke_width=stroke, stroke_fill=0)
|
||||
m = np.array(img) < 128
|
||||
ys2, xs2 = np.where(m)
|
||||
B = m[ys2.min():ys2.max()+1, xs2.min():xs2.max()+1]
|
||||
ha, wa = T.shape; hb, wb = B.shape; best = 0
|
||||
for dy in range(-4, 5):
|
||||
for dx in range(-5, 6):
|
||||
y0 = max(0, dy); x0 = max(0, dx)
|
||||
y1 = min(ha, hb+dy); x1 = min(wa, wb+dx)
|
||||
if y1 <= y0 or x1 <= x0: continue
|
||||
s1 = T[y0:y1, x0:x1]; s2 = B[y0-dy:y1-dy, x0-dx:x1-dx]
|
||||
u = np.logical_or(s1, s2).sum()
|
||||
if u: best = max(best, np.logical_and(s1, s2).sum()/u)
|
||||
return T.shape, B.shape, best
|
||||
|
||||
tests = [
|
||||
('Перезагрузка (R)', (44, 620, 240, 650)),
|
||||
('Super Grub2 (поиск и запуск ОС)', (44, 126, 470, 155)),
|
||||
]
|
||||
fonts = {
|
||||
'SegoeUI-Semibold23': ('/mnt/c/Windows/Fonts/seguisb.ttf', 23),
|
||||
'SegoeUI-Bold22': ('/mnt/c/Windows/Fonts/segoeuib.ttf', 22),
|
||||
'SegoeUI23': ('/mnt/c/Windows/Fonts/segoeui.ttf', 23),
|
||||
'Ubuntu23': ('/mnt/d/GIT/aspia_no2fa-3.0/vcpkg4aspia/buildtrees/harfbuzz/src/14.2.1-f76ca539fc.clean/test/subset/data/fonts/Ubuntu-Regular.ttf', 23),
|
||||
'Roboto23': ('/mnt/d/GIT/aspia_no2fa-3.0/vcpkg4aspia/buildtrees/harfbuzz/src/14.2.1-f76ca539fc.clean/test/subset/data/fonts/Roboto-Regular.ttf', 23),
|
||||
}
|
||||
for t, box in tests:
|
||||
print('==', t)
|
||||
for name,(path,size) in fonts.items():
|
||||
try:
|
||||
ts, bs, s = cmp(box, t, path, size)
|
||||
print(f' {name:22s} target={ts} rendered={bs} IoU={s:.3f}')
|
||||
except Exception as e:
|
||||
print(' ', name, 'err', e)
|
||||
EOF
|
||||
Reference in new issue
Block a user