Turn one illustration into an animated 2D mesh avatar with a coding agent and a local editor
Document live tracking and streaming
shinshin863561f3ecc670
diff --git a/README.ja.md b/README.ja.mdindex 42ab1cb..5e1b5d9 100644--- a/README.ja.md+++ b/README.ja.md@@ -70,14 +70,20 @@ npm run dev## カメラで動かして配信する++エディタでプロジェクトを開き、「配信」を選びます。カメラを開始し、目と口の力を抜いて口を閉じ、正面を向いた状態で「正面の姿勢を登録」を押してください。左右反転、感度、動きのなめらかさを調整できます。マイクで口を動かすこともできます。映像と音声は端末内で処理し、配信用画面に渡すのはアバターの動きの数値だけです。-背景を選んで「OBS用URLをコピー」を押し、操作画面を開いたまま、OBSの「ブラウザ」ソースにURLを貼り付けます。サイズは **1080 × 1080** などに設定してください。背景が透明なら、そのままOBSで重ねて表示できます。ほかのソフトで取り込む場合は、緑の背景にしてクロマキーで抜く方法も使えます。+背景を選んで「OBS用URLをコピー」を押し(先に見た目を確かめたいときは「OBS用の画面を別タブで開く」)、操作画面を開いたまま、OBSの「ブラウザ」ソースにURLを貼り付けます。サイズは **1080 × 1080** などに設定してください。背景が透明なら、そのままOBSで重ねて表示できます。ほかのソフトで取り込む場合は、緑の背景にしてクロマキーで抜く方法も使えます。どちらの画面もローカルの開発サーバー(`npm run dev`)で使います。操作画面からの更新が止まると、配信用画面は待機動作に戻ります。操作画面は専用のウィンドウで開いたままにしてください。OBS用URLはOBSの中か別のタブで開き、操作画面のタブには貼り付けないでください。画面が隠れて追跡が停止・低速になったという表示が出た場合は、操作画面のウィンドウを前面に戻してください。+++配信用画面の URL で指定できる項目、うまく動かないときの確認点、プライバシーについては[リファレンス](docs/reference.md#live-and-streaming)(英語)にまとめています。+## 詳しい資料- [エージェント向けの手順書](docs/agent-guide.md): エージェントが作業するときの手順@@ -91,3 +97,5 @@ npm run devコードは [MIT License](LICENSE) で公開しています。サンプルのキャラクター「ミコ」(`samples/miko-qipao/`)は MIT License の対象外です。ミコは AITuber OnAir のキャラクター(© Yuki Shindo (AITuber OnAir))で、画像は[ミコ キャラクター利用ガイドライン](https://miko.aituberonair.com/#terms)に従って提供しています。概要は [samples/miko-qipao/MIKO_ASSET_TERMS.md](samples/miko-qipao/MIKO_ASSET_TERMS.md) を参照してください。自分の作品の一部として利用・改変できますが、画像だけを単体で配布したり、素材集として配布したりすることはできません。このプロジェクトは AITuber OnAir の公式製品ではありません。++顔の追跡には [MediaPipe](https://github.com/google-ai-edge/mediapipe)(`@mediapipe/tasks-vision` と、`vendor/mediapipe/` の Face Landmarker のモデル)を使っています。© The MediaPipe Authors、Apache License 2.0 です。[vendor/mediapipe/LICENSE](vendor/mediapipe/LICENSE) を参照してください。diff --git a/README.md b/README.mdindex 3a59e08..c668d17 100644--- a/README.md+++ b/README.md@@ -96,12 +96,14 @@ the masks and prompts for you to hand to an image generator.)## Live and streaming++Open your project in the editor and choose **Live**. Start the camera, face forward withrelaxed eyes and a closed mouth, then choose **Calibrate**. You can adjust mirroring,sensitivity and smoothing, or enable microphone lip sync. Camera video and microphoneaudio stay on your machine; only numeric avatar motion values reach the stream view.-Choose a background and **Copy OBS URL**. Keep the Live page open and add the URL as an+Choose a background and **Copy OBS URL**, or **Open stream view in a new tab** to check it first. Keep the Live page open and add the URL as anOBS **Browser Source**, for example at **1080 × 1080**. The transparent background worksdirectly in OBS. For other capture software, choose green and apply a chroma key.Both pages use the local development server (`npm run dev`). The stream view shows idle@@ -111,6 +113,11 @@ Keep the Live page open in its own window. Open the OBS URL inside OBS or in anotab; do not paste it into the tab running Live. If the page reports that tracking hasstopped or slowed while hidden, bring its window to the front.+++Stream view options, troubleshooting and privacy details are in the+[reference](docs/reference.md#live-and-streaming).+## More- [Agent guide](docs/agent-guide.md): the step-by-step procedure agents follow@@ -127,3 +134,7 @@ character of AITuber OnAir, © Yuki Shindo (AITuber OnAir), and her images are p[samples/miko-qipao/MIKO_ASSET_TERMS.md](samples/miko-qipao/MIKO_ASSET_TERMS.md). They may be usedand modified as part of your own works, but not redistributed on their own or as an assetcollection. This project is not an official AITuber OnAir product.++Face tracking uses [MediaPipe](https://github.com/google-ai-edge/mediapipe) (`@mediapipe/tasks-vision`+and the Face Landmarker model in `vendor/mediapipe/`), © The MediaPipe Authors, licensed under the+Apache License 2.0; see [vendor/mediapipe/LICENSE](vendor/mediapipe/LICENSE).diff --git a/docs/images/en/01-overview.png b/docs/images/en/01-overview.pngindex 03b8d3a..1aa7f2d 100644Binary files a/docs/images/en/01-overview.png and b/docs/images/en/01-overview.png differdiff --git a/docs/images/en/02-edit-handles.png b/docs/images/en/02-edit-handles.pngindex 5a9f793..35d1c4d 100644Binary files a/docs/images/en/02-edit-handles.png and b/docs/images/en/02-edit-handles.png differdiff --git a/docs/images/en/03-lip-sync.png b/docs/images/en/03-lip-sync.pngindex 541d4ec..23da4c0 100644Binary files a/docs/images/en/03-lip-sync.png and b/docs/images/en/03-lip-sync.png differdiff --git a/docs/images/en/04-rebuild.png b/docs/images/en/04-rebuild.pngindex 09f40ca..f8f61cf 100644Binary files a/docs/images/en/04-rebuild.png and b/docs/images/en/04-rebuild.png differdiff --git a/docs/images/en/05-variants.png b/docs/images/en/05-variants.pngindex 15118e7..62d6f26 100644Binary files a/docs/images/en/05-variants.png and b/docs/images/en/05-variants.png differdiff --git a/docs/images/en/06-new-project.png b/docs/images/en/06-new-project.pngindex 07b3c46..f04545f 100644Binary files a/docs/images/en/06-new-project.png and b/docs/images/en/06-new-project.png differdiff --git a/docs/images/en/07-live.png b/docs/images/en/07-live.pngnew file mode 100644index 0000000..59549a0Binary files /dev/null and b/docs/images/en/07-live.png differdiff --git a/docs/images/en/08-stream.png b/docs/images/en/08-stream.pngnew file mode 100644index 0000000..e7d7f85Binary files /dev/null and b/docs/images/en/08-stream.png differdiff --git a/docs/images/ja/01-overview.png b/docs/images/ja/01-overview.pngindex cce52d9..b267ddb 100644Binary files a/docs/images/ja/01-overview.png and b/docs/images/ja/01-overview.png differdiff --git a/docs/images/ja/02-edit-handles.png b/docs/images/ja/02-edit-handles.pngindex 7db7aec..02f0359 100644Binary files a/docs/images/ja/02-edit-handles.png and b/docs/images/ja/02-edit-handles.png differdiff --git a/docs/images/ja/03-lip-sync.png b/docs/images/ja/03-lip-sync.pngindex 3defa8b..932bcd5 100644Binary files a/docs/images/ja/03-lip-sync.png and b/docs/images/ja/03-lip-sync.png differdiff --git a/docs/images/ja/04-rebuild.png b/docs/images/ja/04-rebuild.pngindex b3ad1f7..62dcfa8 100644Binary files a/docs/images/ja/04-rebuild.png and b/docs/images/ja/04-rebuild.png differdiff --git a/docs/images/ja/05-variants.png b/docs/images/ja/05-variants.pngindex 076ff8f..9bebfeb 100644Binary files a/docs/images/ja/05-variants.png and b/docs/images/ja/05-variants.png differdiff --git a/docs/images/ja/06-new-project.png b/docs/images/ja/06-new-project.pngindex dd7e0d7..16b9f80 100644Binary files a/docs/images/ja/06-new-project.png and b/docs/images/ja/06-new-project.png differdiff --git a/docs/images/ja/07-live.png b/docs/images/ja/07-live.pngnew file mode 100644index 0000000..1a1adbfBinary files /dev/null and b/docs/images/ja/07-live.png differdiff --git a/docs/images/ja/08-stream.png b/docs/images/ja/08-stream.pngnew file mode 100644index 0000000..fca7a13Binary files /dev/null and b/docs/images/ja/08-stream.png differdiff --git a/docs/reference.md b/docs/reference.mdindex 45a0a65..a2002dd 100644--- a/docs/reference.md+++ b/docs/reference.md@@ -120,6 +120,64 @@ need a writable project from the development server. The app keeps images local;Codex card discloses the image-generation upload before you copy its request; otherexternal services are excluded from that request.+## Live and streaming++Two pages served by the development server (`npm run dev`):++- **Live page** (`/live.html?project=<name>`, or **Live** in the editor header): camera and+ microphone controls, face tracking, calibration and the stream URL.+- **Stream view** (`/stream.html`): only the avatar, for OBS or other capture software.++### Stream view URL++| Parameter | Values | Default |+|---|---|---|+| `project` | A project name from the local list, or `sample-miko-qipao` | the sample |+| `bg` | `transparent`, `green`, `blue` or a hex colour such as `#336699` | `transparent` |+| `fit` | `contain` (whole avatar) or `cover` (fill the frame) | `contain` |+| `idle` | `1` (idle motion, blinking, breathing, hair sway) or `0` | `1` |++Any other `bg` value falls back to transparent. In OBS, add the URL as a **Browser Source**+(for example 1080 × 1080); the transparent background needs no chroma key. Use green or blue+for software without transparency support.++### How motion reaches the stream view++- The Live page sends numeric pose values (head angles, eyes, gaze, brows, mouth) over the+ dev server's WebSocket, at most 60 times per second. The server accepts only well-formed+ numeric messages and rebroadcasts them; each stream view applies only messages for its own+ `project`.+- When updates stop for one second, the stream view eases back to idle motion.+- Tracking runs in a Web Worker, so it continues while the Live page is hidden: in another+ tab, minimised, or behind another window. Frames come from `MediaStreamTrackProcessor` where+ available, otherwise from `requestVideoFrameCallback` or a worker timer. If tracking still+ stops or slows, the Live page shows a warning; bring its window to the front.+- Face Landmarker uses the GPU and switches to the CPU once if the GPU fails or stays slow after+ warm-up.+- With the microphone on, the voice level drives how far the mouth opens and the camera keeps+ the mouth shape. Drawn mouth images are used automatically when the project has them.++### Privacy++Camera video and microphone audio are processed in the browser and never leave your machine.+Only the numeric pose values above travel over the local WebSocket. The MediaPipe runtime and+model are served locally; no CDN or remote model is requested, and the end-to-end tests fail if+either page makes a request outside `127.0.0.1`.++`@mediapipe/tasks-vision` is pinned to 0.10.21 because newer releases include code that posts+usage logs to Google. Read [vendor/mediapipe/README.md](../vendor/mediapipe/README.md) before+upgrading it.++### Troubleshooting++- **No camera image**: allow camera access when the browser asks. On macOS, also check+ System Settings → Privacy & Security → Camera for your browser. Chrome is recommended.+- **Movement is too small or jittery**: raise **Sensitivity**, or raise **Smoothing**.+ Calibrate again while facing the camera with a relaxed face.+- **Left and right are swapped**: toggle **Mirror**.+- **The stream view stays idle**: keep the Live page open and running, and make sure both pages+ use the same `project`.+## Verify```shdiff --git a/tools/capture-readme-screenshots.mjs b/tools/capture-readme-screenshots.mjsindex 9cfc4fc..b1199e3 100644--- a/tools/capture-readme-screenshots.mjs+++ b/tools/capture-readme-screenshots.mjs@@ -99,6 +99,19 @@ async function closeCards(page) {}async function prepare(page, language, scene) {const ja = language === 'ja';+ if (scene === '07-live') {+ await page.goto(new URL(`/live.html?project=${sampleId}`, server.resolvedUrls.local[0]).href);+ await expect(page.getByRole('status').first()).toContainText(ja ? 'アバターの準備完了' : 'Avatar ready');+ // The real URL contains this run's random port; show the usual dev-server address instead.+ await page.locator('.obs-url').evaluate((input, value) => { input.value = value; }, `http://127.0.0.1:5173/stream.html?project=${sampleId}&bg=transparent&fit=contain&idle=1`);+ return;+ }+ if (scene === '08-stream') {+ await page.goto(new URL(`/stream.html?project=${sampleId}&bg=green&idle=0`, server.resolvedUrls.local[0]).href);+ await page.waitForFunction(() => { const canvas = document.querySelector('canvas'); return !!canvas && canvas.width > 0; });+ await page.waitForTimeout(1500);+ return;+ }if (scene === '06-new-project') {await page.route('**/__studio/projects', route => route.fulfill({ contentType: 'application/json', body: '[]' }));for (const path of ['source.png', 'built/base.png']) await page.route(`**/miko-qipao/${path}`, route => route.fulfill({ status: 404, body: '' }));@@ -155,13 +168,16 @@ async function capture(language, scene) {localStorage.setItem('mesh-avatar-agent-recipient', 'codex');}, language);await prepare(page, language, scene);- await page.locator('.open-menu').evaluate(element => { element.open = false; });- await expect(page.getByTestId('first-guide')).toHaveCount(0);- await expect(page.locator('.save-notice')).toHaveCount(0);+ const editor = !['07-live', '08-stream'].includes(scene);+ if (editor) {+ await page.locator('.open-menu').evaluate(element => { element.open = false; });+ await expect(page.getByTestId('first-guide')).toHaveCount(0);+ await expect(page.locator('.save-notice')).toHaveCount(0);+ }await page.mouse.move(1430, 890);await page.evaluate(() => new Promise(done => requestAnimationFrame(() => requestAnimationFrame(done))));if (errors.length) throw new Error(`Browser error: ${errors.join('; ')}`);- const visible = await page.locator('main').innerText();+ const visible = await page.locator('body').innerText();for (const forbidden of [root, homedir(), basename(homedir()), '.readme-tmp-', '2000-01-01', 'Updated:', '更新:', '/path/to/', new Date().toISOString().slice(0, 10)]) {if (visible.includes(forbidden)) throw new Error(`Environment-specific text in ${language}/${scene}.`);}@@ -179,7 +195,7 @@ try {await server.listen();browser = await chromium.launch();const images = [];- const scenes = ['01-overview', '02-edit-handles', '03-lip-sync', '04-rebuild', '05-variants', '06-new-project'];+ const scenes = ['01-overview', '02-edit-handles', '03-lip-sync', '04-rebuild', '05-variants', '06-new-project', '07-live', '08-stream'];for (const language of ['en', 'ja']) for (const scene of scenes) {images.push(await capture(language, scene));console.log(`Captured ${language}/${scene}.png`);@@ -188,7 +204,7 @@ try {await mkdir(join(output, language), { recursive: true });await writeFile(join(output, language, `${scene}.png`), png);}- console.log('Saved 12 screenshots to docs/images/{en,ja}/ (1440×900, PNG without metadata).');+ console.log(`Saved ${images.length} screenshots to docs/images/{en,ja}/ (1440×900, PNG without metadata).`);} catch (error) {console.error(`screenshots: ${error.message.replaceAll(root, '<repo>/').replaceAll(homedir(), '~')}`);process.exitCode = 1;