vibedgames 0.10.0 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/rebuild-object/.cache/spec-search/core_3d.json +1 -0
- package/assets/rebuild-object/.cache/spec-search/cs2.json +1 -0
- package/assets/rebuild-object/LICENSE +201 -0
- package/assets/rebuild-object/NOTICE +7 -0
- package/assets/rebuild-object/docs/materials/material-reference.json +2324 -0
- package/assets/rebuild-object/docs/specs/render-profile.v2.example.json +63 -0
- package/assets/rebuild-object/docs/specs/render-profile.v2.schema.json +56 -0
- package/assets/rebuild-object/docs/specs/vocabulary/README.md +86 -0
- package/assets/rebuild-object/docs/specs/vocabulary/core_3d.jsonl +12 -0
- package/assets/rebuild-object/docs/specs/vocabulary/core_3d_reconstruction.jsonl +37 -0
- package/assets/rebuild-object/docs/specs/vocabulary/cs2.jsonl +8 -0
- package/assets/rebuild-object/docs/specs/vocabulary/cs2_reconstruction.jsonl +62 -0
- package/assets/rebuild-object/forge/_shared/artifact_cache.py +54 -0
- package/assets/rebuild-object/forge/_shared/chirality.py +272 -0
- package/assets/rebuild-object/forge/_shared/color_metrics.py +107 -0
- package/assets/rebuild-object/forge/_shared/feature_acceptance_policy.py +113 -0
- package/assets/rebuild-object/forge/_shared/image_hash.py +113 -0
- package/assets/rebuild-object/forge/_shared/jpeg.py +448 -0
- package/assets/rebuild-object/forge/_shared/material_physics.py +253 -0
- package/assets/rebuild-object/forge/_shared/pipeline_routing.py +177 -0
- package/assets/rebuild-object/forge/_shared/scalp_field.py +302 -0
- package/assets/rebuild-object/forge/_shared/sdf_primitives.py +172 -0
- package/assets/rebuild-object/forge/_shared/spec_search.py +1792 -0
- package/assets/rebuild-object/forge/_shared/spec_search_profiles.json +58 -0
- package/assets/rebuild-object/forge/_shared/status_banner.py +35 -0
- package/assets/rebuild-object/forge/_shared/subdivision.py +232 -0
- package/assets/rebuild-object/forge/_shared/vertex_paint.py +236 -0
- package/assets/rebuild-object/forge/_shared/workflow_state.py +406 -0
- package/assets/rebuild-object/forge/materials/__init__.py +17 -0
- package/assets/rebuild-object/forge/materials/compatibility.py +106 -0
- package/assets/rebuild-object/forge/materials/reference.py +240 -0
- package/assets/rebuild-object/forge/next.py +116 -0
- package/assets/rebuild-object/forge/report.py +38 -0
- package/assets/rebuild-object/forge/requirements.txt +6 -0
- package/assets/rebuild-object/forge/stage1_intake/analyze_texture.py +255 -0
- package/assets/rebuild-object/forge/stage1_intake/bind_detail_properties.py +99 -0
- package/assets/rebuild-object/forge/stage1_intake/build_detail_inventory.py +349 -0
- package/assets/rebuild-object/forge/stage1_intake/camera_fitting_math.py +133 -0
- package/assets/rebuild-object/forge/stage1_intake/camera_fitting_solver.py +197 -0
- package/assets/rebuild-object/forge/stage1_intake/camera_fitting_types.py +291 -0
- package/assets/rebuild-object/forge/stage1_intake/camera_image_helpers.py +133 -0
- package/assets/rebuild-object/forge/stage1_intake/check_intake_correctness.py +116 -0
- package/assets/rebuild-object/forge/stage1_intake/check_reference_admission.py +203 -0
- package/assets/rebuild-object/forge/stage1_intake/cs2_foundation.py +139 -0
- package/assets/rebuild-object/forge/stage1_intake/cs2_manifest.py +230 -0
- package/assets/rebuild-object/forge/stage1_intake/cs2_review_contract.py +42 -0
- package/assets/rebuild-object/forge/stage1_intake/delight_albedo.py +352 -0
- package/assets/rebuild-object/forge/stage1_intake/detect_cs2.py +276 -0
- package/assets/rebuild-object/forge/stage1_intake/detect_reference_effects.py +275 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_cs2_textures.py +126 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_gradient_stops.py +149 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_hair_evidence.py +385 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_landmarks.py +456 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_part_color_recipe.py +496 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_pbr_evidence.py +843 -0
- package/assets/rebuild-object/forge/stage1_intake/fetch_cs2_metadata.py +147 -0
- package/assets/rebuild-object/forge/stage1_intake/label_glb_nodes.py +318 -0
- package/assets/rebuild-object/forge/stage1_intake/locate_cs2_vpk.py +73 -0
- package/assets/rebuild-object/forge/stage1_intake/material_region_analysis.py +227 -0
- package/assets/rebuild-object/forge/stage1_intake/probe_glb.py +357 -0
- package/assets/rebuild-object/forge/stage1_intake/probe_image.py +168 -0
- package/assets/rebuild-object/forge/stage1_intake/run_vision_adapter.py +45 -0
- package/assets/rebuild-object/forge/stage1_intake/search_specs.py +258 -0
- package/assets/rebuild-object/forge/stage1_intake/semantic_decomposition.py +119 -0
- package/assets/rebuild-object/forge/stage1_intake/solve_camera_pose.py +254 -0
- package/assets/rebuild-object/forge/stage2_spec/apply_material_analysis.py +192 -0
- package/assets/rebuild-object/forge/stage2_spec/cs2_adapters.py +62 -0
- package/assets/rebuild-object/forge/stage2_spec/derive_geometry.py +118 -0
- package/assets/rebuild-object/forge/stage2_spec/hair_profile.py +306 -0
- package/assets/rebuild-object/forge/stage2_spec/humanoid_proportions.py +214 -0
- package/assets/rebuild-object/forge/stage2_spec/new_pre_spec_assessment.py +343 -0
- package/assets/rebuild-object/forge/stage2_spec/new_sculpt_spec.py +2396 -0
- package/assets/rebuild-object/forge/stage2_spec/validate_sculpt_spec.py +2871 -0
- package/assets/rebuild-object/forge/stage3_build/bake_projected_texture.py +181 -0
- package/assets/rebuild-object/forge/stage3_build/decimate.py +272 -0
- package/assets/rebuild-object/forge/stage3_build/generate_threejs_factory.py +4099 -0
- package/assets/rebuild-object/forge/stage3_build/module_cache.py +155 -0
- package/assets/rebuild-object/forge/stage3_build/morph_targets.py +178 -0
- package/assets/rebuild-object/forge/stage3_build/orchestrate_passes.py +653 -0
- package/assets/rebuild-object/forge/stage3_build/uv_unwrap.py +622 -0
- package/assets/rebuild-object/forge/stage3_build/visual_hull.py +357 -0
- package/assets/rebuild-object/forge/stage4_review/_fit_divine_eye.py +64 -0
- package/assets/rebuild-object/forge/stage4_review/append_review.py +453 -0
- package/assets/rebuild-object/forge/stage4_review/attachment_anchor.py +349 -0
- package/assets/rebuild-object/forge/stage4_review/calibrate_eye.py +131 -0
- package/assets/rebuild-object/forge/stage4_review/check_part_coverage.py +298 -0
- package/assets/rebuild-object/forge/stage4_review/compare_region_passes.py +169 -0
- package/assets/rebuild-object/forge/stage4_review/correction_loop.py +258 -0
- package/assets/rebuild-object/forge/stage4_review/cs2_review.py +224 -0
- package/assets/rebuild-object/forge/stage4_review/diagnose_render.py +356 -0
- package/assets/rebuild-object/forge/stage4_review/diagnose_render_multi_angle.py +143 -0
- package/assets/rebuild-object/forge/stage4_review/divine_eye.py +461 -0
- package/assets/rebuild-object/forge/stage4_review/fit_params.py +381 -0
- package/assets/rebuild-object/forge/stage4_review/geometry_integrity.py +294 -0
- package/assets/rebuild-object/forge/stage4_review/hair_gate.py +216 -0
- package/assets/rebuild-object/forge/stage4_review/interior_difference.py +188 -0
- package/assets/rebuild-object/forge/stage4_review/joint_loops.py +209 -0
- package/assets/rebuild-object/forge/stage4_review/make_comparison_sheet.py +292 -0
- package/assets/rebuild-object/forge/stage4_review/material_comparator.py +181 -0
- package/assets/rebuild-object/forge/stage4_review/material_feedback.py +143 -0
- package/assets/rebuild-object/forge/stage4_review/material_gate.py +126 -0
- package/assets/rebuild-object/forge/stage4_review/material_views.py +184 -0
- package/assets/rebuild-object/forge/stage4_review/mesh_reference_compare.py +362 -0
- package/assets/rebuild-object/forge/stage4_review/multi_pass.py +102 -0
- package/assets/rebuild-object/forge/stage4_review/objectness.py +143 -0
- package/assets/rebuild-object/forge/stage4_review/pairwise_penetration.py +376 -0
- package/assets/rebuild-object/forge/stage4_review/per_feature.py +215 -0
- package/assets/rebuild-object/forge/stage4_review/render_bridge.py +556 -0
- package/assets/rebuild-object/forge/stage4_review/scalp_exposure.py +257 -0
- package/assets/rebuild-object/forge/stage4_review/self_intersection.py +592 -0
- package/assets/rebuild-object/forge/stage4_review/swept_arc_gate.py +336 -0
- package/assets/rebuild-object/forge/stage4_review/turntable_gate.py +415 -0
- package/assets/rebuild-object/forge/stage4_review/validate_render_profile.py +182 -0
- package/assets/rebuild-object/forge/stage4_review/vertex_region_gate.py +456 -0
- package/assets/rebuild-object/forge/stage4_review/vlm_gate.py +196 -0
- package/assets/rebuild-object/forge/stage5_rig/NOTES.md +149 -0
- package/assets/rebuild-object/forge/stage5_rig/__init__.py +6 -0
- package/assets/rebuild-object/forge/stage5_rig/emit_rig.py +420 -0
- package/assets/rebuild-object/forge/stage5_rig/geodesic_skinning.py +508 -0
- package/assets/rebuild-object/forge/stage5_rig/rig_spec.py +174 -0
- package/assets/rebuild-object/forge/stage5_rig/validate_rig_payload.py +195 -0
- package/assets/rebuild-object/forge/state.py +98 -0
- package/assets/rebuild-object/steps.json +381 -0
- package/dist/{chunk-FXXVXDTW.js → chunk-24TITAFS.js} +1 -1
- package/dist/{chunk-OGX4DKIS.js → chunk-2C5PG2QO.js} +1 -1
- package/dist/{chunk-HYOXGNWS.js → chunk-2DEVOKI7.js} +1 -1
- package/dist/{chunk-RRI23NK2.js → chunk-2GHPYT2P.js} +1 -1
- package/dist/{chunk-S7HYWITX.js → chunk-2HXGMXGC.js} +1 -1
- package/dist/{chunk-N2UHAQXC.js → chunk-36FORP7T.js} +0 -1
- package/dist/{chunk-VB4WLJR2.js → chunk-3IXRQTRF.js} +1 -1
- package/dist/{chunk-2KVQJKIZ.js → chunk-4ENHS32B.js} +23 -36
- package/dist/{chunk-SXYQL4GK.js → chunk-4YHA32OE.js} +1 -1
- package/dist/{chunk-4FJXCS3K.js → chunk-4ZGQKPK5.js} +1 -1
- package/dist/{chunk-SBXCK2I2.js → chunk-6CLUPFQA.js} +2 -2
- package/dist/{chunk-TXOE5UY5.js → chunk-7WTF2BA4.js} +1 -1
- package/dist/{chunk-R2WVORGD.js → chunk-AAXZNK4Z.js} +1 -1
- package/dist/{chunk-DOOQUFPG.js → chunk-ALLBT4FB.js} +1 -1
- package/dist/{chunk-HRKVAXNN.js → chunk-BAZDPPIG.js} +5 -5
- package/dist/{chunk-RPJR3S5S.js → chunk-CYDENLZ4.js} +5 -8
- package/dist/{chunk-I5LELJSK.js → chunk-DKSUD44G.js} +1 -1
- package/dist/{chunk-43P4U7CB.js → chunk-DWWSJKTE.js} +1 -1
- package/dist/{chunk-SUSX3QIA.js → chunk-E72TFJZP.js} +1 -1
- package/dist/{chunk-E3FJUPLT.js → chunk-EUAAQMUA.js} +2 -0
- package/dist/{chunk-U6DTE5IX.js → chunk-F7LYJSZE.js} +1 -1
- package/dist/{chunk-MEAO33XW.js → chunk-FMON3C74.js} +8 -8
- package/dist/{chunk-GLEW7VJQ.js → chunk-FPILHRLZ.js} +1 -1
- package/dist/{chunk-OPUCUUID.js → chunk-G63MXDX2.js} +4 -0
- package/dist/{chunk-4UU622RK.js → chunk-GGO6ZYYI.js} +1 -3
- package/dist/{chunk-2ZKS7V72.js → chunk-GZCRYYS6.js} +5 -5
- package/dist/{chunk-E7NDOZ27.js → chunk-LE4GVTYI.js} +8 -8
- package/dist/{chunk-RKS7SI5L.js → chunk-NO6KPV64.js} +1 -1
- package/dist/{chunk-KJK5CB6E.js → chunk-NXW3Z4Y4.js} +1 -1
- package/dist/{chunk-7RPLQWR2.js → chunk-OHOAZGO4.js} +1 -1
- package/dist/chunk-PYJNI5WD.js +83 -0
- package/dist/{chunk-NCX6LYNJ.js → chunk-Q4XAGTFX.js} +1 -1
- package/dist/{chunk-3UGGMFJJ.js → chunk-QMZBSVKF.js} +1 -1
- package/dist/{chunk-ABTUEIRC.js → chunk-QO66UBOS.js} +2 -2
- package/dist/{chunk-LONQWRTR.js → chunk-S4KVGQQO.js} +8 -8
- package/dist/{chunk-HX5Q63UA.js → chunk-T777EXAO.js} +1 -1
- package/dist/{chunk-UQ7VO6B3.js → chunk-TZZNRA3S.js} +1 -1
- package/dist/{chunk-CTY2WZQK.js → chunk-UC3QLWMQ.js} +1 -1
- package/dist/{chunk-MR5KIFI7.js → chunk-UDJH2RED.js} +3 -3
- package/dist/{chunk-ZHLPE6LI.js → chunk-UIKYK7KI.js} +1 -1
- package/dist/{chunk-KAGVI3CE.js → chunk-UJRSQO2B.js} +1 -1
- package/dist/{chunk-Q2QC6KAZ.js → chunk-V7LEYVXB.js} +29 -25
- package/dist/{chunk-DB7WVFS7.js → chunk-WRMQEXUC.js} +1 -1
- package/dist/{chunk-HSMG6U7J.js → chunk-WXSBNC67.js} +3 -9
- package/dist/{chunk-QLCVLCPM.js → chunk-X4QIOXNQ.js} +1 -1
- package/dist/{chunk-5YPLKGY3.js → chunk-Y6WHUK2O.js} +1 -1
- package/dist/{chunk-VZEJ2ZHE.js → chunk-Z3E7ORGQ.js} +5 -5
- package/dist/index.js +20 -20
- package/package.json +32 -22
- package/dist/{chunk-Q3XQPNF6.js → chunk-BN7TR6OR.js} +3 -3
- package/dist/{chunk-LORGE2NB.js → chunk-U2NCN5RO.js} +3 -3
- package/dist/{chunk-UPHB5HWO.js → chunk-VQTTSPA3.js} +3 -3
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Reference-grounded gradient-stop extractor. Pure stdlib.
|
|
3
|
+
|
|
4
|
+
Samples the TRUE colour gradient of a material along a structural axis directly from the
|
|
5
|
+
reference crop, so procedural texture STOPS are grounded in the photo instead of hand-guessed
|
|
6
|
+
(the root cause of the M9 Doppler "purple guessed → rendered blue" 4-iteration failure).
|
|
7
|
+
|
|
8
|
+
Method (Context Part 2.1): foreground-masked PER-BAND MEDIAN sampling — split the object into N
|
|
9
|
+
bands along the axis, take the median RGB per band (median resists specular outliers far better
|
|
10
|
+
than mean), convert to HSV, assign a deterministic hue name, and flag any violet/purple stop that
|
|
11
|
+
is blue-leaning (B > R) as `hueRisk: blue-collapse` (Context Part 2.3 — such a hue collapses to
|
|
12
|
+
blue under ACES/Reinhard tone-mapping; fix = magenta-lean R>=B + green crosstalk).
|
|
13
|
+
|
|
14
|
+
CLI: extract_gradient_stops.py <crop.png> [--axis u|v] [--stops N] [--json]
|
|
15
|
+
API: extract_gradient_stops(path, axis="u", stops=6) -> dict
|
|
16
|
+
"""
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import argparse
|
|
20
|
+
import colorsys
|
|
21
|
+
import json
|
|
22
|
+
import sys
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
from typing import Any
|
|
25
|
+
|
|
26
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
27
|
+
from extract_pbr_evidence import build_foreground_mask, load_image # noqa: E402
|
|
28
|
+
|
|
29
|
+
# Deterministic hue-name lookup over the HSV hue circle (degrees).
|
|
30
|
+
_HUE_NAMES = [
|
|
31
|
+
(15, "red"), (45, "orange"), (70, "yellow"), (165, "green"),
|
|
32
|
+
(195, "cyan"), (255, "blue"), (290, "violet"), (345, "magenta"), (360, "red"),
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def hue_name(h_deg: float) -> str:
|
|
37
|
+
for upper, name in _HUE_NAMES:
|
|
38
|
+
if h_deg < upper:
|
|
39
|
+
return name
|
|
40
|
+
return "red"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _median(values: list[int]) -> int:
|
|
44
|
+
if not values:
|
|
45
|
+
return 0
|
|
46
|
+
s = sorted(values)
|
|
47
|
+
return s[len(s) // 2]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def sample_banded_stops(
|
|
51
|
+
width: int,
|
|
52
|
+
height: int,
|
|
53
|
+
pixels: list[tuple[int, int, int, int]],
|
|
54
|
+
mask: list[bool],
|
|
55
|
+
axis: str,
|
|
56
|
+
stops: int,
|
|
57
|
+
) -> list[dict[str, Any]]:
|
|
58
|
+
"""Median RGB per band along the axis. axis 'u' = length/x, 'v' = height/y."""
|
|
59
|
+
span = width if axis == "u" else height
|
|
60
|
+
band = max(1, span // stops)
|
|
61
|
+
out: list[dict[str, Any]] = []
|
|
62
|
+
for b in range(stops):
|
|
63
|
+
lo = b * band
|
|
64
|
+
hi = span if b == stops - 1 else (b + 1) * band
|
|
65
|
+
rs: list[int] = []
|
|
66
|
+
gs: list[int] = []
|
|
67
|
+
bs: list[int] = []
|
|
68
|
+
for y in range(height):
|
|
69
|
+
for x in range(width):
|
|
70
|
+
coord = x if axis == "u" else y
|
|
71
|
+
if coord < lo or coord >= hi:
|
|
72
|
+
continue
|
|
73
|
+
idx = y * width + x
|
|
74
|
+
if idx >= len(mask) or not mask[idx]:
|
|
75
|
+
continue
|
|
76
|
+
r, g, bl, _a = pixels[idx]
|
|
77
|
+
rs.append(r)
|
|
78
|
+
gs.append(g)
|
|
79
|
+
bs.append(bl)
|
|
80
|
+
if not rs:
|
|
81
|
+
continue # empty band (no foreground) — skip, don't fabricate a colour
|
|
82
|
+
r, g, bl = _median(rs), _median(gs), _median(bs)
|
|
83
|
+
h, s, v = colorsys.rgb_to_hsv(r / 255.0, g / 255.0, bl / 255.0)
|
|
84
|
+
h_deg = h * 360.0
|
|
85
|
+
name = hue_name(h_deg)
|
|
86
|
+
stop: dict[str, Any] = {
|
|
87
|
+
"t": round((b + 0.5) / stops, 4),
|
|
88
|
+
"rgb": [r, g, bl],
|
|
89
|
+
"hsv": [round(h_deg, 1), round(s, 3), round(v, 3)],
|
|
90
|
+
"hueName": name,
|
|
91
|
+
}
|
|
92
|
+
# Hue-survival flag: a blue-leaning violet/purple (B > R) collapses to blue under
|
|
93
|
+
# tone-mapping. Suggest a magenta-lean correction (raise R above B + a little green).
|
|
94
|
+
if name in ("violet", "magenta", "blue") and bl > r and s > 0.15:
|
|
95
|
+
stop["hueRisk"] = "blue-collapse"
|
|
96
|
+
stop["suggestedRgb"] = [min(255, bl), max(g, int(bl * 0.25)), r]
|
|
97
|
+
out.append(stop)
|
|
98
|
+
return out
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def extract_gradient_stops(path: Path, axis: str = "u", stops: int = 6) -> dict[str, Any]:
|
|
102
|
+
width, height, pixels, warnings = load_image(path)
|
|
103
|
+
mask, _meta, mask_warnings = build_foreground_mask(width, height, pixels)
|
|
104
|
+
warnings.extend(mask_warnings)
|
|
105
|
+
band_stops = sample_banded_stops(width, height, pixels, mask, axis, stops)
|
|
106
|
+
# Collapse consecutive same-hue bands into named hue zones.
|
|
107
|
+
zones: list[dict[str, Any]] = []
|
|
108
|
+
for st in band_stops:
|
|
109
|
+
if zones and zones[-1]["hueName"] == st["hueName"]:
|
|
110
|
+
zones[-1]["tEnd"] = st["t"]
|
|
111
|
+
else:
|
|
112
|
+
zones.append({"hueName": st["hueName"], "tStart": st["t"], "tEnd": st["t"]})
|
|
113
|
+
return {
|
|
114
|
+
"axis": axis,
|
|
115
|
+
"requestedStops": stops,
|
|
116
|
+
"stops": band_stops,
|
|
117
|
+
"hueZones": zones,
|
|
118
|
+
"riskFlags": [s for s in band_stops if s.get("hueRisk")],
|
|
119
|
+
"warnings": warnings,
|
|
120
|
+
"reference": str(path.resolve()),
|
|
121
|
+
"note": "band-median stops grounded in the reference; feed to the texture painter instead "
|
|
122
|
+
"of hand-guessed STOPS. hueRisk=blue-collapse stops need a magenta-lean correction.",
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def main(argv: list[str]) -> int:
|
|
127
|
+
ap = argparse.ArgumentParser(description="Extract reference-grounded gradient stops (stdlib).")
|
|
128
|
+
ap.add_argument("crop", type=Path)
|
|
129
|
+
ap.add_argument("--axis", choices=["u", "v"], default="u")
|
|
130
|
+
ap.add_argument("--stops", type=int, default=6)
|
|
131
|
+
ap.add_argument("--json", action="store_true")
|
|
132
|
+
args = ap.parse_args(argv)
|
|
133
|
+
if not args.crop.exists():
|
|
134
|
+
print(f"error: {args.crop} not found", file=sys.stderr)
|
|
135
|
+
return 2
|
|
136
|
+
result = extract_gradient_stops(args.crop, axis=args.axis, stops=max(2, args.stops))
|
|
137
|
+
if args.json:
|
|
138
|
+
print(json.dumps(result, indent=2))
|
|
139
|
+
else:
|
|
140
|
+
print(f"axis={result['axis']} stops={len(result['stops'])}")
|
|
141
|
+
for s in result["stops"]:
|
|
142
|
+
risk = f" ⚠ {s['hueRisk']} → try rgb {s.get('suggestedRgb')}" if s.get("hueRisk") else ""
|
|
143
|
+
print(f" t={s['t']:<5} rgb={s['rgb']} {s['hueName']:<8} hsv={s['hsv']}{risk}")
|
|
144
|
+
print("hue zones:", " → ".join(z["hueName"] for z in result["hueZones"]))
|
|
145
|
+
return 0
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
if __name__ == "__main__":
|
|
149
|
+
raise SystemExit(main(sys.argv[1:]))
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Measure what a reference image actually says about its hair.
|
|
3
|
+
|
|
4
|
+
WHAT WAS MISSING. `faceLandmarks.hairline` has existed as a slot since v1.2 and no generator has
|
|
5
|
+
ever read it, because nothing ever filled it. Banded dark coverage -- the measurement that finally
|
|
6
|
+
localised a hair deficit to the mid band -- was run by hand, four times, and never became a script.
|
|
7
|
+
And nothing at all measured the SHADING, which is where the deficit turned out mostly to live.
|
|
8
|
+
|
|
9
|
+
WHY SHADING IS IN HERE AT ALL. The reference this pipeline calibrates against is a 570,400-vertex
|
|
10
|
+
merged scan whose hair surface roughness is 0.00338 against a torso control of 0.00312. Its hair is
|
|
11
|
+
a smooth shell; every strand it appears to have is in the diffuse and normal textures. A pipeline
|
|
12
|
+
that emits code and no textures cannot copy that with geometry, so the numbers worth extracting are
|
|
13
|
+
the ones a material can act on: where the highlight band sits, and how much darker the roots are
|
|
14
|
+
than the tips.
|
|
15
|
+
|
|
16
|
+
WHAT THIS DELIBERATELY DOES NOT DO. It does not guess lock geometry. A single image does not carry
|
|
17
|
+
it, the reference does not contain it, and inventing it is how eleven hair locks ended up sharing a
|
|
18
|
+
tip radius of 0.0327.
|
|
19
|
+
|
|
20
|
+
Pure Python 3.10+ standard library.
|
|
21
|
+
"""
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
import argparse
|
|
25
|
+
import json
|
|
26
|
+
import sys
|
|
27
|
+
from pathlib import Path
|
|
28
|
+
from typing import Any, Sequence
|
|
29
|
+
|
|
30
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
31
|
+
|
|
32
|
+
from extract_pbr_evidence import build_foreground_mask, load_image # noqa: E402
|
|
33
|
+
|
|
34
|
+
# Hair is dark against skin at every skin tone the reference set contains, but "dark" has to be
|
|
35
|
+
# relative or a blonde subject reports no hair at all.
|
|
36
|
+
#
|
|
37
|
+
# The threshold is the between-class variance maximum (Otsu) over the head's own luminance
|
|
38
|
+
# histogram. A fixed PERCENTILE was tried first and is a trap: taking the 38th percentile as the
|
|
39
|
+
# cut makes "38% of head pixels are hair" true by construction. It measured 0.380, 0.384 and 0.382
|
|
40
|
+
# on three different views of the same subject, which looks like agreement and is arithmetic.
|
|
41
|
+
# Otsu finds where the distribution actually splits, so a bald head reports little hair and a
|
|
42
|
+
# hooded one reports a lot.
|
|
43
|
+
OTSU_BINS = 64
|
|
44
|
+
# If the two classes Otsu finds are barely separated there is no hair/skin split to speak of -- a
|
|
45
|
+
# bald head, or a subject cropped so tightly that only hair is in frame. Reported rather than
|
|
46
|
+
# silently returning a threshold through the middle of one population.
|
|
47
|
+
MIN_CLASS_SEPARATION = 12.0
|
|
48
|
+
# ... and the two classes must be far apart RELATIVE TO THEIR OWN SPREAD. Separation alone does not
|
|
49
|
+
# catch a single broad population: an ordinarily lit BALD head has a wide luminance spread from
|
|
50
|
+
# shading and measures a separation of 38.6, three times the floor above, while reporting a quarter
|
|
51
|
+
# of its scalp as hair.
|
|
52
|
+
#
|
|
53
|
+
# This bound is one of the few in the hair subsystem with real endpoints under it, because the
|
|
54
|
+
# archived BALD calibration capture is genuine ground truth for "no hair":
|
|
55
|
+
#
|
|
56
|
+
# unimodal, theoretical 1.732 any uniform spread cut at its own middle, sqrt(3)
|
|
57
|
+
# bald, synthetic key light 1.735 and identical at every gradient width, as predicted
|
|
58
|
+
# BALD capture, real render 1.119 <-- the measured floor
|
|
59
|
+
# reference front view 2.450 <-- the measured ceiling, and the tightest real case
|
|
60
|
+
# reference profile 3.603
|
|
61
|
+
# reference rear 4.177
|
|
62
|
+
#
|
|
63
|
+
# 2.0 sits between the two measured neighbours, 15% above the theoretical unimodal value and 22%
|
|
64
|
+
# below the tightest genuine hair view. A first attempt at 3.0 was invented rather than measured and
|
|
65
|
+
# rejected the reference's own front view.
|
|
66
|
+
MIN_SEPARABILITY = 2.0
|
|
67
|
+
# Reported in place of infinity when both classes are exactly constant. Finite because this value is
|
|
68
|
+
# serialised, and `json.dumps(float("inf"))` writes a bare `Infinity` that RFC 8259 forbids.
|
|
69
|
+
SEPARABILITY_MAX = 1.0e6
|
|
70
|
+
# Bands across the head, top to bottom. Three is what the by-hand measurement used, and it was
|
|
71
|
+
# enough to localise the deficit to the middle one.
|
|
72
|
+
BAND_NAMES = ("crown", "mid", "jaw")
|
|
73
|
+
# Fraction of the figure's height taken to be head. Anchored on the reference's own proportion --
|
|
74
|
+
# a 1.75m figure whose head spans y 1.52 to 1.75 -- which is 0.13, rounded up for framing slack.
|
|
75
|
+
HEAD_FRACTION = 0.15
|
|
76
|
+
# Views that see the back of the head. Anything not in here leaves the rear unobserved, and the
|
|
77
|
+
# report has to say so rather than let a generator invent a nape.
|
|
78
|
+
#
|
|
79
|
+
# A profile sees the nape and the rear mass in outline, which is weaker evidence than a true rear
|
|
80
|
+
# view but is evidence. `right-profile` was missing purely because the capture set this was written
|
|
81
|
+
# against names its two side views `profile` and `left-profile`; a set that spells both sides out
|
|
82
|
+
# would have had one of them silently ignored.
|
|
83
|
+
REAR_VIEWS = {
|
|
84
|
+
"rear", "back", "orbit-plus-145", "orbit-minus-145",
|
|
85
|
+
"profile", "left-profile", "right-profile",
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _luma(pixel: tuple[int, int, int, int]) -> float:
|
|
90
|
+
return 0.2126 * pixel[0] + 0.7152 * pixel[1] + 0.0722 * pixel[2]
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def otsu_threshold(values: Sequence[float], bins: int = OTSU_BINS) -> tuple[float, float, float]:
|
|
94
|
+
"""Split a luminance population in two where the between-class variance is greatest.
|
|
95
|
+
|
|
96
|
+
Returns `(threshold, separation, separability)`.
|
|
97
|
+
|
|
98
|
+
`separation` is the gap between the two class means. `separability` is that gap divided by the
|
|
99
|
+
two classes' combined standard deviation -- large when the classes are genuinely distinct, and
|
|
100
|
+
around 1.7 for ANY single broad population cut down the middle.
|
|
101
|
+
|
|
102
|
+
SEPARABILITY IS NOT OPTIONAL. Otsu always returns a split, even from one population, and
|
|
103
|
+
separation alone does not catch that: an ordinarily lit BALD head has a wide luminance spread
|
|
104
|
+
from shading and measures a separation of 38.6, three times over any sane floor, while
|
|
105
|
+
reporting a quarter of its scalp as hair.
|
|
106
|
+
"""
|
|
107
|
+
if not values:
|
|
108
|
+
return (0.0, 0.0, 0.0)
|
|
109
|
+
low = min(values)
|
|
110
|
+
high = max(values)
|
|
111
|
+
if high - low < 1e-9:
|
|
112
|
+
return (low, 0.0, 0.0)
|
|
113
|
+
|
|
114
|
+
histogram = [0] * bins
|
|
115
|
+
width = (high - low) / bins
|
|
116
|
+
for value in values:
|
|
117
|
+
index = min(bins - 1, int((value - low) / width))
|
|
118
|
+
histogram[index] += 1
|
|
119
|
+
|
|
120
|
+
total = len(values)
|
|
121
|
+
sum_all = sum((low + (i + 0.5) * width) * count for i, count in enumerate(histogram))
|
|
122
|
+
best_variance = -1.0
|
|
123
|
+
best_index = 0
|
|
124
|
+
weight_below = 0
|
|
125
|
+
sum_below = 0.0
|
|
126
|
+
for index, count in enumerate(histogram[:-1]):
|
|
127
|
+
weight_below += count
|
|
128
|
+
if weight_below == 0:
|
|
129
|
+
continue
|
|
130
|
+
weight_above = total - weight_below
|
|
131
|
+
if weight_above == 0:
|
|
132
|
+
break
|
|
133
|
+
sum_below += (low + (index + 0.5) * width) * count
|
|
134
|
+
mean_below = sum_below / weight_below
|
|
135
|
+
mean_above = (sum_all - sum_below) / weight_above
|
|
136
|
+
variance = weight_below * weight_above * (mean_below - mean_above) ** 2
|
|
137
|
+
if variance > best_variance:
|
|
138
|
+
best_variance = variance
|
|
139
|
+
best_index = index
|
|
140
|
+
|
|
141
|
+
threshold = low + (best_index + 1) * width
|
|
142
|
+
below = [v for v in values if v <= threshold]
|
|
143
|
+
above = [v for v in values if v > threshold]
|
|
144
|
+
if not below or not above:
|
|
145
|
+
return (threshold, 0.0, 0.0)
|
|
146
|
+
mean_below = sum(below) / len(below)
|
|
147
|
+
mean_above = sum(above) / len(above)
|
|
148
|
+
separation = abs(mean_above - mean_below)
|
|
149
|
+
|
|
150
|
+
# SEPARABILITY, not histogram shape. Two shape-based attempts failed here, each on a different
|
|
151
|
+
# edge case, and both are recorded because the failures are instructive:
|
|
152
|
+
#
|
|
153
|
+
# valley = min bin between the peaks Broke on QUANTISATION. An 8-bit gradient lands on far
|
|
154
|
+
# fewer distinct values than there are bins, so empty
|
|
155
|
+
# bins scatter through a perfectly unimodal spread and
|
|
156
|
+
# read as a bottomless valley. A key-lit bald head
|
|
157
|
+
# scored 0.000 -- maximally bimodal -- and passed as 50%
|
|
158
|
+
# hair.
|
|
159
|
+
# valley = the bin at the cut Broke when the cut lands beside a spike, which is what
|
|
160
|
+
# a two-tone synthetic image always does. Every haired
|
|
161
|
+
# fixture scored 1.0 and was thrown out.
|
|
162
|
+
#
|
|
163
|
+
# This measure asks the question directly: are the two classes far apart RELATIVE TO THEIR OWN
|
|
164
|
+
# spread? Two tight clusters give a large ratio. One broad population cut down the middle gives
|
|
165
|
+
# about 1.7 whatever its width, because widening it grows the gap and the spreads together.
|
|
166
|
+
# No bins, no smoothing, no peak finding, nothing to tune.
|
|
167
|
+
spread_below = (sum((v - mean_below) ** 2 for v in below) / len(below)) ** 0.5
|
|
168
|
+
spread_above = (sum((v - mean_above) ** 2 for v in above) / len(above)) ** 0.5
|
|
169
|
+
total_spread = spread_below + spread_above
|
|
170
|
+
if total_spread < 1e-9:
|
|
171
|
+
# Two exactly-constant classes -- as separated as it is possible to be, and the arithmetic
|
|
172
|
+
# answer is infinity. A FINITE sentinel goes out instead, because this value is serialised:
|
|
173
|
+
# `json.dumps(float("inf"))` emits a bare `Infinity`, which RFC 8259 does not allow. Python's
|
|
174
|
+
# own loader accepts it, so every test here parsed it happily while `jq`, `JSON.parse` and
|
|
175
|
+
# any strict validator would reject the file the CLI had just written. And this is not a
|
|
176
|
+
# rare branch: a two-tone synthetic image hits it every time.
|
|
177
|
+
return (threshold, separation, SEPARABILITY_MAX)
|
|
178
|
+
return (threshold, separation, min(separation / total_spread, SEPARABILITY_MAX))
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def _bbox(mask: Sequence[bool], width: int) -> tuple[int, int, int, int] | None:
|
|
182
|
+
rows = [i // width for i, on in enumerate(mask) if on]
|
|
183
|
+
if not rows:
|
|
184
|
+
return None
|
|
185
|
+
columns = [i % width for i, on in enumerate(mask) if on]
|
|
186
|
+
return (min(columns), min(rows), max(columns), max(rows))
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def analyse_view(path: Path, view: str) -> dict[str, Any]:
|
|
190
|
+
"""Everything one image can honestly say about the hair in it."""
|
|
191
|
+
width, height, pixels, warnings = load_image(path)
|
|
192
|
+
mask, _mask_info, mask_warnings = build_foreground_mask(width, height, pixels)
|
|
193
|
+
warnings = list(warnings) + list(mask_warnings)
|
|
194
|
+
|
|
195
|
+
box = _bbox(mask, width)
|
|
196
|
+
if box is None:
|
|
197
|
+
return {"view": view, "status": "no-foreground", "warnings": warnings + ["empty mask"]}
|
|
198
|
+
x0, y0, x1, y1 = box
|
|
199
|
+
figure_height = y1 - y0 + 1
|
|
200
|
+
head_bottom = y0 + max(1, int(figure_height * HEAD_FRACTION))
|
|
201
|
+
|
|
202
|
+
head_pixels: list[tuple[int, int, float]] = []
|
|
203
|
+
for y in range(y0, head_bottom + 1):
|
|
204
|
+
for x in range(x0, x1 + 1):
|
|
205
|
+
index = y * width + x
|
|
206
|
+
if mask[index]:
|
|
207
|
+
head_pixels.append((x, y, _luma(pixels[index])))
|
|
208
|
+
if not head_pixels:
|
|
209
|
+
return {"view": view, "status": "no-head-region", "warnings": warnings}
|
|
210
|
+
|
|
211
|
+
threshold, separation, separability = otsu_threshold([luma for _, _, luma in head_pixels])
|
|
212
|
+
if separation < MIN_CLASS_SEPARATION or separability < MIN_SEPARABILITY:
|
|
213
|
+
reason = (
|
|
214
|
+
f"class separation {separation:.1f} < {MIN_CLASS_SEPARATION}"
|
|
215
|
+
if separation < MIN_CLASS_SEPARATION
|
|
216
|
+
else f"separability {separability:.2f} < {MIN_SEPARABILITY}, so the spread is one broad "
|
|
217
|
+
f"population cut down the middle -- shading on bare skin looks exactly like this"
|
|
218
|
+
)
|
|
219
|
+
return {
|
|
220
|
+
"view": view,
|
|
221
|
+
"status": "no-hair-skin-split",
|
|
222
|
+
"darkThreshold": round(threshold, 2),
|
|
223
|
+
"classSeparation": round(separation, 2),
|
|
224
|
+
"separability": round(separability, 3),
|
|
225
|
+
"warnings": warnings + [
|
|
226
|
+
f"the head region has one luminance population, not two ({reason}); this view "
|
|
227
|
+
f"cannot tell hair from skin"
|
|
228
|
+
],
|
|
229
|
+
}
|
|
230
|
+
hair = [(x, y, luma) for x, y, luma in head_pixels if luma <= threshold]
|
|
231
|
+
|
|
232
|
+
# ---- banded coverage: the by-hand measurement, made repeatable ----
|
|
233
|
+
head_height = head_bottom - y0 + 1
|
|
234
|
+
bands: dict[str, dict[str, float]] = {}
|
|
235
|
+
for band_index, band_name in enumerate(BAND_NAMES):
|
|
236
|
+
top = y0 + int(head_height * band_index / len(BAND_NAMES))
|
|
237
|
+
bottom = y0 + int(head_height * (band_index + 1) / len(BAND_NAMES))
|
|
238
|
+
in_band = [(x, y, luma) for x, y, luma in head_pixels if top <= y < max(bottom, top + 1)]
|
|
239
|
+
dark = [p for p in in_band if p[2] <= threshold]
|
|
240
|
+
bands[band_name] = {
|
|
241
|
+
"coverage": round(len(dark) / len(in_band), 4) if in_band else 0.0,
|
|
242
|
+
"meanLuma": round(sum(p[2] for p in dark) / len(dark), 2) if dark else 0.0,
|
|
243
|
+
"pixelCount": len(in_band),
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
# ---- hairline: where the hair stops and the face starts ----
|
|
247
|
+
# Per column, walk down from the top of the head and record the first non-hair row. Reported as
|
|
248
|
+
# a fraction of figure height, which is the unit `faceLandmarks` already uses.
|
|
249
|
+
hair_rows_by_column: dict[int, list[int]] = {}
|
|
250
|
+
for x, y, _ in hair:
|
|
251
|
+
hair_rows_by_column.setdefault(x, []).append(y)
|
|
252
|
+
crossings: list[float] = []
|
|
253
|
+
for x, rows in hair_rows_by_column.items():
|
|
254
|
+
rows.sort()
|
|
255
|
+
run_end = rows[0]
|
|
256
|
+
for row in rows[1:]:
|
|
257
|
+
if row - run_end > 2:
|
|
258
|
+
break
|
|
259
|
+
run_end = row
|
|
260
|
+
crossings.append((run_end - y0) / figure_height)
|
|
261
|
+
crossings.sort()
|
|
262
|
+
hairline = round(crossings[len(crossings) // 2], 4) if crossings else None
|
|
263
|
+
|
|
264
|
+
# ---- shading: where the highlight band sits, and how much darker the roots are ----
|
|
265
|
+
#
|
|
266
|
+
# Measured over rows the hair OWNS, not over the sub-threshold pixels alone. A specular band on
|
|
267
|
+
# dark hair is bright by definition, so it lands above the hair/skin threshold and a naive pass
|
|
268
|
+
# discards exactly the thing it is looking for -- measured on a fixture whose planted highlight
|
|
269
|
+
# had luminance 132.8: the reported band luminance came back as 31.8, the base hair colour, and
|
|
270
|
+
# the highlight was invisible to it. A row that is majority hair is a hair row, and every head
|
|
271
|
+
# pixel in it counts.
|
|
272
|
+
hair_by_row: dict[int, int] = {}
|
|
273
|
+
total_by_row: dict[int, list[float]] = {}
|
|
274
|
+
for _, y, _ in hair:
|
|
275
|
+
hair_by_row[y] = hair_by_row.get(y, 0) + 1
|
|
276
|
+
for _, y, luma in head_pixels:
|
|
277
|
+
total_by_row.setdefault(y, []).append(luma)
|
|
278
|
+
owned = {
|
|
279
|
+
y for y, values in total_by_row.items()
|
|
280
|
+
if len(values) >= 3 and hair_by_row.get(y, 0) >= len(values) * 0.5
|
|
281
|
+
}
|
|
282
|
+
# A row can be blown out end to end -- glossy hair under a key light does exactly this -- and
|
|
283
|
+
# then it holds no sub-threshold pixels at all and the majority test drops it. Since it is the
|
|
284
|
+
# brightest row, dropping it removes the highlight the moment the highlight is strong enough to
|
|
285
|
+
# matter. Any row ENCLOSED by owned rows is owned: hair does not stop for one row and resume.
|
|
286
|
+
if owned:
|
|
287
|
+
for y in range(min(owned), max(owned) + 1):
|
|
288
|
+
if y in total_by_row and len(total_by_row[y]) >= 3:
|
|
289
|
+
owned.add(y)
|
|
290
|
+
row_means = {y: sum(total_by_row[y]) / len(total_by_row[y]) for y in owned}
|
|
291
|
+
specular_row = max(row_means, key=lambda y: row_means[y]) if row_means else None
|
|
292
|
+
ordered_rows = sorted(row_means)
|
|
293
|
+
if len(ordered_rows) >= 6:
|
|
294
|
+
third = max(1, len(ordered_rows) // 3)
|
|
295
|
+
top_mean = sum(row_means[y] for y in ordered_rows[:third]) / third
|
|
296
|
+
bottom_mean = sum(row_means[y] for y in ordered_rows[-third:]) / third
|
|
297
|
+
root_tip_delta = round(bottom_mean - top_mean, 2)
|
|
298
|
+
else:
|
|
299
|
+
root_tip_delta = None
|
|
300
|
+
|
|
301
|
+
return {
|
|
302
|
+
"view": view,
|
|
303
|
+
"status": "measured",
|
|
304
|
+
"figureBox": {"x0": x0, "y0": y0, "x1": x1, "y1": y1},
|
|
305
|
+
"darkThreshold": round(threshold, 2),
|
|
306
|
+
"classSeparation": round(separation, 2),
|
|
307
|
+
"separability": round(separability, 3),
|
|
308
|
+
"hairFraction": round(len(hair) / len(head_pixels), 4),
|
|
309
|
+
"bands": bands,
|
|
310
|
+
"hairline": hairline,
|
|
311
|
+
"shading": {
|
|
312
|
+
"specularBandV": (
|
|
313
|
+
round((specular_row - y0) / max(1, head_height), 4) if specular_row is not None else None
|
|
314
|
+
),
|
|
315
|
+
"specularBandLuma": round(row_means[specular_row], 2) if specular_row is not None else None,
|
|
316
|
+
"rootToTipLumaDelta": root_tip_delta,
|
|
317
|
+
"note": (
|
|
318
|
+
"rootToTipLumaDelta is lower-row mean minus upper-row mean, so a positive value "
|
|
319
|
+
"means the hair gets LIGHTER downward. Which end is the root depends on the "
|
|
320
|
+
"hairstyle and is not inferred here."
|
|
321
|
+
),
|
|
322
|
+
},
|
|
323
|
+
"warnings": warnings,
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
def extract_hair_evidence(views: dict[str, Path]) -> dict[str, Any]:
|
|
328
|
+
"""Combine per-view measurements and state plainly what was never seen."""
|
|
329
|
+
per_view = {name: analyse_view(path, name) for name, path in sorted(views.items())}
|
|
330
|
+
measured = {name: data for name, data in per_view.items() if data.get("status") == "measured"}
|
|
331
|
+
|
|
332
|
+
hairlines = [d["hairline"] for d in measured.values() if d.get("hairline") is not None]
|
|
333
|
+
consensus = round(sorted(hairlines)[len(hairlines) // 2], 4) if hairlines else None
|
|
334
|
+
|
|
335
|
+
not_observed: list[str] = []
|
|
336
|
+
if not any(name in REAR_VIEWS for name in measured):
|
|
337
|
+
not_observed.append(
|
|
338
|
+
"rear: no view in this set sees the back of the head, so the nape and rear mass are "
|
|
339
|
+
"unobserved. Do not author them as if measured."
|
|
340
|
+
)
|
|
341
|
+
if len(measured) < 2:
|
|
342
|
+
not_observed.append(
|
|
343
|
+
"depth: a single view cannot separate hair thickness from hair silhouette."
|
|
344
|
+
)
|
|
345
|
+
if not hairlines:
|
|
346
|
+
not_observed.append("hairline: no view produced a usable hair/skin boundary.")
|
|
347
|
+
|
|
348
|
+
return {
|
|
349
|
+
"schemaVersion": 1,
|
|
350
|
+
"kind": "hair-evidence",
|
|
351
|
+
"views": per_view,
|
|
352
|
+
"faceLandmarks": {"hairline": consensus} if consensus is not None else {},
|
|
353
|
+
"notObserved": not_observed,
|
|
354
|
+
"confidence": round(min(1.0, len(measured) / 4.0), 3),
|
|
355
|
+
"calibrationNote": (
|
|
356
|
+
"Envelope and shading numbers are measurable from an image. Lock geometry is not, and "
|
|
357
|
+
"is not reported: the reference this pipeline calibrates against is a merged scan whose "
|
|
358
|
+
"hair is a smooth shell with all strand detail in textures."
|
|
359
|
+
),
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
364
|
+
parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])
|
|
365
|
+
parser.add_argument("images", nargs="+", help="view=path pairs, e.g. front=ref.front.png")
|
|
366
|
+
parser.add_argument("--out")
|
|
367
|
+
args = parser.parse_args(argv)
|
|
368
|
+
|
|
369
|
+
views: dict[str, Path] = {}
|
|
370
|
+
for entry in args.images:
|
|
371
|
+
if "=" not in entry:
|
|
372
|
+
parser.error(f"expected view=path, got {entry!r}")
|
|
373
|
+
name, _, raw = entry.partition("=")
|
|
374
|
+
views[name] = Path(raw)
|
|
375
|
+
|
|
376
|
+
report = extract_hair_evidence(views)
|
|
377
|
+
text = json.dumps(report, indent=2)
|
|
378
|
+
if args.out:
|
|
379
|
+
Path(args.out).write_text(text + "\n")
|
|
380
|
+
print(text)
|
|
381
|
+
return 0
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
if __name__ == "__main__":
|
|
385
|
+
raise SystemExit(main())
|