@viji-dev/core 0.4.6 → 0.5.0

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/index.d.ts CHANGED
@@ -1863,14 +1863,16 @@ declare interface TouchPoint {
1863
1863
  */
1864
1864
  declare type TrackingState = 'TRACKING' | 'LOCKED' | 'BREAKDOWN' | 'LOST';
1865
1865
 
1866
- export declare const VERSION = "0.3.29";
1866
+ export declare const VERSION = "0.5.0";
1867
1867
 
1868
1868
  /**
1869
- * Real-time video API: drawable frame, dimensions, and computer-vision results
1870
- * (faces, hands, pose, segmentation). Activate individual CV features through `cv.*`.
1869
+ * Real-time video API: drawable frame, dimensions, and the source-side
1870
+ * properties of the connected stream. All computer-vision data and controls
1871
+ * (faces, hands, pose, segmentation, the analysed frame, and feature
1872
+ * enable/disable verbs) live on `viji.video.cv`.
1871
1873
  *
1872
- * When `isConnected` is `false`, `currentFrame` is `null`, all dimensions are `0`,
1873
- * and CV result fields hold their empty defaults.
1874
+ * When `isConnected` is `false`, `currentFrame` is `null`, all dimensions are
1875
+ * `0`, and every member of `cv` holds its empty default.
1874
1876
  */
1875
1877
  export declare interface VideoAPI {
1876
1878
  /** `true` when a video stream is connected. When `false`, all other fields hold their default empty values. */
@@ -1889,6 +1891,70 @@ export declare interface VideoAPI {
1889
1891
  * use only when you need to read individual pixel values.
1890
1892
  */
1891
1893
  getFrameData: () => ImageData | null;
1894
+ /**
1895
+ * Computer-vision surface for this video stream. Holds both the data
1896
+ * outputs (`faces`, `hands`, `pose`, `segmentation`, `analysedFrame`,
1897
+ * `getAnalysedFrameData`) and the verbs that activate them
1898
+ * (`enable*`/`disable*`/`getActiveFeatures`/`isProcessing`).
1899
+ *
1900
+ * Multiple features can be active simultaneously, but each adds CPU/GPU
1901
+ * and WebGL-context cost — toggle only what you need.
1902
+ *
1903
+ * `analysedFrame` and the result fields refresh together once per host
1904
+ * frame (atomic snapshot) — within a single `render()` call they are
1905
+ * always paired.
1906
+ */
1907
+ cv: VideoCVAPI;
1908
+ }
1909
+
1910
+ /**
1911
+ * Computer-vision surface attached to a `VideoAPI`. Combines paired CV data
1912
+ * outputs (the analysed frame and its detection / segmentation results) with
1913
+ * the verbs that activate the underlying MediaPipe pipelines.
1914
+ *
1915
+ * Available only on the main video stream (`viji.video.cv`). Additional
1916
+ * streams (`viji.videoStreams[i].cv`) and device videos
1917
+ * (`viji.devices[i].video.cv`) do not run CV — their `cv` surface exists for
1918
+ * API consistency but the data fields stay at their empty defaults and the
1919
+ * `enable*` verbs are no-ops.
1920
+ */
1921
+ export declare interface VideoCVAPI {
1922
+ /**
1923
+ * The exact video frame that produced the current `faces` / `hands` /
1924
+ * `pose` / `segmentation` results — the frame MediaPipe actually analysed.
1925
+ * Use this (not `viji.video.currentFrame`) when overlaying pixel-precise
1926
+ * CV-driven effects (face-mesh masks, body-segmentation compositing,
1927
+ * makeup, distortion). `currentFrame` is the just-arrived frame and runs
1928
+ * ~15–40 ms ahead of the analysis; `analysedFrame` is the frame the
1929
+ * landmarks/mask actually correspond to, so the two stay locked under
1930
+ * fast head/body motion.
1931
+ *
1932
+ * Pairing guarantee: within a single `render()` call, `analysedFrame`
1933
+ * is paired with the values of `faces`, `hands`, `pose`, `segmentation`
1934
+ * you read in the same call. They refresh together once per host frame.
1935
+ *
1936
+ * `null` until the first CV inference completes after a feature is
1937
+ * enabled, after the video disconnects, or after a CV-feature toggle
1938
+ * clears state. A common pattern is
1939
+ * `viji.video.cv.analysedFrame ?? viji.video.currentFrame` to fall back
1940
+ * to the live feed during the brief startup window.
1941
+ *
1942
+ * Read-only: this `OffscreenCanvas` is owned by the engine. Do not
1943
+ * mutate it (no `getContext`-and-paint, no `transferToImageBitmap`).
1944
+ * Drawing it as a source (`ctx.drawImage`, `gl.texImage2D`,
1945
+ * `p5.image(...)`) is the only supported usage.
1946
+ */
1947
+ analysedFrame: OffscreenCanvas | null;
1948
+ /**
1949
+ * Returns `analysedFrame` as raw RGBA `ImageData` for per-pixel CPU
1950
+ * analysis, or `null` when no CV result has landed yet (or the stream is
1951
+ * disconnected). Cached: re-extracted only when a new CV result arrives,
1952
+ * so multiple readers within a render share one allocation. Slow
1953
+ * compared to drawing `analysedFrame` directly — use only when you need
1954
+ * pixel values aligned with CV landmark positions (e.g. sampling skin
1955
+ * colour at a face landmark).
1956
+ */
1957
+ getAnalysedFrameData: () => ImageData | null;
1892
1958
  /** Detected faces (empty array when face detection is off or no faces are visible). */
1893
1959
  faces: FaceData[];
1894
1960
  /** Detected hands (up to 2; empty array when hand tracking is off or no hands are visible). */
@@ -1898,50 +1964,42 @@ export declare interface VideoAPI {
1898
1964
  /** Body segmentation mask, or `null` when segmentation is off. */
1899
1965
  segmentation: SegmentationData | null;
1900
1966
  /**
1901
- * Computer-vision feature control. Each `enable*` method toggles a specific CV
1902
- * pipeline; results land in the corresponding `faces` / `hands` / `pose` /
1903
- * `segmentation` field on the next available frame. Multiple features can be
1904
- * active simultaneously, but each adds CPU/GPU and WebGL-context cost.
1967
+ * Toggle face detection (bounding box, center, confidence, id).
1968
+ * @returns Resolves once the underlying pipeline has finished switching.
1905
1969
  */
1906
- cv: {
1907
- /**
1908
- * Toggle face detection (bounding box, center, confidence, id).
1909
- * @returns Resolves once the underlying pipeline has finished switching.
1910
- */
1911
- enableFaceDetection(enabled: boolean): Promise<void>;
1912
- /**
1913
- * Toggle 468-point face mesh + head pose (`pitch`, `yaw`, `roll`). Implies
1914
- * face detection.
1915
- * @returns Resolves once the pipeline has finished switching.
1916
- */
1917
- enableFaceMesh(enabled: boolean): Promise<void>;
1918
- /**
1919
- * Toggle 7 expressions + 52 ARKit blendshape coefficients on each face.
1920
- * Implies face mesh.
1921
- * @returns Resolves once the pipeline has finished switching.
1922
- */
1923
- enableEmotionDetection(enabled: boolean): Promise<void>;
1924
- /**
1925
- * Toggle 21-point hand landmarks + ML-classified gesture confidences for up
1926
- * to two hands.
1927
- * @returns Resolves once the pipeline has finished switching.
1928
- */
1929
- enableHandTracking(enabled: boolean): Promise<void>;
1930
- /**
1931
- * Toggle 33-point BlazePose body landmarks (face / torso / arms / legs).
1932
- * @returns Resolves once the pipeline has finished switching.
1933
- */
1934
- enablePoseDetection(enabled: boolean): Promise<void>;
1935
- /**
1936
- * Toggle per-pixel person/background segmentation mask.
1937
- * @returns Resolves once the pipeline has finished switching.
1938
- */
1939
- enableBodySegmentation(enabled: boolean): Promise<void>;
1940
- /** Returns the list of CV features currently enabled on this stream. */
1941
- getActiveFeatures(): CVFeature[];
1942
- /** Returns `true` if the CV worker is actively processing frames. */
1943
- isProcessing(): boolean;
1944
- };
1970
+ enableFaceDetection(enabled: boolean): Promise<void>;
1971
+ /**
1972
+ * Toggle 468-point face mesh + head pose (`pitch`, `yaw`, `roll`). Implies
1973
+ * face detection.
1974
+ * @returns Resolves once the pipeline has finished switching.
1975
+ */
1976
+ enableFaceMesh(enabled: boolean): Promise<void>;
1977
+ /**
1978
+ * Toggle 7 expressions + 52 ARKit blendshape coefficients on each face.
1979
+ * Implies face mesh.
1980
+ * @returns Resolves once the pipeline has finished switching.
1981
+ */
1982
+ enableEmotionDetection(enabled: boolean): Promise<void>;
1983
+ /**
1984
+ * Toggle 21-point hand landmarks + ML-classified gesture confidences for up
1985
+ * to two hands.
1986
+ * @returns Resolves once the pipeline has finished switching.
1987
+ */
1988
+ enableHandTracking(enabled: boolean): Promise<void>;
1989
+ /**
1990
+ * Toggle 33-point BlazePose body landmarks (face / torso / arms / legs).
1991
+ * @returns Resolves once the pipeline has finished switching.
1992
+ */
1993
+ enablePoseDetection(enabled: boolean): Promise<void>;
1994
+ /**
1995
+ * Toggle per-pixel person/background segmentation mask.
1996
+ * @returns Resolves once the pipeline has finished switching.
1997
+ */
1998
+ enableBodySegmentation(enabled: boolean): Promise<void>;
1999
+ /** Returns the list of CV features currently enabled on this stream. */
2000
+ getActiveFeatures(): CVFeature[];
2001
+ /** Returns `true` if the CV worker is actively processing frames. */
2002
+ isProcessing(): boolean;
1945
2003
  }
1946
2004
 
1947
2005
  /**
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A, V, a, b } from "./index-Oj_9v8r4.js";
1
+ import { A, V, a, b } from "./index-Cp9G0z4E.js";
2
2
  export {
3
3
  A as AudioSystem,
4
4
  V as VERSION,
@@ -374,6 +374,16 @@ export const shaderUniforms = {
374
374
  "category": "Video",
375
375
  "description": "Video frame rate in frames per second"
376
376
  },
377
+ "u_videoAnalysed": {
378
+ "type": "sampler2D",
379
+ "category": "Video",
380
+ "description": "The exact frame MediaPipe analysed; pair with u_face*/u_hand*/u_pose* uniforms for pixel-precise CV-driven effects (face mesh masks, segmentation overlays). Shares u_videoResolution."
381
+ },
382
+ "u_videoAnalysedAvailable": {
383
+ "type": "bool",
384
+ "category": "Video",
385
+ "description": "True after the first CV result lands; before that, u_videoAnalysed samples a 1x1 black fallback. Use to gate effects that require valid analysed pixels."
386
+ },
377
387
  "u_videoStreamCount": {
378
388
  "type": "int",
379
389
  "category": "Video",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viji-dev/core",
3
- "version": "0.4.6",
3
+ "version": "0.5.0",
4
4
  "description": "Universal execution engine for Viji Creative scenes",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",