@framefields/node-vision 2.0.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.
@@ -0,0 +1,88 @@
1
+ import {
2
+ createOutputItemSchema,
3
+ SingleOutputGenericSchema,
4
+ VirtualMediaDataSchema,
5
+ } from "@framefields/core";
6
+ import {
7
+ ImageResultSchema,
8
+ MultiOutputGenericSchema,
9
+ } from "@framefields/node-sdk";
10
+ import { z } from "zod";
11
+
12
+ /**
13
+ * What the node draws:
14
+ * - passthrough — the child unchanged (vision signals still update)
15
+ * - mask — white subject silhouette on black
16
+ * - matte — the child cut out by the subject alpha (transparent background)
17
+ * - crop — the matte, punched in to the subject's bounds
18
+ * - skeleton — COCO-17 pose skeleton of the primary person
19
+ * - boxes — the child with tracked-object boxes
20
+ * - tracking — boxes plus track centers
21
+ */
22
+ export const VISION_MODES = [
23
+ "passthrough",
24
+ "mask",
25
+ "matte",
26
+ "crop",
27
+ "skeleton",
28
+ "boxes",
29
+ "tracking",
30
+ ] as const;
31
+
32
+ export type VisionMode = (typeof VISION_MODES)[number];
33
+
34
+ export const VisionNodeConfigSchema = z
35
+ .object({
36
+ enableDetection: z.boolean().default(true),
37
+ enableSegmentation: z.boolean().default(false),
38
+ enablePose: z.boolean().default(false),
39
+ enableMatte: z.boolean().default(false),
40
+ classes: z.array(z.string()).optional(),
41
+ confidence: z.number().min(0).max(1).default(0.3),
42
+ variant: z.enum(["t", "s", "m"]).default("s"),
43
+ mode: z.enum(VISION_MODES).default("passthrough"),
44
+ /**
45
+ * Source of the subject alpha for mask/matte/crop: `instance` (RTMDet-Ins, any COCO
46
+ * class, overlapping parts merged) or `selfie` (Selfie Segmenter, people only, fastest).
47
+ */
48
+ matteSource: z.enum(["instance", "selfie"]).default("instance"),
49
+ /** Frames a track may go unseen before it is dropped. */
50
+ maxMissedFrames: z.number().int().positive().default(15),
51
+ maskThreshold: z.number().min(0).max(1).default(0.5),
52
+ featherRadius: z.number().min(0).max(1).optional(),
53
+ /** Grow the subject into connected pixels that differ from the frame-border backdrop. */
54
+ keyBackground: z.boolean().default(false),
55
+ backgroundKeyThreshold: z.number().min(0).max(255).default(70),
56
+ modelsDir: z.string().optional(),
57
+ baseUrl: z.string().optional(),
58
+ visionBundle: z.custom<unknown>().optional(),
59
+ })
60
+ .strict();
61
+
62
+ export type VisionNodeConfig = z.infer<typeof VisionNodeConfigSchema>;
63
+
64
+ export const VisionOperationSchema = VisionNodeConfigSchema.extend({
65
+ op: z.literal("Vision"),
66
+ dataType: z.enum(["Image", "Video", "SVG", "GIF", "Caption"]).optional(),
67
+ inputs: z.record(z.string(), z.unknown()).optional(),
68
+ metadata: z.record(z.string(), z.unknown()).optional(),
69
+ });
70
+
71
+ export type VisionOperation = z.infer<typeof VisionOperationSchema>;
72
+
73
+ export const ImageVisionResultSchema = ImageResultSchema;
74
+ export type ImageVisionResult = z.infer<typeof ImageVisionResultSchema>;
75
+
76
+ const VisualOutputSchema = z.union([
77
+ createOutputItemSchema(z.literal("Video"), VirtualMediaDataSchema),
78
+ createOutputItemSchema(z.literal("Image"), VirtualMediaDataSchema),
79
+ createOutputItemSchema(z.literal("SVG"), VirtualMediaDataSchema),
80
+ createOutputItemSchema(z.literal("GIF"), VirtualMediaDataSchema),
81
+ ]);
82
+
83
+ export const VideoVisionResultSchema =
84
+ SingleOutputGenericSchema(VisualOutputSchema);
85
+ export type VideoVisionResult = z.infer<typeof VideoVisionResultSchema>;
86
+
87
+ export const VisionResultSchema = MultiOutputGenericSchema(VisualOutputSchema);
88
+ export type VisionResult = z.infer<typeof VisionResultSchema>;
@@ -0,0 +1 @@
1
+ export * from "./config.js";
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "@framefields/tsconfig/base.json",
3
+ "compilerOptions": {
4
+ "lib": ["ES2022", "ESNext", "DOM", "DOM.Iterable"],
5
+ "types": ["webgpu"],
6
+ "target": "esnext",
7
+ "noEmit": true
8
+ },
9
+ "include": ["src/**/*"],
10
+ "exclude": ["dist", "build", "node_modules"]
11
+ }
@@ -0,0 +1,13 @@
1
+ import { defineConfig } from "tsdown";
2
+
3
+ export default defineConfig({
4
+ entry: {
5
+ index: "src/index.ts",
6
+ renderer: "src/renderers/index.ts",
7
+ },
8
+ format: ["esm"],
9
+ dts: true,
10
+ clean: true,
11
+ sourcemap: true,
12
+ treeshake: true,
13
+ });