okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge commit 'b8d604d28' into f-clean-1ab0fc432ed

main
986 B18 linesraw
1"""q36_venc.py EXE MMPROJ MODEL IMG [IMG ...] : drive strata-vision (ENC protocol), print each picture's header + stats."""
2import subprocess, sys, struct, os
3exe, mm, model, *imgs = sys.argv[1:]
4args = [exe, "--mmproj", mm, "--model", model] + [a for a in os.environ.get("STRATA_VARGS", os.environ.get("VARGS", "")).split() if a]
5p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True)
6print(p.stdout.readline().strip())
7for img in imgs:
8    out = img + ".sve"
9    p.stdin.write(f"ENC {img} {out}\n"); p.stdin.flush()
10    r = p.stdout.readline().strip()
11    print(img, r)
12    if r.startswith("OK"):
13        d = open(out, "rb").read()
14        magic, n, nx, ny, ne = struct.unpack("<5i", d[:20])
15        import array
16        a = array.array("f"); a.frombytes(d[20:])
17        print("  hdr", hex(magic), n, nx, ny, ne, "floats", len(a), "mean %.5f" % (sum(a) / len(a)), "first", [round(x, 4) for x in a[:6]])
18p.stdin.write("QUIT\n"); p.stdin.flush(); p.wait()