npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pose-camera

v0.3.4

Published

Plug-and-play camera and pose detection with Web Worker-based tracking

Downloads

607

Readme

pose-camera

Plug-and-play camera and pose detection for the browser. Uses a Web Worker for pose detection so the main thread stays responsive.

Install

npm install pose-camera @tensorflow-models/pose-detection @tensorflow/tfjs-core @tensorflow/tfjs-backend-webgl

Peer dependencies: @tensorflow-models/pose-detection, @tensorflow/tfjs-core, @tensorflow/tfjs-backend-webgl.

Usage

import { createPoseCamera } from 'pose-camera'

const camera = createPoseCamera()

// Optional: set which <video> shows the camera
camera.setVideoElement(document.querySelector('video'))

// Callbacks
camera.onFrame((users, options) => {
  console.log(users.length, 'user(s)', options.width, options.height)
})
camera.onStatusChange((status) => {
  console.log('status', status.cameraReady, status.tracking, status.modelStatus)
})

// Optional: enable face snapshots (128×128 crops every few seconds)
await camera.init({
  faceSnapshots: { enabled: true, intervalMs: 2000 },
})
const cameras = await camera.getAvailableCameras()
if (cameras.length) {
  await camera.selectCamera(cameras[0].deviceId)
  camera.startTracking()
}

// Or one-shot
await camera.start()

How it works

  • Main thread: Camera, video element, your callbacks (onFrame, onStatusChange), and frame capture. No TensorFlow on the main thread.
  • Web Worker: TensorFlow and the pose model run in a dedicated worker. Frames are sent as RGB data; poses are posted back. The API you use is the same – no worker-specific code.

The worker script is loaded from pose-camera-worker.js next to the main script. With a bundler (Vite, Webpack, etc.), you may need to pass the worker URL so it resolves correctly:

await camera.init({
  workerUrl: new URL('pose-camera/dist/pose-camera-worker.js', import.meta.url).href
})

Or configure your bundler to expose the worker (e.g. Vite’s ?worker or copying node_modules/pose-camera/dist/pose-camera-worker.js into your build).

API

  • status: { cameraReady, tracking, trackedUserCount, modelStatus, mediaPermission, error }
  • setVideoElement(element): Set the <video> that shows the camera feed.
  • onFrame(cb), onStatusChange(cb): Subscribe; return unsubscribe.
  • onFaceUpdate(cb): Subscribe to face snapshots (when faceSnapshots.enabled). Callback receives FaceSnapshot[] (128×128 face crops); return unsubscribe.
  • setFaceSnapshotOptions(options): Enable/disable face snapshots at runtime; options: { enabled, intervalMs? }.
  • init(options?): Load model (worker). Options: maxPoses, workerUrl, faceSnapshots ({ enabled, intervalMs? }), enableSmoothing (default false), modelType ('lite' | 'full', default 'lite').
  • getAvailableCameras(): List video input devices.
  • selectCamera(deviceId, constraints?): Start stream and attach to video element.
  • startTracking() / stopTracking(): Start or stop the detection loop.
  • dispose(): Stop tracking, stop camera, reset state.
  • start(options?): Init, optionally select camera, then start tracking.
  • utils: getRelativeToShoulders(pose, options) (center + all keypoints relative to center + body height), getAvailableMedia(), getMediaPermission(), avgBetween, distanceBetween.

Documentation

Types

TypeScript types are exported: PoseCameraAPI, Status, FrameOptions, UserFrame, InitOptions, StartOptions, FaceSnapshotOptions, FaceSnapshot, Pose (from pose-detection), DetectorModelType.

Global

In the browser, window.PoseCamera is set to the factory: window.PoseCamera() returns a new API instance.