mediapipe-usage
Provides guidance for Google MediaPipe Pose Landmarker on web using @mediapipe/tasks-vision. Covers setup, landmark indices, running modes, and real-time video patterns. Use when working with MediaPipe, pose detection, body landmarks, or @mediapipe/tasks-vision.
What this skill does
# Google MediaPipe Usage (Web / Pose Landmarker)
## Quick Start
1. Install `@mediapipe/tasks-vision`, resolve WASM from CDN
2. Create `PoseLandmarker` with `createFromOptions`
3. Use `detect()` for single image, or `detectForVideo()` in a throttled `requestAnimationFrame` loop
## Setup
**Install (prefer pnpm):**
```bash
pnpm add @mediapipe/tasks-vision
```
**WASM root:** Resolve vision tasks from CDN when creating the task:
```ts
const vision = await FilesetResolver.forVisionTasks(
"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm",
);
```
## Create the Pose Landmarker Task
Use `PoseLandmarker.createFromOptions(vision, options)`:
```ts
import { PoseLandmarker, FilesetResolver } from "@mediapipe/tasks-vision";
const vision = await FilesetResolver.forVisionTasks(
"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm",
);
const poseLandmarker = await PoseLandmarker.createFromOptions(vision, {
baseOptions: {
modelAssetPath: modelUrl, // see reference.md for lite/full/heavy URLs
delegate: "GPU", // falls back to CPU if unavailable
},
runningMode: "VIDEO", // or "IMAGE" for single image
numPoses: 1,
minPoseDetectionConfidence: 0.5,
minPosePresenceConfidence: 0.5,
minTrackingConfidence: 0.5,
});
```
- **runningMode**: `IMAGE` for single image → use `detect(image)`. `VIDEO` for stream → use `detectForVideo(video, timestamp)`.
- **baseOptions.modelAssetPath**: URL to a `.task` model (lite / full / heavy). See [reference.md](reference.md) for URLs.
- **delegate**: `"GPU"` preferred; some environments fall back to CPU.
## Run the Task
**Single image (runningMode IMAGE):**
```ts
const result = poseLandmarker.detect(imageElement);
```
**Video / webcam (runningMode VIDEO):**
Call `detectForVideo(video, timestamp)` inside a `requestAnimationFrame` loop. Throttle by time (e.g. ~33 ms between frames) to avoid excessive work:
```ts
let lastFrameTime = 0;
function detectLoop() {
const now = performance.now();
if (video.readyState >= 2 && now - lastFrameTime > 33) {
lastFrameTime = now;
const result = poseLandmarker.detectForVideo(video, now);
if (result.landmarks?.length) {
const landmarks = result.landmarks[0]; // first person
// use landmarks
}
}
requestAnimationFrame(detectLoop);
}
requestAnimationFrame(detectLoop);
```
## Result Shape
- **result.landmarks**: Array of poses; each pose is `NormalizedLandmark[]` (33 points). Each landmark: `x`, `y`, `z` (normalized 0–1; z is depth relative to hip center), `visibility` (0–1).
- **result.worldLandmarks**: Optional 3D coordinates in meters (same indices).
- Single person: use `result.landmarks[0]`.
## Practical Patterns (Know-how)
- **State machine**: idle → loading (load model) → ready (can start) → active (webcam + detection) → error. When switching model variant, close the old PoseLandmarker instance and create a new one.
- **Throttle**: Run `detectForVideo` only when `performance.now() - lastFrameTime > 33` (≈30 fps) to avoid blocking the main thread.
- **Smoothing**: Apply a smoothing factor (e.g. 0.3) to derived values (pitch, bank) to reduce jitter; use a dead zone (in degrees) to ignore small movements.
- **Confidence**: Use each landmark’s `visibility`; ignore or downweight points below a threshold. Helper: `getLandmark(landmarks, index, minConfidence)` returning the point only if `visibility >= minConfidence`.
- **Gestures**: e.g. “hands forward” = compare shoulder vs wrist z; “hands overhead” = compare wrist y to shoulder y. Use consecutive-frame counters for toggles (e.g. require N frames in pose before firing an action).
## Cleanup
- Stop webcam: `stream.getTracks().forEach(t => t.stop())`.
- Release task: `poseLandmarker.close()` when done or before creating a new instance.
## Additional Resources
- For full 33 landmark indices and skeleton connections, see [reference.md](reference.md)
- For minimal example, skeleton overlay, and landmark-to-control mapping, see [examples.md](examples.md)
- Official docs: [Pose Landmarker Web JS](https://ai.google.dev/edge/mediapipe/solutions/vision/pose_landmarker/web_js), [Setup guide for web](https://ai.google.dev/edge/mediapipe/solutions/setup_web)
Related in Image & Video
watch
IncludedWatch a video (URL or local path). Downloads with yt-dlp, extracts auto-scaled frames with ffmpeg, pulls the transcript from captions (or Whisper API fallback), and hands the result to Claude so it can answer questions about what's in the video.
physical-ai-defect-image-generation
IncludedUse when the user wants to orchestrate defect image generation, run associated setup, or handle outputs on OSMO. The Day 0 path handles cold-start with USD-to-ROI, image-edit augmentation, and AnomalyGen to create initial PCBA datasets. The Day 1 path performs inference and labeling on real images. This skill helps with first-time asset setup, creation of finetuning checkpoints, and configuring deployment. Trigger keywords: defect image generation, dig workflow, dig pipeline, defect image detection workflow, aoi pipeline, aoi anomalygen, usd2roi anomalygen, day 0 pcba, day 1 pcba, day 1 real-photo alignment, day 1 manual roi, metal surface anomaly, glass defect, anomalygen finetune, setup_pcb, setup_metal, setup_glass, setup_pretrained, dig setup, dig datasets, dig pretrained checkpoint, dig image-edit endpoint.
accelint-react-best-practices
IncludedReact performance optimization and best practices. ALWAYS use this skill when working with any React code - writing components, hooks, JSX; refactoring; optimizing re-renders, memoization, state management; reviewing for performance; fixing hydration mismatches; debugging infinite re-renders, stale closures, input focus loss, animations restarting; preventing remounting; implementing transitions, lazy initialization, effect dependencies. Even simple React tasks benefit from these patterns. Covers React 19+ (useEffectEvent, Activity, ref props). Triggers - useEffect, useState, useMemo, useCallback, memo, inline components, nested components, components inside components, re-render, performance, hydration, SSR, Next.js, useDeferredValue, combined hooks.
elevenlabs-agents
IncludedBuild conversational AI voice agents with ElevenLabs Platform using React, JavaScript, React Native, or Swift SDKs. Configure agents, tools (client/server/MCP), RAG knowledge bases, multi-voice, and Scribe real-time STT. Use when: building voice chat interfaces, implementing AI phone agents with Twilio, configuring agent workflows or tools, adding RAG knowledge bases, testing with CLI "agents as code", or troubleshooting deprecated @11labs packages, Android audio cutoff, CSP violations, dynamic variables, or WebRTC config. Keywords: ElevenLabs Agents, ElevenLabs voice agents, AI voice agents, conversational AI, @elevenlabs/react, @elevenlabs/client, @elevenlabs/react-native, @elevenlabs/elevenlabs-js, @elevenlabs/agents-cli, elevenlabs SDK, voice AI, TTS, text-to-speech, ASR, speech recognition, turn-taking model, WebRTC voice, WebSocket voice, ElevenLabs conversation, agent system prompt, agent tools, agent knowledge base, RAG voice agents, multi-voice agents, pronunciation dictionary, voice speed control, elevenlabs scribe, @11labs deprecated, Android audio cutoff, CSP violation elevenlabs, dynamic variables elevenlabs, case-sensitive tool names, webhook authentication
humanizer
IncludedHumanize AI-generated text by detecting and removing patterns typical of LLM output. Rewrites text to sound natural, specific, and human. Uses 28 pattern detectors, 560+ AI vocabulary terms across 3 tiers, and statistical analysis (burstiness, type-token ratio, readability) for comprehensive detection. Use when asked to humanize text, de-AI writing, make content sound more natural/human, review writing for AI patterns, score text for AI detection, or improve AI-generated drafts. Covers content, language, style, communication, and filler categories.
generating-mermaid-diagrams
IncludedSalesforce architecture diagrams using Mermaid with ASCII fallback. Use this skill when generating text-based diagrams for Salesforce architecture, OAuth flows, ERDs, integration sequences, or Agentforce structure. TRIGGER when: user says "diagram", "visualize", "ERD", or asks for sequence diagrams, flowcharts, class diagrams, or architecture visualizations in Mermaid. DO NOT TRIGGER when: user wants PNG/SVG image output (use generating-visual-diagrams), or asks about non-Salesforce systems.