@hackbuild/vision 0.1.1 → 0.1.3

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/dist/segment.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Prompted segmentation with one image embedding per image. The encoder
3
3
  * runs once per image; every later point or box prompt on that image
4
- * decodes from the cached embedding (as the earlier mask studio did, one
5
- * embedding per image, then hover and click decode from it).
4
+ * decodes from the cached embedding, so hover and click prompts stay
5
+ * cheap.
6
6
  */
7
7
  import type { ImageInput, Mask, SegmentPrompt, Segmenter } from "./types.js";
8
8
  /**
@@ -26,6 +26,7 @@ export declare class EmbeddingCache<E = unknown> {
26
26
  clear(): void;
27
27
  get size(): number;
28
28
  }
29
+ /** The parts of a prompted segmenter: an image encoder run once per image, a prompt decoder, and the embedding cache. */
29
30
  export interface PromptSegmenterOptions<E> {
30
31
  /** The image encoder: runs once per image. */
31
32
  encode(image: ImageInput): Promise<E>;
package/dist/segment.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Prompted segmentation with one image embedding per image. The encoder
3
3
  * runs once per image; every later point or box prompt on that image
4
- * decodes from the cached embedding (as the earlier mask studio did, one
5
- * embedding per image, then hover and click decode from it).
4
+ * decodes from the cached embedding, so hover and click prompts stay
5
+ * cheap.
6
6
  */
7
7
  /**
8
8
  * Least recently used embeddings by image. A key is a string the caller
package/dist/signals.d.ts CHANGED
@@ -14,11 +14,12 @@
14
14
  * language model, written only when it changed. Frames never leave the
15
15
  * tab: only these signals and the text made from them do.
16
16
  *
17
- * Thresholds below are vendor figures from earlier builds; none was
18
- * measured here.
17
+ * Thresholds below are vendor figures; none was measured here.
19
18
  */
20
19
  import type { Landmarks } from "./types.js";
20
+ /** The hand gestures the tracker reports: a wave from wrist motion, and the canned recognizer gestures by name. */
21
21
  export type HandGesture = "wave" | "thumbs_up" | "thumbs_down" | "open_palm" | "victory" | "pointing_up" | "fist" | "love";
22
+ /** Steady signals for one moment: present, where the face is, facing, smile, surprise and frown strengths, and the held gesture. */
22
23
  export interface Perception {
23
24
  present: boolean;
24
25
  /** The face in the viewer's frame, -1 to 1 on both axes: +x the character's left (the person's right), +y up. Null when no face is seen. */
@@ -34,6 +35,7 @@ export interface Perception {
34
35
  frown: number;
35
36
  gesture: HandGesture | null;
36
37
  }
38
+ /** A discrete perception event: someone arrived, left, smiled, or made a gesture. */
37
39
  export type PerceptionEvent = {
38
40
  type: "arrived";
39
41
  } | {
@@ -55,6 +57,7 @@ export interface RawFace {
55
57
  surprise: number;
56
58
  frown: number;
57
59
  }
60
+ /** One hand reading before smoothing: wrist position, the recognizer's canned label and its score. */
58
61
  export interface RawHand {
59
62
  /** Wrist position. */
60
63
  x: number;
@@ -63,6 +66,7 @@ export interface RawHand {
63
66
  gesture: string | null;
64
67
  score: number;
65
68
  }
69
+ /** One frame's readings for {@link SignalTracker}: the face, and the hands when they were checked. */
66
70
  export interface RawFrame {
67
71
  face: RawFace | null;
68
72
  /** Null on frames where hands were not checked. */
@@ -70,6 +74,7 @@ export interface RawFrame {
70
74
  }
71
75
  /** Canned recognizer labels to gesture names. */
72
76
  export declare const CANNED_GESTURES: Readonly<Record<string, HandGesture>>;
77
+ /** Turns raw face and hand frames into steady signals and discrete events, smoothed or held so one noisy frame never fires a reaction. */
73
78
  export declare class SignalTracker {
74
79
  private p;
75
80
  private lastSeen;
@@ -110,6 +115,7 @@ export declare class SeenNotes {
110
115
  }
111
116
  /** Questions that call for an on demand look rather than the steady signals. Replace it to suit a persona. */
112
117
  export declare const LOOK_PATTERN: RegExp;
118
+ /** True when a message asks the character to look, by {@link LOOK_PATTERN} or the pattern you pass. */
113
119
  export declare const wantsLook: (text: string, pattern?: RegExp) => boolean;
114
120
  /** One reaction to a perception event: a mood or a gesture by common name, after a delay, with a chance. */
115
121
  export interface Reaction {
package/dist/signals.js CHANGED
@@ -14,8 +14,7 @@
14
14
  * language model, written only when it changed. Frames never leave the
15
15
  * tab: only these signals and the text made from them do.
16
16
  *
17
- * Thresholds below are vendor figures from earlier builds; none was
18
- * measured here.
17
+ * Thresholds below are vendor figures; none was measured here.
19
18
  */
20
19
  // all vendor
21
20
  const PRESENT_GRACE_MS = 2500;
@@ -45,6 +44,7 @@ export const CANNED_GESTURES = {
45
44
  ILoveYou: "love",
46
45
  };
47
46
  const absent = () => ({ present: false, face: null, facing: false, smile: 0, surprise: 0, frown: 0, gesture: null });
47
+ /** Turns raw face and hand frames into steady signals and discrete events, smoothed or held so one noisy frame never fires a reaction. */
48
48
  export class SignalTracker {
49
49
  p = absent();
50
50
  lastSeen = -Infinity;
@@ -271,6 +271,7 @@ export class SeenNotes {
271
271
  }
272
272
  /** Questions that call for an on demand look rather than the steady signals. Replace it to suit a persona. */
273
273
  export const LOOK_PATTERN = /\b(what (am i|is this|'?s this|do you see|can you see)|can you see|do you see|look at (this|me|my)|what('?s| is) in my hand|holding|wearing|show(ing)? you)\b/i;
274
+ /** True when a message asks the character to look, by {@link LOOK_PATTERN} or the pattern you pass. */
274
275
  export const wantsLook = (text, pattern = LOOK_PATTERN) => pattern.test(text);
275
276
  /** Default reactions (vendor): greet on arrival, smile back after 600 ms at 0.7 chance, answer waves and a few gestures. */
276
277
  export const DEFAULT_REACTIONS = [