Generalized from the render lanes' proven tools: map segmentation, 2.5D massing by wealth zone, a CPU ray marcher with analytic landmarks and true-scale proxy people, prompt composition from blocks, a self-calibrating batch submitter with a renderer adapter point, the plate-vs-frame gates (drift, ECC, landmark region, skyline and invented structures, figure brackets, corner sweep), matrix job builders, a cost line, and an end-to-end smoke test on a synthetic town.
78 lines
3.2 KiB
Python
78 lines
3.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Contact sheets for the eye check: plate | pick | pick with landmark outline, with the gate numbers as a caption.
|
|
|
|
usage: qc_sheet.py --config citykit.json --picks picks.json --gates out_day/qc/gate_out_day.json --out qc_plates.jpg [V ...]
|
|
picks.json: {"V": {"day": "V_day_t2", "sunset": "V_sunset_t1"}, ...}
|
|
Thumbnail every batch of same-tier exteriors at this size before calling it done: "geometry-true" is not the
|
|
same as "recognizable" (seven houses on one wealth rung come out as seven identical barns without a character pass).
|
|
"""
|
|
import argparse
|
|
import json
|
|
import os
|
|
|
|
from PIL import Image, ImageDraw, ImageFont
|
|
|
|
from citykit import load_config, resolve
|
|
|
|
try:
|
|
FB = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 26)
|
|
FS = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 20)
|
|
except OSError:
|
|
FB = FS = ImageFont.load_default()
|
|
|
|
|
|
def lab(d, xy, t, f=FS, fill=(255, 255, 0)):
|
|
d.text(xy, t, fill=fill, font=f, stroke_width=3, stroke_fill=(0, 0, 0))
|
|
|
|
|
|
def gate_line(QA, fid):
|
|
r = QA.get(fid, {})
|
|
return "grad_corr %s · ECC scale %s · shift %s/%s px · landmark corr %s · invented %s" % (
|
|
r.get("grad_corr"), r.get("scale"), r.get("tx_px"), r.get("ty_px"), r.get("landmark_grad_corr"),
|
|
r.get("invented_structures_n", "-"))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
ap.add_argument("views", nargs="*")
|
|
ap.add_argument("--config", required=True)
|
|
ap.add_argument("--picks", required=True)
|
|
ap.add_argument("--gates", required=True)
|
|
ap.add_argument("--frames", required=True, help="dir holding the take PNGs")
|
|
ap.add_argument("--out", required=True)
|
|
ap.add_argument("--title", default="plates vs picks")
|
|
a = ap.parse_args()
|
|
cfg = load_config(a.config)
|
|
plates = resolve(cfg, cfg.get("plates_dir", "plates"))
|
|
PICKS = json.load(open(a.picks))
|
|
QA = json.load(open(a.gates))
|
|
qc = os.path.join(a.frames, "qc")
|
|
views = a.views or list(PICKS)
|
|
w, h = 640, 360
|
|
rows = []
|
|
for v in views:
|
|
p = PICKS[v]
|
|
fid = p["day"] if isinstance(p, dict) else p
|
|
ims = [(Image.open(os.path.join(plates, v + "_mass.png")), "block-model plate (IMAGE 1)"),
|
|
(Image.open(os.path.join(a.frames, fid + ".png")), "pick " + fid)]
|
|
geo = os.path.join(qc, fid + "_geo.jpg")
|
|
if os.path.exists(geo):
|
|
ims.append((Image.open(geo), "pick + landmark outline from the model (cyan)"))
|
|
R = Image.new("RGB", (3 * w + 16, h + 64), (20, 20, 20))
|
|
d = ImageDraw.Draw(R)
|
|
for i, (im, t) in enumerate(ims):
|
|
R.paste(im.convert("RGB").resize((w, h)), (i * (w + 8), 34))
|
|
lab(d, (i * (w + 8) + 6, 38), t)
|
|
lab(d, (6, 4), "%s: %s" % (v, gate_line(QA, fid)), FS, (255, 255, 255))
|
|
rows.append(R)
|
|
H = sum(r.height for r in rows)
|
|
S = Image.new("RGB", (rows[0].width, H + 50), (20, 20, 20))
|
|
d = ImageDraw.Draw(S)
|
|
lab(d, (10, 8), a.title, FB, (255, 255, 255))
|
|
y = 50
|
|
for r in rows:
|
|
S.paste(r, (0, y))
|
|
y += r.height
|
|
S.save(a.out, quality=88)
|
|
print("wrote", a.out)
|