Skip to content

About

Real-time human pose detection and motion tracking system using TensorFlow.js

Topics

Resources

Contributing

Stars

18 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

252 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Pose Detection

A real-time webcam-based human pose detection and motion tracking system built with React, TypeScript, and TensorFlow.js.

๐ŸŽฎ Live Demo - Try it out in your browser!

The app running: a live camera feed with the control bar and motion-analysis panels below it

๐ŸŽฏ Features

  • Real-time Pose Detection: Uses TensorFlow.js with MoveNet for accurate pose estimation
  • Motion Tracking: Comprehensive movement analysis including joint positions, velocity, and acceleration
  • Gait Analysis: Specialized algorithms for walking pattern detection and analysis
  • Visual Feedback: Live skeleton overlay and motion visualization
  • Performance Optimized: Runs at 60+ FPS on modern hardware
  • Docker Support: Containerized deployment with runtime path configuration
  • PWA Ready: Installable as a Progressive Web App

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • Webcam access
  • Modern browser with WebGL support

Installation

git clone https://github.com/jedarden/pose-detection.git
cd pose-detection

# Install dependencies
npm install

# Start development server
npm run dev

npm run dev serves the app at http://localhost:3000 (the port is fixed in vite.config.ts; if that port is taken on your machine, relocate it with npm run dev -- --port 5173, which serves at http://localhost:5173). Open the URL, allow the browser's camera prompt, click โ–ถ๏ธ Start Analysis, and the skeleton overlay appears over the live camera feed.

Docker Deployment

# Build the container
docker build -t pose-detection .

# Run with default settings (root path); the container listens on 8080
docker run -p 8080:8080 pose-detection

# Run with custom base path (runtime setting, same image)
docker run -p 8080:8080 -e BASE_PATH=/pose pose-detection

If port 8080 is already in use on your machine, change the left-hand port only, e.g. -p 18080:8080, and open http://localhost:18080 instead.

๐Ÿ—๏ธ Architecture

  • Frontend: React 18 with TypeScript
  • Pose Detection: TensorFlow.js with MoveNet
  • State Management: React hooks and context
  • Styling: CSS modules with responsive design
  • Build Tool: Vite for fast development
  • Testing: Vitest for unit tests, Cypress for E2E

๐Ÿ“ฆ Key Components

  • PoseDetector: Core pose detection engine
  • MotionTracker: Movement analysis and tracking
  • GaitAnalyzer: Walking pattern detection
  • VisualOverlay: Real-time skeleton rendering
  • MetricsDisplay: Performance and accuracy metrics

๐Ÿ”ง Configuration

Environment Variables

  • BASE_PATH: URL base path for deployment (default: /)

There is no backend API endpoint variable. The application is fully client-side: webcam capture, pose detection (TensorFlow.js), motion tracking, and rendering all run in the browser, and the app does not call an application backend. Nothing in the build reads VITE_API_URL.

Runtime Configuration

The application supports runtime path configuration for flexible deployment:

// BASE_PATH is injected by the container at startup. The fallback supports
// local development, where no runtime injection is present.
const basePath = window.__BASE_PATH__ || '/';

BASE_PATH is a runtime setting only. There is no build-time path setting, and PUBLIC_URL is not used. BASE_PATH is the configured deployment prefix, not a value inferred from the current URL. Use / for the root deployment, /pose for a single-segment deployment, or /apps/pose-detector for a nested deployment. The same built image supports all three shapes at runtime.

๐Ÿ“Š Performance

  • Targets 60 FPS for smooth motion tracking
  • Optimized pose detection pipeline
  • WebGL acceleration for TensorFlow.js
  • Efficient canvas rendering

Browser performance benchmark

npm run bench:browser

Builds the production bundle, serves it, starts analysis with a fake camera in headless Chromium, and reports render FPS, detection FPS, dropped frames and detection latency as JSON. Render FPS and detection FPS must both reach BENCH_MIN_FPS (default 60, the target above) or the run exits 1. Exit 2 means the run could not complete (for example, no browser), so no verdict was produced.

Environment variables:

  • BENCH_CHROME: Chromium executable. Defaults to Playwright's cached build; set this when that build cannot start on the host.
  • BENCH_URL: measure an already-running app instead of building one.
  • BENCH_MIN_FPS, BENCH_WARMUP_MS, BENCH_DURATION_MS, BENCH_PORT: see scripts/browser-benchmark.mjs.

Results depend heavily on hardware. Headless Chromium without a GPU uses software WebGL, so numbers from such a host are not representative of users' machines. The benchmark is not part of the default verification gate.

๐Ÿงช Testing

# Run unit tests
npm test

# Run with coverage
npm run test:coverage

# Run E2E tests
npm run test:e2e

# Test the production container at root, single-segment, and nested paths
npm run test:deployment

๐Ÿšข Deployment

The canonical production CI/CD and repository workflow is documented in docs/CI-CD.md. Production pushes are authored on Forgejo; the GitHub copy is a read-only mirror used by the current webhook bridge.

Kubernetes

See k8s-example.yaml for a complete deployment example with:

  • Deployment with health checks
  • Service configuration
  • Ingress with path-based routing
  • TLS certificate management

Docker Compose

services:
  pose-detection:
    build: .
    ports:
      - "8080:8080"
    environment:
      - BASE_PATH=/pose

๐Ÿ“„ License

MIT License - see LICENSE file for details

๐Ÿค Contributing

Contributions are welcome! Forgejo is the source of truth for changes โ€” see .github/CONTRIBUTING.md for the workflow. The GitHub copy is a read-only mirror.

๐Ÿ“ž Support

๐Ÿค– AI-Generated Code

This project was created using AI assistance. Below are the prompts that were used to generate this codebase:

First Prompt

Create a new folder in research/pose-detection conduct deep research into creating a webpage that can use a computer's webcam to analyze and detect a human in the video and to overlay pose detection of the user's body. Source the data from from academic papers, github repos, blogs, and youtube transcripts (source using youtube-transcript-retrieval library). Create up to 8 agents using the available MCP servers to conduct the research. Put all file into research/pose-detection.

Second Prompt

Based on the research in research/pose-detection create a docker image in containers/pose-detection. The application should be a single docker image which exposes a single port. It will create a web experience that uses the user's webcam to detect the presence of a person and to draw an overlay showing the person's pose and orientation. Use up to 8 agents to build this application concurrently. Follow test driven development principles and keep iterating until the application is complete. If stuck conduct deep web searches to resolve the problem. All created files should go in containers/pose-detection


Built with โค๏ธ using React, TypeScript, and TensorFlow.js


Part of jedarden.com ยท Read the write-up: jedarden.com/projects/gait/

This repository is maintained on Forgejo at git.ardenone.com/jedarden/pose-detection; GitHub is a read-only mirror.

About

Real-time human pose detection and motion tracking system using TensorFlow.js

Topics

Resources

Contributing

Stars

18 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages