Skip to content

About

Browser pose estimation SDK (vanilla JS) — TF.js + remote MoveNet/BlazePose. Script-tag IIFE + ESM. Free keypoints; optional API-key exercise engine.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

PoseTracker is a real-time pose estimation SDK and API for fitness and rehab apps. It runs MoveNet on-device on React Native, iOS, Android and the web. Keypoints are free. An optional API key adds rep counting, joint angles and a form score.

npm

Guide: https://www.posetracker.com/news/javascript-react-pose-estimation-sdk

Docs: https://docs.posetracker.com/web-sdks

React Native: https://www.posetracker.com/news/react-native-pose-estimation-expo

@pose-tracker/pose-estimation-web

Vanilla browser pose estimation (MoveNet / BlazePose / custom modelUrl) + remote exercise engine after configure(apiToken).

Default model: https://app.posetracker.com/scripts/tmp_model_to_remove.json

Install (npm)

npm install @pose-tracker/pose-estimation-web @tensorflow/tfjs
# Optional — BlazePose in bundlers (React / Vite). Vanilla IIFE can use CDN.
npm install @tensorflow-models/pose-detection
import { createPoseTracker } from '@pose-tracker/pose-estimation-web';

const pt = createPoseTracker({ model: 'movenet' });
pt.mount('#root');
await pt.start(); // default source = camera (webcam)
pt.on('keypoints', (e) => console.log(e.keypoints));

// BlazePose (peer or CDN window.poseDetection / auto-inject):
await pt.setModel('blazepose');

// Uploaded video / still image:
await pt.setSource({ type: 'video', src: videoFile }); // File | Blob | URL | HTMLVideoElement
await pt.start();
await pt.setSource({ type: 'image', src: imageFile });
await pt.start();       // single-shot keypoints
await pt.analyze();     // re-run on the same image

Input sources

PoseSource Behavior
{ type: 'camera', facingMode? } Live getUserMedia (default)
{ type: 'video', src } File / blob URL / <video> — stream while playing
{ type: 'image', src } File / blob URL / <img> / ImageBitmap — one shot (+ analyze())

Full tables (RN parity, CORS, React): monorepo docs/MEDIA_SOURCES.md · public https://docs.posetracker.com/media-sources

Several exercises, one call

A tracking call is counted once, on camera_start when the camera opens. startExercise never counts again. To chain exercises in the same call, keep the camera open and call it again:

pt.startExercise('squat');
// later, while the camera stays open:
pt.startExercise('plank'); // placement + counter restart, no new call

stop() then start(), or any new camera open ends the session; the next exercise counts as a new call. Optional pattern, no API change. Docs: https://docs.posetracker.com/reference/features-plans#what-counts-as-one-tracking-call

External frames (your camera, our data)

Full guide (getUserMedia, React, native cameras): https://docs.posetracker.com/external-frames

Optional. Use it when your page already owns the camera or the frames (your own <video>, WebRTC, a canvas pipeline) and you only need the data. No mount(), no getUserMedia, and nothing is drawn. Pose estimation and the exercise engine run on every frame, and every event you would get from the camera flow is emitted: keypoints, posture/placement, counter, form score.

const pt = createPoseTracker({ model: 'movenet' });
await pt.configure('YOUR_API_KEY'); // only needed for exercises
await pt.warmupExternal();
pt.startExercise('squat');
pt.on('counter', (e) => console.log(e.count)); // listeners still fire

// For each frame (ImageBitmap / <img> / <canvas> / <video>, or base64 / uri):
const { dropped, pose, events } = await pt.processFrame({
  image: bitmap,
  width: bitmap.width,
  height: bitmap.height,
  timestampMs: performance.now(),
  mirrored: true, // front camera (default)
});
  • One frame in flight at a time: an overlapping call resolves at once with { dropped: true, pose: lastPose, events: [] }.
  • Prefer image over base64, and keep frames small (longest side about 256 px).
  • The engine is temporal: push frames in order and keep the same session.
  • Don't mix the two flows. processFrame throws while start() is running.

Script tag (CDN)

The IIFE build exposes a PoseTracker global (PoseTracker.createPoseTracker, …).

Load TensorFlow.js first, then the SDK. Order matters.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>PoseTracker</title>
    <!-- 1) TensorFlow.js (peer — required before PoseTracker) -->
    <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@4.22.0/dist/tf.min.js"></script>
    <!-- 2) PoseTracker IIFE (jsDelivr / unpkg both work) -->
    <script src="https://cdn.jsdelivr.net/npm/@pose-tracker/pose-estimation-web@0.3.0/dist/pose-tracker.global.js"></script>
  </head>
  <body>
    <div id="root" style="width: 100%; height: 100vh; background: #111"></div>
    <script>
      const pt = PoseTracker.createPoseTracker({
        model: 'movenet',
        drawSkeleton: true,
        // source defaults to camera; also: { type:'video'|'image', src }
      });
      pt.mount('#root');
      pt.start().catch(console.error); // webcam
      // pt.setSource({ type: 'image', src: file }).then(() => pt.start());
      pt.on('keypoints', (e) => console.log(e.keypoints.length));
    </script>
  </body>
</html>

Equivalent unpkg URL:

https://unpkg.com/@pose-tracker/pose-estimation-web@0.3.0/dist/pose-tracker.global.js

Omitting /dist/... also works — package.json jsdelivr / unpkg fields point at the IIFE.

Optional BlazePose (CDN)

Preload pose-detection after TF.js (or omit — the SDK can inject the same CDN URL):

<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/pose-detection@2.1.3/dist/pose-detection.min.js"></script>

Global API (IIFE)

Global Notes
PoseTracker.createPoseTracker(options?) Main factory
PoseTracker.PoseCamera / mount helpers Camera helper
PoseTracker.configure Standalone configure helper
PoseTracker.DEFAULT_MOVENET_LIGHTNING_URL Default model URL
PoseTracker.SDK_VERSION / SDK_NAME Package identity

BlazePose maps to the same COCO-17 keypoints event shape as MoveNet (extra face/hand/foot landmarks dropped). It is heavier than MoveNet Lightning.

PoseTrackerNet (optional model, 39 keypoints)

Unreleased. MoveNet stays the default: nothing changes unless you select this model.

const pt = createPoseTracker({
  apiToken: 'YOUR_API_KEY',   // required for this model (free plan included)
  model: 'posetrackernet',    // = 'posetrackernet-lite'; or 'posetrackernet-ultra'
});
pt.mount('#root');
await pt.start();
pt.on('keypoints', (e) => console.log(e.keypoints.length)); // 39
console.log(pt.getPoseModelLicense()); // { name, notice, attribution, url }
  • API key and internet required. The model is handed out by the PoseTracker API to your API key at load time and kept in memory only: no offline mode, no local cache. Without a key, loading fails with a PoseModelError (code: 'api_key_required', "PoseTrackerNet needs an API key; keypoints with the default model stay free.") and an error event; there is no silent fallback to MoveNet. Other load failures: code: 'model_load_failed'.
  • Runtime. LiteRT.js (@litertjs/core@2.6.0) is imported from jsDelivr at run time, only when this model is selected. It is not a dependency of the package and TensorFlow.js is not used by this model. WebGPU when the browser has it, WebAssembly otherwise.
  • 39 keypoints. First the 17 COCO keypoints: same names, same order, same fields and coordinates as with MoveNet (COCO_KEYPOINT_NAMES). Then 22 more (POSETRACKERNET_EXTRA_KEYPOINT_NAMES, type PoseTrackerNetKeypointName): lower_neck_front, left_toe_inner, right_toe_inner, left_heel, right_heel, lower_neck_back, trunk_f1 … trunk_f5, trunk_b1 … trunk_b5, left_deltoid, right_deltoid, left_trapezius, right_trapezius, upper_neck_front, upper_neck_back.
  • Score rule. A keypoint appears from a score of 0.7; once shown it stays down to 0.5, so that it does not blink. A keypoint that is not shown keeps its place in the list with a score of 0: test score > 0. On a camera or a video a keypoint appears once it has held for about 0.1 s; keypoints are steadied by the model's own filter.
  • Skeleton. With drawSkeleton, this model draws its own default skeleton (POSETRACKERNET_SKELETON_DEFINITION: the default lines plus feet, neck, trunk and shoulder line). A skeletonDef / skeletonUuid of yours still takes precedence.
  • Licence. PoseTrackerNet is a proprietary model of PoseTracker, not open source: no redistribution, retraining, distillation or use in a competing SDK. Commercial use requires a paid plan (Developer or above) or a written agreement from PoseTracker. Credit it where your app credits its parts: "Pose estimation by PoseTrackerNet — posetracker.com". The licence granted with the model is on pt.getPoseModelLicense() and on the ready initialization event (modelLicense).

Watermark

Freemium watermark now links to posetracker.com. On a free or keyless session the live view shows “Powered by PoseTracker”, opening https://www.posetracker.com/?utm_source=watermark&utm_medium=web-sdk. Developer and Business plans hide it. Pass showWatermark: false to remove it on a session that would otherwise show it.

See monorepo root README for exercises + examples.

About

Browser pose estimation SDK (vanilla JS) — TF.js + remote MoveNet/BlazePose. Script-tag IIFE + ESM. Free keypoints; optional API-key exercise engine.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages