stack3js 0.6.4 → 0.6.5
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/COMMAND.md +2 -0
- package/README.md +4 -0
- package/bin/stack3.mjs +129 -70
- package/package.json +1 -1
- package/verification/acceptance.py +85 -0
- package/verification/panels.py +13 -3
- package/verification/verify.py +8 -1
package/COMMAND.md
CHANGED
|
@@ -46,6 +46,7 @@ Build options
|
|
|
46
46
|
--layers <integer|native> Vertical samples (default 128)
|
|
47
47
|
--spacing <number> Sprite stack spacing multiplier (default 1)
|
|
48
48
|
--profile <name> silhouette, round, or round-base
|
|
49
|
+
--verification <file> Require a matching atlas PASS report before building
|
|
49
50
|
--no-cache Bypass the local build cache
|
|
50
51
|
--resolution <integer|native> Longer horizontal axis samples (default 96)
|
|
51
52
|
--height <number> Asset height in scene units (default 1)
|
|
@@ -59,6 +60,7 @@ Build options
|
|
|
59
60
|
stack3 verify -f <manifest.yaml> [--output-dir <dir>]
|
|
60
61
|
Print one JSON measurement report to stdout.
|
|
61
62
|
Atlas: projections and landmarks. Assembly: whole and part atlases plus mount measurements.
|
|
63
|
+
A full atlas run reports an acceptance verdict. Use --output-dir to prepare a report for build --verification.
|
|
62
64
|
--output-dir <dir> Also save report.json and annotated PNG overlays
|
|
63
65
|
-f, --file Image and child manifest paths are relative to their YAML file.
|
|
64
66
|
```
|
package/README.md
CHANGED
|
@@ -302,4 +302,8 @@ For landmarks supply entries with an id and a points map of view names to local
|
|
|
302
302
|
|
|
303
303
|
**Assembly YAML.** Set whole to an atlas manifest and map parts by name. Each part supplies its atlas and mounts. Provide two or more distinct TOP pairs and at least one FRONT pair, each with part and whole pixel coordinates. TOP fits one positive uniform scale and planar translation, FRONT fits height. Frames must already share their physical orientation. Anchor residuals are recorded separately from checks. Each check names an id and view and supplies either a held-out part/whole point pair or a visible edge polyline in whole-panel pixels. The latter measures the maximum distance along that marked segment to the projected part outline. Set visible to false for hidden features. The reported transform remains fixed for every check.
|
|
304
304
|
|
|
305
|
+
**Acceptance gate.** A full atlas run adds `acceptance.verdict` to the report. All four checks must pass: registered silhouette dimensions within `tolerancePx`, zero unsupported contour samples at that tolerance, shared and held-out landmark residuals within tolerance with at least one held-out prediction, and at least one camera-axis pair per view within tolerance. Failure takes precedence over missing evidence. Use `axisPairs` to map each view name to a list such as `[{points: [[42, 50], [42, 50]], evidence: "Known vertically aligned upper and lower corners"}]`. Annotate only independently supported point pairs that differ solely along the viewing axis. The geometry of that pair is supplied evidence. Missing evidence gives `UNCONFIRMED`; the PNG alone cannot certify the camera angle. With `--output-dir`, inspect `atlas-guides.png` and the projection and landmark overlays. Exit status still reports execution success.
|
|
306
|
+
|
|
307
|
+
Use `stack3 build INPUT --verification qa/report.json ...` for a guarded build. The CLI requires a complete atlas `PASS` and compares the set of views, original PNG hashes, and prepared pixel data against the report before reading the cache or writing output. Keep `atlas-guides.png` beside `report.json`. Use the same directions and masking for verification and build. If the CLI's atlas split or background mask differs from the verification crop, use identical separate panel PNGs in both manifests.
|
|
308
|
+
|
|
305
309
|
See the [runnable locomotive example and measured outputs](../../samples/inspection/locomotive-verify/README.md).
|
package/bin/stack3.mjs
CHANGED
|
@@ -3779,37 +3779,87 @@ var init_src = __esm({
|
|
|
3779
3779
|
}
|
|
3780
3780
|
});
|
|
3781
3781
|
|
|
3782
|
-
// apps/cli/src/
|
|
3782
|
+
// apps/cli/src/verification-gate.ts
|
|
3783
|
+
import { createHash } from "node:crypto";
|
|
3783
3784
|
import { readFile } from "node:fs/promises";
|
|
3784
|
-
import { dirname,
|
|
3785
|
+
import { dirname, join } from "node:path";
|
|
3786
|
+
function sha256(bytes) {
|
|
3787
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
3788
|
+
}
|
|
3789
|
+
function viewFingerprint(view) {
|
|
3790
|
+
const data = new Uint8Array(view.data);
|
|
3791
|
+
for (let i2 = 0; i2 < data.length; i2 += 4) {
|
|
3792
|
+
if (data[i2 + 3] < 128) data.fill(0, i2, i2 + 4);
|
|
3793
|
+
}
|
|
3794
|
+
return createHash("sha256").update(view.width + "x" + view.height + ":").update(data).digest("hex");
|
|
3795
|
+
}
|
|
3796
|
+
async function requireVerifiedViews(reportPath, views, sourceHashes) {
|
|
3797
|
+
const report = JSON.parse(await readFile(reportPath, "utf8"));
|
|
3798
|
+
const acceptance = report?.acceptance;
|
|
3799
|
+
if (report?.kind !== "atlas" || acceptance?.version !== 1 || acceptance.verdict !== "PASS" || !requiredChecks.every((name) => acceptance.checks?.[name]?.verdict === "PASS")) {
|
|
3800
|
+
throw new Error("Build requires a PASS report from a full stack3 verify run.");
|
|
3801
|
+
}
|
|
3802
|
+
const viewEntries = Object.entries(views);
|
|
3803
|
+
if (Object.keys(acceptance.inputs ?? {}).length !== viewEntries.length) {
|
|
3804
|
+
throw new Error("Verification does not match the current set of atlas views. Verify the build inputs again.");
|
|
3805
|
+
}
|
|
3806
|
+
const guide = acceptance.checks.cameras;
|
|
3807
|
+
const overlay = guide.overlay === "atlas-guides.png" ? await readFile(join(dirname(reportPath), guide.overlay)).catch((error) => {
|
|
3808
|
+
if (error.code !== "ENOENT") throw error;
|
|
3809
|
+
}) : void 0;
|
|
3810
|
+
if (!overlay || guide.overlaySha256 !== sha256(overlay)) {
|
|
3811
|
+
throw new Error("Verification guide is missing or stale. Regenerate the report with --output-dir.");
|
|
3812
|
+
}
|
|
3813
|
+
for (const [name, view] of viewEntries) {
|
|
3814
|
+
const input = acceptance.inputs?.[name];
|
|
3815
|
+
if (input?.sourceSha256 !== sourceHashes.get(name) || input?.viewSha256 !== viewFingerprint(view)) {
|
|
3816
|
+
throw new Error("Verification does not match the current " + name.toUpperCase() + " input and mask. Verify the build inputs again.");
|
|
3817
|
+
}
|
|
3818
|
+
}
|
|
3819
|
+
}
|
|
3820
|
+
var requiredChecks;
|
|
3821
|
+
var init_verification_gate = __esm({
|
|
3822
|
+
"apps/cli/src/verification-gate.ts"() {
|
|
3823
|
+
"use strict";
|
|
3824
|
+
requiredChecks = ["dimensions", "cameras", "projections", "landmarks"];
|
|
3825
|
+
}
|
|
3826
|
+
});
|
|
3827
|
+
|
|
3828
|
+
// apps/cli/src/atlas-input.ts
|
|
3829
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
3830
|
+
import { dirname as dirname2, extname, resolve } from "node:path";
|
|
3785
3831
|
import { PNG } from "pngjs";
|
|
3786
|
-
async function png(path) {
|
|
3787
|
-
const bytes = await
|
|
3832
|
+
async function png(path, onRead) {
|
|
3833
|
+
const bytes = await readFile2(path);
|
|
3834
|
+
if (onRead) onRead(sha256(bytes));
|
|
3788
3835
|
readPngSize(bytes);
|
|
3789
3836
|
const image = PNG.sync.read(bytes);
|
|
3790
3837
|
return { width: image.width, height: image.height, data: image.data };
|
|
3791
3838
|
}
|
|
3792
|
-
async function readInput(path, layout, threshold) {
|
|
3839
|
+
async function readInput(path, layout, threshold, hashes) {
|
|
3793
3840
|
if (extname(path).toLowerCase() === ".png") {
|
|
3794
3841
|
if (!layout) throw new Error("A PNG atlas needs an explicit --layout.");
|
|
3795
|
-
|
|
3842
|
+
const directions = parseLayout(layout);
|
|
3843
|
+
const image = await png(path, hashes && ((hash) => directions.forEach((name) => hashes.set(name, hash))));
|
|
3844
|
+
return splitAtlas(image, directions, threshold);
|
|
3796
3845
|
}
|
|
3797
3846
|
if (extname(path).toLowerCase() !== ".json") throw new Error("Choose a PNG atlas or a JSON view manifest.");
|
|
3798
3847
|
if (layout) throw new Error("View manifests define their directions in the views field.");
|
|
3799
|
-
const manifest = JSON.parse(await
|
|
3848
|
+
const manifest = JSON.parse(await readFile2(path, "utf8"));
|
|
3800
3849
|
const views = manifest && typeof manifest === "object" && "views" in manifest ? manifest.views : null;
|
|
3801
3850
|
if (!views || typeof views !== "object" || Array.isArray(views)) throw new Error("The manifest needs a views object.");
|
|
3802
3851
|
const entries = Object.entries(views);
|
|
3803
3852
|
parseLayout(entries.map(([name]) => name).join(","));
|
|
3804
3853
|
return Object.fromEntries(await Promise.all(entries.map(async ([name, file]) => {
|
|
3805
3854
|
if (!DIRECTIONS.includes(name) || typeof file !== "string" || !file) throw new Error(`Invalid view entry: ${name}`);
|
|
3806
|
-
return [name, await png(resolve(
|
|
3855
|
+
return [name, await png(resolve(dirname2(path), file), hashes && ((hash) => hashes.set(name, hash)))];
|
|
3807
3856
|
})));
|
|
3808
3857
|
}
|
|
3809
3858
|
var init_atlas_input = __esm({
|
|
3810
3859
|
"apps/cli/src/atlas-input.ts"() {
|
|
3811
3860
|
"use strict";
|
|
3812
3861
|
init_src();
|
|
3862
|
+
init_verification_gate();
|
|
3813
3863
|
}
|
|
3814
3864
|
});
|
|
3815
3865
|
|
|
@@ -3851,7 +3901,7 @@ import { execFile, spawn } from "node:child_process";
|
|
|
3851
3901
|
import { existsSync } from "node:fs";
|
|
3852
3902
|
import { link, mkdir, mkdtemp, rm } from "node:fs/promises";
|
|
3853
3903
|
import { tmpdir } from "node:os";
|
|
3854
|
-
import { basename, dirname as
|
|
3904
|
+
import { basename, dirname as dirname3, extname as extname2, join as join2, resolve as resolve2 } from "node:path";
|
|
3855
3905
|
import { fileURLToPath } from "node:url";
|
|
3856
3906
|
import { promisify } from "node:util";
|
|
3857
3907
|
function blenderExecutable() {
|
|
@@ -3864,9 +3914,9 @@ async function openBlenderStack(directory2, output, open2) {
|
|
|
3864
3914
|
const destination = output && resolve2(output);
|
|
3865
3915
|
if (destination && extname2(destination).toLowerCase() !== ".blend") throw new Error("Use a .blend output file.");
|
|
3866
3916
|
if (destination && existsSync(destination)) throw new Error("Output already exists: " + destination);
|
|
3867
|
-
if (destination) await mkdir(
|
|
3868
|
-
const scratch = await mkdtemp(
|
|
3869
|
-
const generated =
|
|
3917
|
+
if (destination) await mkdir(dirname3(destination), { recursive: true });
|
|
3918
|
+
const scratch = await mkdtemp(join2(destination ? dirname3(destination) : tmpdir(), "stack3-blender-"));
|
|
3919
|
+
const generated = join2(scratch, (basename(directory2) || "stack") + ".blend");
|
|
3870
3920
|
const scene = destination || generated;
|
|
3871
3921
|
let keepPreview = false;
|
|
3872
3922
|
try {
|
|
@@ -3899,9 +3949,9 @@ var init_blender = __esm({
|
|
|
3899
3949
|
|
|
3900
3950
|
// apps/cli/src/part-mesh.ts
|
|
3901
3951
|
import { execFile as execFile2 } from "node:child_process";
|
|
3902
|
-
import { mkdtemp as mkdtemp2, readFile as
|
|
3952
|
+
import { mkdtemp as mkdtemp2, readFile as readFile3, rm as rm2, writeFile } from "node:fs/promises";
|
|
3903
3953
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
3904
|
-
import { dirname as
|
|
3954
|
+
import { dirname as dirname4, join as join3, resolve as resolve3 } from "node:path";
|
|
3905
3955
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
3906
3956
|
import { promisify as promisify2 } from "node:util";
|
|
3907
3957
|
function isCoreMeshMethod(method) {
|
|
@@ -3916,14 +3966,14 @@ async function readStackMesh(stack, method, guide, finish) {
|
|
|
3916
3966
|
return isCoreMeshMethod(method) ? meshFromStack(stack, method) : partMesh(stack, method, guide, finish);
|
|
3917
3967
|
}
|
|
3918
3968
|
async function partMesh(stack, method, guidePath, finish) {
|
|
3919
|
-
const guide = guidePath ? JSON.parse(await
|
|
3969
|
+
const guide = guidePath ? JSON.parse(await readFile3(guidePath, "utf8")) : {};
|
|
3920
3970
|
const { width, depth, layers, columns: columns2, spacing, pivot } = stack;
|
|
3921
3971
|
const size = [stack.size[0], stack.size[1], layers * spacing];
|
|
3922
|
-
const temporary = await mkdtemp2(
|
|
3972
|
+
const temporary = await mkdtemp2(join3(tmpdir2(), "stack3-part-"));
|
|
3923
3973
|
try {
|
|
3924
3974
|
await Promise.all([
|
|
3925
|
-
writeFile(
|
|
3926
|
-
writeFile(
|
|
3975
|
+
writeFile(join3(temporary, "stack.rgba"), stack.texture.data),
|
|
3976
|
+
writeFile(join3(temporary, "input.json"), JSON.stringify({
|
|
3927
3977
|
width,
|
|
3928
3978
|
depth,
|
|
3929
3979
|
layers,
|
|
@@ -3931,7 +3981,7 @@ async function partMesh(stack, method, guidePath, finish) {
|
|
|
3931
3981
|
size,
|
|
3932
3982
|
pivot,
|
|
3933
3983
|
guide,
|
|
3934
|
-
guideDirectory: guidePath &&
|
|
3984
|
+
guideDirectory: guidePath && dirname4(resolve3(guidePath)),
|
|
3935
3985
|
finish,
|
|
3936
3986
|
blender: finish && blenderExecutable()
|
|
3937
3987
|
}))
|
|
@@ -3952,7 +4002,7 @@ async function partMesh(stack, method, guidePath, finish) {
|
|
|
3952
4002
|
throw new Error(e.code === "ENOENT" ? "Install uv or set STACK3_PYTHON to a Python environment with the meshing dependencies." : e.stderr?.trim() || e.message);
|
|
3953
4003
|
}
|
|
3954
4004
|
const read = async (name) => {
|
|
3955
|
-
const bytes = await
|
|
4005
|
+
const bytes = await readFile3(join3(temporary, name));
|
|
3956
4006
|
return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
3957
4007
|
};
|
|
3958
4008
|
const [positions, normals, uvs, indices, pixels, metadata] = await Promise.all(
|
|
@@ -4006,13 +4056,13 @@ var init_part_mesh = __esm({
|
|
|
4006
4056
|
});
|
|
4007
4057
|
|
|
4008
4058
|
// apps/cli/src/stack-input.ts
|
|
4009
|
-
import { readFile as
|
|
4010
|
-
import { join as
|
|
4059
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
4060
|
+
import { join as join4 } from "node:path";
|
|
4011
4061
|
import { PNG as PNG2 } from "pngjs";
|
|
4012
4062
|
async function loadStack(directory2) {
|
|
4013
4063
|
const [metadata, png2] = await Promise.all([
|
|
4014
|
-
|
|
4015
|
-
|
|
4064
|
+
readFile4(join4(directory2, "stack.json"), "utf8"),
|
|
4065
|
+
readFile4(join4(directory2, "stack.png"))
|
|
4016
4066
|
]);
|
|
4017
4067
|
const manifest = JSON.parse(metadata);
|
|
4018
4068
|
readStackPngSize(png2, manifest);
|
|
@@ -4027,19 +4077,19 @@ var init_stack_input = __esm({
|
|
|
4027
4077
|
});
|
|
4028
4078
|
|
|
4029
4079
|
// apps/cli/src/build-cache.ts
|
|
4030
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
4031
|
-
import { mkdir as mkdir2, readdir, readFile as
|
|
4080
|
+
import { createHash as createHash2, randomUUID } from "node:crypto";
|
|
4081
|
+
import { mkdir as mkdir2, readdir, readFile as readFile5, rename, stat, unlink, writeFile as writeFile2 } from "node:fs/promises";
|
|
4032
4082
|
import { homedir } from "node:os";
|
|
4033
|
-
import { join as
|
|
4083
|
+
import { join as join5, resolve as resolve4 } from "node:path";
|
|
4034
4084
|
import { deserialize, serialize } from "node:v8";
|
|
4035
4085
|
async function readCache(key) {
|
|
4036
4086
|
try {
|
|
4037
|
-
return deserialize(await
|
|
4087
|
+
return deserialize(await readFile5(join5(directory, key + ".cache")));
|
|
4038
4088
|
} catch {
|
|
4039
4089
|
}
|
|
4040
4090
|
}
|
|
4041
4091
|
function buildCacheKey(views, format, settings, spacing) {
|
|
4042
|
-
const hash =
|
|
4092
|
+
const hash = createHash2("sha256");
|
|
4043
4093
|
hash.update(JSON.stringify([version, format, settings, spacing]));
|
|
4044
4094
|
for (const direction of DIRECTIONS) {
|
|
4045
4095
|
const view = views[direction];
|
|
@@ -4059,15 +4109,15 @@ async function readSurfaceCache(key) {
|
|
|
4059
4109
|
if (data?.format === "surface" && data.mesh?.positions instanceof Float32Array && data.mesh.indices instanceof Uint32Array) return data.mesh;
|
|
4060
4110
|
}
|
|
4061
4111
|
async function writeBuildCache(key, output) {
|
|
4062
|
-
const temporary =
|
|
4112
|
+
const temporary = join5(directory, randomUUID() + ".tmp");
|
|
4063
4113
|
try {
|
|
4064
4114
|
await mkdir2(directory, { recursive: true });
|
|
4065
4115
|
await writeFile2(temporary, serialize(output), { flag: "wx" });
|
|
4066
|
-
await rename(temporary,
|
|
4116
|
+
await rename(temporary, join5(directory, key + ".cache"));
|
|
4067
4117
|
const entries = (await readdir(directory)).filter((name) => /^[0-9a-f]{64}\.cache$/.test(name));
|
|
4068
4118
|
if (entries.length <= 12) return;
|
|
4069
|
-
const dated = await Promise.all(entries.map(async (name) => ({ name, time: (await stat(
|
|
4070
|
-
await Promise.all(dated.sort((a, b) => b.time - a.time).slice(12).map(({ name }) => unlink(
|
|
4119
|
+
const dated = await Promise.all(entries.map(async (name) => ({ name, time: (await stat(join5(directory, name))).mtimeMs })));
|
|
4120
|
+
await Promise.all(dated.sort((a, b) => b.time - a.time).slice(12).map(({ name }) => unlink(join5(directory, name))));
|
|
4071
4121
|
} catch {
|
|
4072
4122
|
await unlink(temporary).catch(() => {
|
|
4073
4123
|
});
|
|
@@ -4079,7 +4129,7 @@ var init_build_cache = __esm({
|
|
|
4079
4129
|
"use strict";
|
|
4080
4130
|
init_src();
|
|
4081
4131
|
version = "render-data-4";
|
|
4082
|
-
directory = process.env.STACK3_CACHE_DIR ? resolve4(process.env.STACK3_CACHE_DIR) :
|
|
4132
|
+
directory = process.env.STACK3_CACHE_DIR ? resolve4(process.env.STACK3_CACHE_DIR) : join5(process.env.XDG_CACHE_HOME || join5(homedir(), ".cache"), "stack3", version);
|
|
4083
4133
|
}
|
|
4084
4134
|
});
|
|
4085
4135
|
|
|
@@ -4090,17 +4140,17 @@ __export(capabilities_exports, {
|
|
|
4090
4140
|
printPipelineSchema: () => printPipelineSchema
|
|
4091
4141
|
});
|
|
4092
4142
|
import { existsSync as existsSync2 } from "node:fs";
|
|
4093
|
-
import { readFile as
|
|
4143
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
4094
4144
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
4095
4145
|
import { parseArgs } from "node:util";
|
|
4096
4146
|
async function printPipelineSchema(kind) {
|
|
4097
4147
|
if (kind !== "recipe" && kind !== "fragment") throw new Error("Use stack3 pipeline schema [recipe|fragment].");
|
|
4098
|
-
const recipe = await
|
|
4148
|
+
const recipe = await readFile6(schemaFiles.recipe, "utf8");
|
|
4099
4149
|
if (kind === "recipe") {
|
|
4100
4150
|
process.stdout.write(recipe);
|
|
4101
4151
|
return;
|
|
4102
4152
|
}
|
|
4103
|
-
const fragment = JSON.parse(await
|
|
4153
|
+
const fragment = JSON.parse(await readFile6(schemaFiles.fragment, "utf8"));
|
|
4104
4154
|
const definitions = JSON.parse(recipe).$defs;
|
|
4105
4155
|
process.stdout.write(JSON.stringify({ ...fragment, $ref: "#/$defs/manifest", $defs: definitions }, null, 2) + "\n");
|
|
4106
4156
|
}
|
|
@@ -4288,9 +4338,9 @@ var pipeline_exports = {};
|
|
|
4288
4338
|
__export(pipeline_exports, {
|
|
4289
4339
|
pipelineCommand: () => pipelineCommand
|
|
4290
4340
|
});
|
|
4291
|
-
import { createHash as
|
|
4292
|
-
import { mkdir as mkdir3, readFile as
|
|
4293
|
-
import { dirname as
|
|
4341
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
4342
|
+
import { mkdir as mkdir3, readFile as readFile7, realpath, writeFile as writeFile3 } from "node:fs/promises";
|
|
4343
|
+
import { dirname as dirname5, extname as extname3, resolve as resolve5 } from "node:path";
|
|
4294
4344
|
import { parseArgs as parseArgs2 } from "node:util";
|
|
4295
4345
|
import { parse, stringify } from "yaml";
|
|
4296
4346
|
function isMapping(value) {
|
|
@@ -4308,7 +4358,7 @@ function requiredText(value, name) {
|
|
|
4308
4358
|
}
|
|
4309
4359
|
async function readYaml(path) {
|
|
4310
4360
|
try {
|
|
4311
|
-
return parse(await
|
|
4361
|
+
return parse(await readFile7(path, "utf8"), { maxAliasCount: 0 });
|
|
4312
4362
|
} catch (error) {
|
|
4313
4363
|
throw new Error(`${path}: ${error.message}`);
|
|
4314
4364
|
}
|
|
@@ -4594,7 +4644,7 @@ async function renderPipeline(path, overridePaths) {
|
|
|
4594
4644
|
}
|
|
4595
4645
|
if (Array.isArray(doc.includes)) {
|
|
4596
4646
|
for (const include of doc.includes) {
|
|
4597
|
-
await load(resolve5(
|
|
4647
|
+
await load(resolve5(dirname5(file), requiredText(include, `${file}.includes item`)), false);
|
|
4598
4648
|
}
|
|
4599
4649
|
}
|
|
4600
4650
|
if (doc.values !== void 0) values = mergeValues(values, mapping(doc.values, `${file}.values`));
|
|
@@ -4604,12 +4654,12 @@ async function renderPipeline(path, overridePaths) {
|
|
|
4604
4654
|
}
|
|
4605
4655
|
await load(path, true);
|
|
4606
4656
|
for (const overridePath of overridePaths) values = mergeValues(values, mapping(await readYaml(overridePath), overridePath));
|
|
4607
|
-
const nodes = orderNodes(rawNodes.map(({ raw, name }) => parseNode(raw, values,
|
|
4657
|
+
const nodes = orderNodes(rawNodes.map(({ raw, name }) => parseNode(raw, values, dirname5(path), name)));
|
|
4608
4658
|
return { version: 1, nodes };
|
|
4609
4659
|
}
|
|
4610
4660
|
async function surfaceCacheKey(node, stack) {
|
|
4611
4661
|
const { texture, ...bounds2 } = stack;
|
|
4612
|
-
const hash =
|
|
4662
|
+
const hash = createHash3("sha256");
|
|
4613
4663
|
hash.update(JSON.stringify([
|
|
4614
4664
|
"surface-v4",
|
|
4615
4665
|
node.method,
|
|
@@ -4622,12 +4672,12 @@ async function surfaceCacheKey(node, stack) {
|
|
|
4622
4672
|
]));
|
|
4623
4673
|
hash.update(texture.data);
|
|
4624
4674
|
if (node.guide) {
|
|
4625
|
-
const guide = await
|
|
4675
|
+
const guide = await readFile7(node.guide);
|
|
4626
4676
|
hash.update(guide);
|
|
4627
4677
|
if (node.method === "signed-distance-dc" || node.method === "hermite-dc") {
|
|
4628
4678
|
const { field, dexel } = JSON.parse(guide.toString("utf8"));
|
|
4629
4679
|
for (const source of [field, dexel]) {
|
|
4630
|
-
if (typeof source === "string") hash.update(await
|
|
4680
|
+
if (typeof source === "string") hash.update(await readFile7(resolve5(dirname5(node.guide), source)));
|
|
4631
4681
|
}
|
|
4632
4682
|
}
|
|
4633
4683
|
}
|
|
@@ -4662,7 +4712,7 @@ async function runPipeline(nodes) {
|
|
|
4662
4712
|
if (node.type === "extract-mesh" && source?.target === "stack") {
|
|
4663
4713
|
assets.set(node.id, await extract(node, source));
|
|
4664
4714
|
} else if (node.type === "write-glb" && source?.target === "mesh") {
|
|
4665
|
-
await mkdir3(
|
|
4715
|
+
await mkdir3(dirname5(node.path), { recursive: true });
|
|
4666
4716
|
await writeFile3(node.path, encodeGlb(source, node));
|
|
4667
4717
|
console.log(`${node.id}: ${node.path}`);
|
|
4668
4718
|
} else {
|
|
@@ -4764,6 +4814,7 @@ var init_verify_command = __esm({
|
|
|
4764
4814
|
help3 = `stack3 verify -f <manifest.yaml> [--output-dir <dir>]
|
|
4765
4815
|
Print one JSON measurement report to stdout.
|
|
4766
4816
|
Atlas: projections and landmarks. Assembly: whole and part atlases plus mount measurements.
|
|
4817
|
+
A full atlas run reports an acceptance verdict. Use --output-dir to prepare a report for build --verification.
|
|
4767
4818
|
--output-dir <dir> Also save report.json and annotated PNG overlays
|
|
4768
4819
|
-f, --file Image and child manifest paths are relative to their YAML file.`;
|
|
4769
4820
|
}
|
|
@@ -4771,16 +4822,16 @@ var init_verify_command = __esm({
|
|
|
4771
4822
|
|
|
4772
4823
|
// apps/cli/src/project-store.ts
|
|
4773
4824
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
4774
|
-
import { mkdir as mkdir4, open, readFile as
|
|
4775
|
-
import { dirname as
|
|
4825
|
+
import { mkdir as mkdir4, open, readFile as readFile8, rename as rename2, stat as stat2, unlink as unlink2, writeFile as writeFile4 } from "node:fs/promises";
|
|
4826
|
+
import { dirname as dirname6 } from "node:path";
|
|
4776
4827
|
import { setTimeout as setTimeout2 } from "node:timers/promises";
|
|
4777
4828
|
async function readProject(file) {
|
|
4778
|
-
const data = JSON.parse(await
|
|
4829
|
+
const data = JSON.parse(await readFile8(file, "utf8"));
|
|
4779
4830
|
if (data.version !== 1 || !Number.isInteger(data.revision) || !Array.isArray(data.nodes) || !Array.isArray(data.atlases) || !data.view || !data.play) throw new Error("Expected a version 1 stack3 scene project.");
|
|
4780
4831
|
return data;
|
|
4781
4832
|
}
|
|
4782
4833
|
async function initProject(file, name) {
|
|
4783
|
-
await mkdir4(
|
|
4834
|
+
await mkdir4(dirname6(file), { recursive: true });
|
|
4784
4835
|
const project = newProject(name);
|
|
4785
4836
|
await writeFile4(file, JSON.stringify(project) + "\n", { flag: "wx", mode: 384 });
|
|
4786
4837
|
return project;
|
|
@@ -4877,7 +4928,7 @@ var project_server_exports = {};
|
|
|
4877
4928
|
__export(project_server_exports, {
|
|
4878
4929
|
openProject: () => openProject
|
|
4879
4930
|
});
|
|
4880
|
-
import { createHash as
|
|
4931
|
+
import { createHash as createHash4, randomUUID as randomUUID3 } from "node:crypto";
|
|
4881
4932
|
async function body(request) {
|
|
4882
4933
|
const chunks = [];
|
|
4883
4934
|
let size = 0;
|
|
@@ -4962,7 +5013,7 @@ var init_project_server = __esm({
|
|
|
4962
5013
|
init_src();
|
|
4963
5014
|
init_project_store();
|
|
4964
5015
|
limit = 80 * 1024 * 1024;
|
|
4965
|
-
fingerprint = (png2) =>
|
|
5016
|
+
fingerprint = (png2) => createHash4("sha256").update(png2).digest("hex");
|
|
4966
5017
|
}
|
|
4967
5018
|
});
|
|
4968
5019
|
|
|
@@ -4971,9 +5022,9 @@ var project_command_exports = {};
|
|
|
4971
5022
|
__export(project_command_exports, {
|
|
4972
5023
|
projectCommand: () => projectCommand
|
|
4973
5024
|
});
|
|
4974
|
-
import { createHash as
|
|
4975
|
-
import { readFile as
|
|
4976
|
-
import { basename as basename2, dirname as
|
|
5025
|
+
import { createHash as createHash5, randomUUID as randomUUID4 } from "node:crypto";
|
|
5026
|
+
import { readFile as readFile9, writeFile as writeFile5, mkdir as mkdir5 } from "node:fs/promises";
|
|
5027
|
+
import { basename as basename2, dirname as dirname7, extname as extname4, join as join6, resolve as resolve6 } from "node:path";
|
|
4977
5028
|
import { parseArgs as parseArgs4 } from "node:util";
|
|
4978
5029
|
import { PNG as PNG3 } from "pngjs";
|
|
4979
5030
|
async function stdin() {
|
|
@@ -5037,7 +5088,7 @@ async function projectCommand(args) {
|
|
|
5037
5088
|
if (inputs.length !== 1) throw new Error("Provide a JSON action file or - for standard input.");
|
|
5038
5089
|
const revision = values.revision === void 0 ? void 0 : Number(values.revision);
|
|
5039
5090
|
if (revision !== void 0 && (!Number.isInteger(revision) || revision < 0)) throw new Error("Invalid project revision.");
|
|
5040
|
-
print(summarizeProject(await editProject(path, JSON.parse(inputs[0] === "-" ? await stdin() : await
|
|
5091
|
+
print(summarizeProject(await editProject(path, JSON.parse(inputs[0] === "-" ? await stdin() : await readFile9(inputs[0], "utf8")), revision)));
|
|
5041
5092
|
return;
|
|
5042
5093
|
}
|
|
5043
5094
|
case "preset": {
|
|
@@ -5061,9 +5112,9 @@ async function projectCommand(args) {
|
|
|
5061
5112
|
const actions = [];
|
|
5062
5113
|
const nodes = [];
|
|
5063
5114
|
for (const image of inputs) {
|
|
5064
|
-
const bytes = await
|
|
5115
|
+
const bytes = await readFile9(image);
|
|
5065
5116
|
const name = basename2(image, extname4(image));
|
|
5066
|
-
const atlasId =
|
|
5117
|
+
const atlasId = createHash5("sha256").update(layout).update(bytes).digest("hex");
|
|
5067
5118
|
const id = randomUUID4();
|
|
5068
5119
|
nodes.push(id);
|
|
5069
5120
|
actions.push(
|
|
@@ -5091,13 +5142,13 @@ async function projectCommand(args) {
|
|
|
5091
5142
|
const views = prepareViews(splitAtlas(image, parseLayout(atlas.layout), settings.threshold), settings.threshold);
|
|
5092
5143
|
const asset = buildFromPreparedViews(views, format === "glb" ? "mesh" : "stack", settings);
|
|
5093
5144
|
if (asset.target === "mesh") {
|
|
5094
|
-
await mkdir5(
|
|
5145
|
+
await mkdir5(dirname7(output), { recursive: true });
|
|
5095
5146
|
await writeFile5(output, encodeGlb(asset));
|
|
5096
5147
|
} else {
|
|
5097
5148
|
const bundle = encodeStack(respaceStack(asset, settings.spacing));
|
|
5098
5149
|
await mkdir5(output, { recursive: true });
|
|
5099
|
-
await writeFile5(
|
|
5100
|
-
await writeFile5(
|
|
5150
|
+
await writeFile5(join6(output, "stack.png"), bundle.png);
|
|
5151
|
+
await writeFile5(join6(output, "stack.json"), JSON.stringify(bundle.manifest, null, 2) + "\n");
|
|
5101
5152
|
}
|
|
5102
5153
|
print({ node: node.id, format, output });
|
|
5103
5154
|
return;
|
|
@@ -5181,10 +5232,11 @@ init_part_mesh();
|
|
|
5181
5232
|
init_stack_input();
|
|
5182
5233
|
init_grid_build();
|
|
5183
5234
|
init_src();
|
|
5235
|
+
init_verification_gate();
|
|
5184
5236
|
init_build_cache();
|
|
5185
5237
|
import { constants, existsSync as existsSync4 } from "node:fs";
|
|
5186
|
-
import { copyFile, mkdir as mkdir6, readFile as
|
|
5187
|
-
import { dirname as
|
|
5238
|
+
import { copyFile, mkdir as mkdir6, readFile as readFile10, writeFile as writeFile6 } from "node:fs/promises";
|
|
5239
|
+
import { dirname as dirname8, extname as extname5, join as join7, resolve as resolve7 } from "node:path";
|
|
5188
5240
|
import { parseArgs as parseArgs5 } from "node:util";
|
|
5189
5241
|
var HELP = `Usage: stack3 <verb> <input> [options]
|
|
5190
5242
|
|
|
@@ -5227,6 +5279,7 @@ Build options
|
|
|
5227
5279
|
--layers <integer|native> Vertical samples (default ${DEFAULT_LAYERS})
|
|
5228
5280
|
--spacing <number> Sprite stack spacing multiplier (default 1)
|
|
5229
5281
|
--profile <name> silhouette, round, or round-base
|
|
5282
|
+
--verification <file> Require a matching atlas PASS report before building
|
|
5230
5283
|
--no-cache Bypass the local build cache
|
|
5231
5284
|
--resolution <integer|native> Longer horizontal axis samples (default 96)
|
|
5232
5285
|
--height <number> Asset height in scene units (default 1)
|
|
@@ -5303,6 +5356,7 @@ async function main() {
|
|
|
5303
5356
|
layout: { type: "string" },
|
|
5304
5357
|
format: { type: "string" },
|
|
5305
5358
|
target: { type: "string" },
|
|
5359
|
+
verification: { type: "string" },
|
|
5306
5360
|
output: { type: "string", short: "o" },
|
|
5307
5361
|
layers: { type: "string" },
|
|
5308
5362
|
resolution: { type: "string" },
|
|
@@ -5321,7 +5375,7 @@ async function main() {
|
|
|
5321
5375
|
}
|
|
5322
5376
|
});
|
|
5323
5377
|
if (values.version) {
|
|
5324
|
-
const manifest = JSON.parse(await
|
|
5378
|
+
const manifest = JSON.parse(await readFile10(new URL("../package.json", import.meta.url), "utf8"));
|
|
5325
5379
|
console.log(manifest.version);
|
|
5326
5380
|
return;
|
|
5327
5381
|
}
|
|
@@ -5330,6 +5384,7 @@ async function main() {
|
|
|
5330
5384
|
return;
|
|
5331
5385
|
}
|
|
5332
5386
|
const [verb, input] = positionals;
|
|
5387
|
+
if (values.verification !== void 0 && verb !== "build") throw new Error("--verification requires stack3 build.");
|
|
5333
5388
|
if (values.guide !== void 0 && verb !== "mesh") throw new Error("--guide requires stack3 mesh.");
|
|
5334
5389
|
if (verb === "example" && positionals.length === 2) {
|
|
5335
5390
|
await copyExample(input, values.output);
|
|
@@ -5355,7 +5410,7 @@ async function main() {
|
|
|
5355
5410
|
throw new Error(`${input} (${method}): ${error.message}`);
|
|
5356
5411
|
}
|
|
5357
5412
|
const output2 = resolve7(values.output);
|
|
5358
|
-
await mkdir6(
|
|
5413
|
+
await mkdir6(dirname8(output2), { recursive: true });
|
|
5359
5414
|
await writeFile6(output2, bytes);
|
|
5360
5415
|
console.log(`Meshed ${stack.layers} saved layers with ${method} into ${output2}`);
|
|
5361
5416
|
return;
|
|
@@ -5393,7 +5448,11 @@ async function main() {
|
|
|
5393
5448
|
if ((meshMethod || values["contour-hub"]) && format !== "glb") throw new Error("Mesh methods require GLB output.");
|
|
5394
5449
|
if (values["contour-hub"] && meshMethod !== "contour") throw new Error("--contour-hub requires --mesh-method contour.");
|
|
5395
5450
|
if (meshMethod === "contour" && profile && profile !== "silhouette") throw new Error("Contour extrusion uses the FRONT silhouette.");
|
|
5396
|
-
const
|
|
5451
|
+
const sourceHashes = values.verification === void 0 ? void 0 : /* @__PURE__ */ new Map();
|
|
5452
|
+
const views = prepareViews(await readInput(input, values.layout, threshold, sourceHashes), threshold);
|
|
5453
|
+
if (values.verification !== void 0 && sourceHashes) {
|
|
5454
|
+
await requireVerifiedViews(values.verification, views, sourceHashes);
|
|
5455
|
+
}
|
|
5397
5456
|
const { nativeSamples } = inspectViews(views);
|
|
5398
5457
|
const settings = {
|
|
5399
5458
|
textureProjection,
|
|
@@ -5415,12 +5474,12 @@ async function main() {
|
|
|
5415
5474
|
const cached = key ? await readBuildCache(key, format) : void 0;
|
|
5416
5475
|
const artifact = cached ?? buildOutput(views, format, settings, spacing);
|
|
5417
5476
|
if (artifact.format === "glb") {
|
|
5418
|
-
await mkdir6(
|
|
5477
|
+
await mkdir6(dirname8(output), { recursive: true });
|
|
5419
5478
|
await writeFile6(output, artifact.bytes);
|
|
5420
5479
|
} else {
|
|
5421
5480
|
await mkdir6(output, { recursive: true });
|
|
5422
|
-
await writeFile6(
|
|
5423
|
-
await writeFile6(
|
|
5481
|
+
await writeFile6(join7(output, "stack.png"), artifact.png);
|
|
5482
|
+
await writeFile6(join7(output, "stack.json"), artifact.manifest);
|
|
5424
5483
|
}
|
|
5425
5484
|
if (key && !cached) await writeBuildCache(key, artifact);
|
|
5426
5485
|
console.log(`Built ${format} at ${output}${cached ? " \xB7 disk cache" : ""}`);
|
package/package.json
CHANGED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""Deterministic acceptance checks and two-dimensional camera evidence."""
|
|
2
|
+
import math
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
from PIL import ImageDraw
|
|
6
|
+
|
|
7
|
+
from panels import CYAN, GREEN, RED, canvas, dot, sheet
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def dimensions(panels, tolerance):
|
|
11
|
+
ranges = {}
|
|
12
|
+
for view, panel in panels.items():
|
|
13
|
+
if panel.scale is None:
|
|
14
|
+
return dict(verdict="UNCONFIRMED", differences=[])
|
|
15
|
+
y, x = np.nonzero(panel.mask)
|
|
16
|
+
for axis, points in zip(panel.axes, (x, y)):
|
|
17
|
+
ranges.setdefault(axis, []).append((view, float(points.max()-points.min()+1), panel.scale))
|
|
18
|
+
differences = []
|
|
19
|
+
for axis, entries in ranges.items():
|
|
20
|
+
for i, (view, pixels, scale) in enumerate(entries):
|
|
21
|
+
for other, other_pixels, other_scale in entries[i+1:]:
|
|
22
|
+
error = abs(pixels/scale-other_pixels/other_scale)*max(scale, other_scale)
|
|
23
|
+
differences.append(dict(axis=axis, views=[view, other], errorPx=error))
|
|
24
|
+
return dict(verdict="FAIL" if any(d["errorPx"] > tolerance for d in differences) else "PASS",
|
|
25
|
+
differences=differences)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def camera(panels, config, tolerance):
|
|
29
|
+
if not isinstance(config, dict) or set(config) - set(panels):
|
|
30
|
+
raise ValueError("axisPairs must map known views to lists of annotated pairs")
|
|
31
|
+
images = canvas(panels)
|
|
32
|
+
checks = {}
|
|
33
|
+
for view, panel in panels.items():
|
|
34
|
+
pairs = config.get(view, [])
|
|
35
|
+
if not isinstance(pairs, list):
|
|
36
|
+
raise ValueError(f"{view}: axisPairs must be a list")
|
|
37
|
+
rows = []
|
|
38
|
+
drawing = ImageDraw.Draw(images[view])
|
|
39
|
+
y, x = np.nonzero(panel.mask)
|
|
40
|
+
bounds = tuple(map(int, (x.min(), y.min(), x.max(), y.max())))
|
|
41
|
+
drawing.rectangle(bounds, outline=CYAN)
|
|
42
|
+
w, h = bounds[2]-bounds[0]+1, bounds[3]-bounds[1]+1
|
|
43
|
+
drawing.text((bounds[0], max(0, bounds[1]-12)), f"{w} x {h} px", fill=CYAN)
|
|
44
|
+
if view != "top" and panel.origin is not None:
|
|
45
|
+
ground = panel.origin[1]
|
|
46
|
+
if 0 <= ground < panel.mask.shape[0]:
|
|
47
|
+
drawing.line([(0, ground), (panel.mask.shape[1]-1, ground)], fill=CYAN, width=1)
|
|
48
|
+
for pair in pairs:
|
|
49
|
+
evidence = pair["evidence"]
|
|
50
|
+
if not isinstance(evidence, str) or not evidence.strip():
|
|
51
|
+
raise ValueError(f"{view}: axis pair needs an evidence description")
|
|
52
|
+
a, b = (panel.annotation(xy, f"{view} axis pair") for xy in pair["points"])
|
|
53
|
+
error = math.dist(a, b)
|
|
54
|
+
passed = error <= tolerance
|
|
55
|
+
color = GREEN if passed else RED
|
|
56
|
+
drawing.line([tuple(a), tuple(b)], fill=color, width=2)
|
|
57
|
+
dot(drawing, a, color)
|
|
58
|
+
dot(drawing, b, color)
|
|
59
|
+
rows.append(dict(points=[a, b], evidence=evidence, errorPx=error, passed=passed))
|
|
60
|
+
checks[view] = rows
|
|
61
|
+
verdict = ("FAIL" if any(not row["passed"] for rows in checks.values() for row in rows)
|
|
62
|
+
else "PASS" if all(checks.values()) else "UNCONFIRMED")
|
|
63
|
+
overlay = sheet(images, "Orthographic atlas guides", "Cyan: silhouette / registered ground Green: pass Red: fail")
|
|
64
|
+
return dict(verdict=verdict, views=checks), overlay
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def acceptance(data, panels, results, tolerance, save_overlay):
|
|
68
|
+
sizes = dimensions(panels, tolerance)
|
|
69
|
+
cameras, overlay = camera(panels, data.get("axisPairs", {}), tolerance)
|
|
70
|
+
save_overlay("atlas-guides", cameras, overlay)
|
|
71
|
+
projection = results.get("projections", {})
|
|
72
|
+
contour = ("UNCONFIRMED" if projection.get("status") != "measured"
|
|
73
|
+
else "FAIL" if projection["unsupportedSamples"] else "PASS")
|
|
74
|
+
marks = results.get("landmarks", {}).get("landmarks", [])
|
|
75
|
+
shared = [e for row in marks for pair in row["sharedAxes"] for e in pair["sharedErrorPx"].values()]
|
|
76
|
+
held_out = [p["errorPx"] for row in marks for p in row["predictions"]]
|
|
77
|
+
landmarks = ("FAIL" if any(e > tolerance for e in shared + held_out)
|
|
78
|
+
else "PASS" if held_out and all(row["status"] == "measured" for row in marks)
|
|
79
|
+
else "UNCONFIRMED")
|
|
80
|
+
checks = dict(dimensions=sizes, cameras=cameras, projections=dict(verdict=contour),
|
|
81
|
+
landmarks=dict(verdict=landmarks))
|
|
82
|
+
verdicts = {check["verdict"] for check in checks.values()}
|
|
83
|
+
verdict = "FAIL" if "FAIL" in verdicts else "PASS" if verdicts == {"PASS"} else "UNCONFIRMED"
|
|
84
|
+
return dict(version=1, verdict=verdict, checks=checks,
|
|
85
|
+
inputs={view: panel.fingerprint for view, panel in panels.items()})
|
package/verification/panels.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"""Orthographic registration in pixel-center coordinates, without resampling source pixels."""
|
|
2
|
+
from hashlib import sha256
|
|
3
|
+
from io import BytesIO
|
|
2
4
|
from pathlib import Path
|
|
3
5
|
import math
|
|
4
6
|
|
|
@@ -37,9 +39,10 @@ class Panel:
|
|
|
37
39
|
self.axes, self.signs = AXES[view], SIGNS[view]
|
|
38
40
|
path = folder / config["image"]
|
|
39
41
|
if path not in images:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
raw = path.read_bytes()
|
|
43
|
+
with Image.open(BytesIO(raw)) as source:
|
|
44
|
+
images[path] = (source.convert("RGBA"), sha256(raw).hexdigest())
|
|
45
|
+
img, self.source_hash = images[path]
|
|
43
46
|
if "crop" in config:
|
|
44
47
|
x, y, w, h = config["crop"]
|
|
45
48
|
if any(type(n) is not int for n in (x, y, w, h)) or min(x, y) < 0 or min(w, h) < 1 or x+w > img.width or y+h > img.height:
|
|
@@ -59,6 +62,13 @@ class Panel:
|
|
|
59
62
|
raise ValueError(f"{view}: mask must be alpha or white")
|
|
60
63
|
if not self.mask.any():
|
|
61
64
|
raise ValueError(f"{view}: empty foreground")
|
|
65
|
+
ys, xs = np.nonzero(self.mask)
|
|
66
|
+
bounds = (slice(ys.min(), ys.max()+1), slice(xs.min(), xs.max()+1))
|
|
67
|
+
visible = pixels[bounds].copy()
|
|
68
|
+
visible[~self.mask[bounds]] = 0
|
|
69
|
+
h, w = visible.shape[:2]
|
|
70
|
+
self.fingerprint = dict(sourceSha256=self.source_hash,
|
|
71
|
+
viewSha256=sha256(f"{w}x{h}:".encode() + visible.tobytes()).hexdigest())
|
|
62
72
|
self.image = Image.new("RGB", img.size, "white")
|
|
63
73
|
self.image.paste(img, mask=img.getchannel("A"))
|
|
64
74
|
self.origin = point(config["origin"], f"{view}.origin") if "origin" in config else None
|
package/verification/verify.py
CHANGED
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
# ///
|
|
5
5
|
"""Verification entry point shared by the workspace CLI and the packaged executable."""
|
|
6
6
|
import argparse
|
|
7
|
+
from hashlib import sha256
|
|
7
8
|
import json
|
|
8
9
|
from pathlib import Path
|
|
9
10
|
import sys
|
|
10
11
|
|
|
11
12
|
import yaml
|
|
13
|
+
from acceptance import acceptance
|
|
12
14
|
from assembly import assemble
|
|
13
15
|
from landmarks import landmarks
|
|
14
16
|
from panels import atlas, read_manifest, scalar, unregistered
|
|
@@ -59,13 +61,18 @@ def run(args):
|
|
|
59
61
|
if out and image is not None:
|
|
60
62
|
out.mkdir(parents=True, exist_ok=True)
|
|
61
63
|
filename = name + ".png"
|
|
62
|
-
|
|
64
|
+
path = out / filename
|
|
65
|
+
image.save(path)
|
|
63
66
|
result["overlay"] = filename
|
|
67
|
+
if name == "atlas-guides":
|
|
68
|
+
result["overlaySha256"] = sha256(path.read_bytes()).hexdigest()
|
|
64
69
|
overlays.append(filename)
|
|
65
70
|
|
|
66
71
|
if kind == "atlas":
|
|
67
72
|
data, panels = atlas(path, config)
|
|
68
73
|
report = measure_atlas(data, panels, save_overlay, check=args.check)
|
|
74
|
+
if not args.check:
|
|
75
|
+
report["acceptance"] = acceptance(data, panels, report["results"], report["tolerancePx"], save_overlay)
|
|
69
76
|
else:
|
|
70
77
|
parts = config["parts"]
|
|
71
78
|
if not isinstance(parts, dict) or not parts or (args.part and args.part not in parts):
|