@svenflow/micro-handpose 0.1.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.
@@ -0,0 +1,54 @@
1
+ /** A 3D landmark point (x, y in [0,1] image coords, z is relative depth) */
2
+ interface Landmark {
3
+ x: number;
4
+ y: number;
5
+ z: number;
6
+ }
7
+ /** Detection result for a single hand */
8
+ interface HandposeResult {
9
+ /** Confidence score (0-1) that a hand is present */
10
+ score: number;
11
+ /** Whether this is a left or right hand */
12
+ handedness: 'left' | 'right';
13
+ /** 21 hand landmarks in order (wrist, thumb_cmc, ..., pinky_tip) */
14
+ landmarks: Landmark[];
15
+ }
16
+ /** Options for creating a handpose detector */
17
+ interface HandposeOptions {
18
+ /** URL to fetch weights from. Defaults to bundled weights or CDN. */
19
+ weightsUrl?: string;
20
+ /** Minimum confidence score to return a detection (0-1). Default: 0.5 */
21
+ scoreThreshold?: number;
22
+ }
23
+ /** A handpose detector instance */
24
+ interface Handpose {
25
+ /**
26
+ * Detect hand landmarks from an image source.
27
+ *
28
+ * Accepts: HTMLCanvasElement, OffscreenCanvas, ImageBitmap, HTMLImageElement,
29
+ * HTMLVideoElement, or ImageData.
30
+ *
31
+ * Returns null if no hand is detected (below score threshold).
32
+ */
33
+ detect: (source: HandposeInput) => Promise<HandposeResult | null>;
34
+ /** Dispose GPU resources */
35
+ dispose: () => void;
36
+ }
37
+ /** Accepted input types for detection */
38
+ type HandposeInput = HTMLCanvasElement | OffscreenCanvas | ImageBitmap | HTMLImageElement | HTMLVideoElement | ImageData;
39
+
40
+ /**
41
+ * Create a handpose detector.
42
+ *
43
+ * Downloads model weights and compiles the WebGPU pipeline.
44
+ * Call this once, then use `detect()` repeatedly.
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const handpose = await createHandpose()
49
+ * const result = await handpose.detect(canvas)
50
+ * ```
51
+ */
52
+ declare function createHandpose(options?: HandposeOptions): Promise<Handpose>;
53
+
54
+ export { type Handpose, type HandposeOptions, type HandposeResult, type Landmark, createHandpose };